/** * return the last inserted id for a specific database table * @param string $p_table a valid database table name * @return int last successful insert id */ function db_insert_id($p_table = null, $p_field = "id") { global $g_db; if (isset($p_table) && db_is_pgsql()) { $query = "SELECT currval('" . $p_table . "_" . $p_field . "_seq')"; $result = db_query_bound($query); return db_result($result); } if (db_is_mssql()) { $query = "SELECT IDENT_CURRENT('{$p_table}')"; $result = db_query_bound($query); return db_result($result); } return $g_db->Insert_ID(); }
db_connect($t_database_dsn, $t_database_hostname, $t_database_username, $t_database_password, $t_database_name); check_print_test_row('Can open connection to database <em>' . htmlentities($t_database_name) . '</em> on host <em>' . htmlentities($t_database_hostname) . '</em> with username <em>' . htmlentities($t_database_username) . '</em>', db_is_connected()); if (!db_is_connected()) { return; } $t_database_server_info = $g_db->ServerInfo(); $t_db_version = $t_database_server_info['version']; preg_match('/^[0-9]+\\.[0-9+]/', $t_db_version, $t_matches); $t_db_major_version = $t_matches[0]; # MantisBT minimum version check_print_info_row('Database server version', htmlentities($t_database_server_info['version'])); if (db_is_mysql()) { $t_db_min_version = DB_MIN_VERSION_MYSQL; } elseif (db_is_pgsql()) { $t_db_min_version = DB_MIN_VERSION_PGSQL; } elseif (db_is_mssql()) { $t_db_min_version = DB_MIN_VERSION_MSSQL; } else { $t_db_min_version = 0; } check_print_test_row('Minimum database version required for MantisBT', version_compare($t_db_version, $t_db_min_version, '>='), array(true => 'You are using version ' . htmlentities($t_db_version) . '.', false => 'The database version you are using is ' . htmlentities($t_db_version) . '. The minimum requirement for MantisBT on your database platform is ' . $t_db_min_version . '.')); $t_date_format = config_get('short_date_format'); # MySQL support checking if (db_is_mysql()) { # Note: the MySQL lifecycle page [1] is no longer available. # The list below was built based on information found in [2]. # [1] http://www.mysql.com/about/legal/lifecycle/ # [2] http://dev.mysql.com/doc/refman/5.7/en/faqs-general.html#qandaitem-B-1-1-1 $t_versions = array('5.0' => array('GA', '5.0.15', '2005-10-19'), '5.1' => array('GA', '5.1.30', '2008-11-14'), '5.4' => array('Discontinued'), '5.5' => array('GA', '5.5.8', '2010-12-03'), '5.6' => array('GA', '5.6.10', '2013-02-05'), '5.7' => array('Development'), '6.0' => array('Discontinued')); $t_support_url = 'http://www.mysql.com/support/'; # Is it a GA release
$t_serverinfo = $g_db->ServerInfo(); print_info_row('Database Type (adodb)', $g_db->databaseType); print_info_row('Database Provider (adodb)', $g_db->dataProvider); print_info_row('Database Server Description (adodb)', $t_serverinfo['description']); print_info_row('Database Server Description (version)', $t_serverinfo['version']); print_test_row('Checking to see if your absolute_path config option has a trailing slash: "' . config_get_global('absolute_path') . '"', "\\" == substr(config_get_global('absolute_path'), -1, 1) || "/" == substr(config_get_global('absolute_path'), -1, 1)); // Windows-only checks if (is_windows_server()) { print_test_row('validate_email (if ON) requires php 5.3 on windows...', OFF == config_get_global('validate_email') || ON == config_get_global('validate_email') && version_compare(phpversion(), '5.3.0', '>=')); print_test_row('check_mx_record (if ON) requires php 5.3 on windows...', OFF == config_get_global('check_mx_record') || ON == config_get_global('check_mx_record') && version_compare(phpversion(), '5.3.0', '>=')); } $t_vars = array('magic_quotes_gpc', 'include_path'); while (list($t_foo, $t_var) = each($t_vars)) { print_info_row($t_var, ini_get($t_var)); } if (db_is_mssql()) { if ('mssql' == config_get_global('db_type')) { print_test_warn_row('Checking PHP support for Microsoft SQL Server driver', version_compare(phpversion(), '5.3') < 0, "'mssql' driver is no longer supported in PHP >= 5.3, please use 'mssqlnative' instead"); } if (print_test_row('check mssql textsize in php.ini...', ini_get('mssql.textsize') != 4096, ini_get('mssql.textsize'))) { print_test_warn_row('check mssql textsize in php.ini...', ini_get('mssql.textsize') == 2147483647, ini_get('mssql.textsize')); } if (print_test_row('check mssql textsize in php.ini...', ini_get('mssql.textlimit') != 4096, ini_get('mssql.textlimit'))) { print_test_warn_row('check mssql textsize in php.ini...', ini_get('mssql.textsize') == 2147483647, ini_get('mssql.textsize')); } } print_test_row('check variables_order includes GPCS', stristr(ini_get('variables_order'), 'G') && stristr(ini_get('variables_order'), 'P') && stristr(ini_get('variables_order'), 'C') && stristr(ini_get('variables_order'), 'S'), ini_get('variables_order')); test_bug_download_threshold(); test_bug_attachments_allow_flags(); print_test_row('check mail configuration: send_reset_password = ON requires allow_blank_email = OFF', OFF == config_get_global('send_reset_password') || OFF == config_get_global('allow_blank_email')); print_test_row('check mail configuration: send_reset_password = ON requires enable_email_notification = ON', OFF == config_get_global('send_reset_password') || ON == config_get_global('enable_email_notification'));
/** * return the last inserted id for a specific database table * @param string $p_table A valid database table name. * @param string $p_field A valid field name (default 'id'). * @return integer last successful insert id */ function db_insert_id($p_table = null, $p_field = 'id') { global $g_db; if (isset($p_table)) { if (db_is_oracle()) { $t_query = 'SELECT seq_' . $p_table . '.CURRVAL FROM DUAL'; } elseif (db_is_pgsql()) { $t_query = 'SELECT currval(\'' . $p_table . '_' . $p_field . '_seq\')'; } if (isset($t_query)) { $t_result = db_query($t_query); return db_result($t_result); } } if (db_is_mssql()) { $t_query = 'SELECT IDENT_CURRENT(\'' . $p_table . '\')'; $t_result = db_query($t_query); return db_result($t_result); } return $g_db->Insert_ID(); }
/** * Gets the candidates for the specified bug. These are existing tags * that are not associated with the bug already. * * @param int $p_bug_id The bug id, if 0 returns all tags. * @returns The array of tag rows, each with id, name, and description. */ function tag_get_candidates_for_bug($p_bug_id) { $t_tag_table = db_get_table('tag'); $t_params = array(); if (0 != $p_bug_id) { $t_bug_tag_table = db_get_table('bug_tag'); if (db_is_mssql()) { $t_params[] = $p_bug_id; $query = "SELECT t.id FROM {$t_tag_table} t\n\t\t\t\t\tLEFT JOIN {$t_bug_tag_table} b ON t.id=b.tag_id\n\t\t\t\t\tWHERE b.bug_id IS NULL OR b.bug_id != " . db_param(); $result = db_query_bound($query, $t_params); $t_subquery_results = array(); while ($row = db_fetch_array($result)) { $t_subquery_results[] = (int) $row['id']; } if (count($t_subquery_results) == 0) { return array(); } $query = "SELECT id, name, description FROM {$t_tag_table} WHERE id IN ( " . implode(', ', $t_subquery_results) . ')'; } else { $query = "SELECT id, name, description FROM {$t_tag_table} WHERE id IN (\n\t\t\t\t\tSELECT t.id FROM {$t_tag_table} t\n\t\t\t\t\tLEFT JOIN {$t_bug_tag_table} b ON t.id=b.tag_id\n\t\t\t\t\tWHERE b.bug_id IS NULL OR b.bug_id != " . db_param() . ')'; } $t_params[] = $p_bug_id; } else { $query = 'SELECT id, name, description FROM ' . $t_tag_table; } $query .= ' ORDER BY name ASC '; $result = db_query_bound($query, $t_params); $t_results_to_return = array(); while ($row = db_fetch_array($result)) { $t_results_to_return[] = $row; } return $t_results_to_return; }
function setAgileMantisUserRights($p_user_id, $p_participant, $p_developer, $p_administrator) { $t_user = $this->getAdditionalUserFields($p_user_id); if (empty($p_participant)) { $p_participant = 0; } if (empty($p_developer)) { $p_developer = 0; } if (empty($p_administrator)) { $p_administrator = 0; } // Den User gibt es schon -> update, falls nichts dagegen spricht if ($t_user[0]['user_id'] > 0) { $t_sql = "UPDATE gadiv_additional_user_fields \n\t\t\t\t\t\t\tSET participant=" . db_param(0) . ", \n\t\t\t\t\t\t\tdeveloper=" . db_param(1) . ", \n\t\t\t\t\t\t\tadministrator=" . db_param(2) . " \n\t\t\t\t\t\t\tWHERE user_id=" . db_param(3); $t_params = array($p_participant, $p_developer, $p_administrator, $p_user_id); # Der User ist neu -> insert } else { $t_sql = "INSERT INTO gadiv_additional_user_fields \n\t\t\t\t\t\t\tSET user_id=" . db_param(0) . ", \n\t\t\t\t\t\t\tparticipant=" . db_param(1) . ", \n\t\t\t\t\t\t\tdeveloper=" . db_param(2) . ", \n\t\t\t\t\t\t\tadministrator=" . db_param(3) . ", \n\t\t\t\t\t\t\texpert=0"; if (db_is_mssql()) { $t_sql = "INSERT INTO gadiv_additional_user_fields\n\t\t\t\t\t\t\tVALUES (" . db_param(0) . "," . db_param(1) . "," . db_param(2) . "," . db_param(3) . ",0)"; } $t_params = array($p_user_id, $p_participant, $p_developer, $p_administrator); } db_query_bound($t_sql, $t_params); }
function getDateFormat($p_year, $p_month, $p_day, $p_withTime = false) { if (db_is_mssql()) { $t_sql = "SELECT dateformat FROM master..syslanguages WHERE name = @@LANGUAGE"; $t_result = $this->executeQuery($t_sql); if ($t_result[0]['dateformat'] == 'dmy') { //german mssqlserver $german_date_format = str_pad($p_day, 2, '0', STR_PAD_LEFT) . "-" . str_pad($p_month, 2, '0', STR_PAD_LEFT) . "-" . $p_year; if ($p_withTime) { return $german_date_format . " " . date('H') . ":" . date('i') . ":" . date('s') . ".000"; } return $german_date_format; } } //or every other dbs $other_date_format = $p_year . "-" . str_pad($p_month, 2, '0', STR_PAD_LEFT) . "-" . str_pad($p_day, 2, '0', STR_PAD_LEFT); if ($p_withTime) { return $other_date_format . " " . date('H') . ":" . date('i') . ":" . date('s'); } return $other_date_format; }
/** * return the last inserted id for a specific database table * @param string $p_table a valid database table name * @return int last successful insert id */ function db_insert_id($p_table = null, $p_field = "id") { global $g_db; $t_db_type = config_get_global('db_type'); if (isset($p_table)) { if (db_is_oracle()) { $query = "SELECT seq_" . $p_table . ".CURRVAL FROM DUAL"; } elseif (db_is_pgsql()) { $query = "SELECT currval('" . $p_table . "_" . $p_field . "_seq')"; } if (isset($query)) { $result = db_query_bound($query); return db_result($result); } } if (db_is_mssql()) { $query = "SELECT IDENT_CURRENT('{$p_table}')"; $result = db_query_bound($query); return db_result($result); } return $g_db->Insert_ID(); }
/** * Will be executed, if the user hits the install link on the plugin * overview page and before schema() */ function install() { $t_plugin_path = config_get_global('plugin_path') . plugin_get_current() . DIRECTORY_SEPARATOR; // Install site key plugin_config_set('gadiv_sitekey', md5(uniqid(rand(), true))); $this->installConfigurationParams(); // Create custom fields $this->create_custom_field('ProductBacklog', array('possible_values' => '', 'type' => '6')); // List $this->create_custom_field('Sprint', array('possible_values' => '', 'type' => '6')); // List $this->create_custom_field('Storypoints', array('possible_values' => '', 'type' => '1')); // Number $this->create_custom_field('BusinessValue', array('possible_values' => '', 'type' => '0')); // Text $this->create_custom_field('RankingOrder', array('possible_values' => '', 'type' => '1')); // Number $this->create_custom_field('Presentable', array('possible_values' => '1|2|3', 'type' => '6')); // List $this->create_custom_field('Technical', array('possible_values' => 'Ja', 'type' => '5')); // Checkbox $this->create_custom_field('InReleaseDocu', array('possible_values' => 'Ja', 'type' => '5')); // Checkbox $this->create_custom_field('PlannedWork', array('possible_values' => '', 'type' => '1')); // Number $this->create_custom_field('PlannedWorkUnit', array('possible_values' => '0|1|2|3', 'type' => '0', 'filter_by' => '0')); // Text // If old tables exists, that where not created by ADODB, the setting 'plugin_agileMantis_schema' // needs to be set to the last block of the schema that was created without ADODB. // e.g. if the last table created without ADODB was 'gadiv_teams', the plugin_agileMantis_schema // needs to be set to the corresponding schema block. Only the blocks after that will be executed. if (plugin_config_get('schema', -1) == -1) { if (db_is_mysql()) { if ($this->getDBVersion() == '2.0.0') { // Version 2.0. is installed, set block to #21 plugin_config_set('schema', 21); } else { if (db_field_exists('expert', 'gadiv_additional_user_fields')) { // Version 1.3 is installed, set block to #14 plugin_config_set('schema', 14); } else { if (db_table_exists('gadiv_sprints')) { // Version < 1.3 is installed, set block to #13 plugin_config_set('schema', 13); } } } } else { if (db_is_mssql()) { plugin_config_set('schema', -1); } } } return TRUE; }
function getPreviousSprint($sprint_id, $team_id) { $t_sql = "SELECT enddate as " . AGILEMANTIS_END_FIELD . " FROM gadiv_sprints WHERE id=" . db_param(0); $t_params = array($sprint_id); $sprint = $this->executeQuery($t_sql, $t_params); $top = ""; $limit = ""; if (db_is_mssql()) { $top = " top 1 "; } else { $limit = " LIMIT 0, 1 "; } $t_sql = "SELECT " . $top . "id,\n\t\t\t\t\t\t\tteam_id,\n\t\t\t\t\t\t\tpb_id,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\tstatus,\n\t\t\t\t\t\t\tdaily_scrum,\n\t\t\t\t\t\t\tstart,\n\t\t\t\t\t\t\tdispose as " . AGILEMANTIS_COMMIT_FIELD . ",\n\t\t\t\t\t\t\tenddate as " . AGILEMANTIS_END_FIELD . ",\n\t\t\t\t\t\t\tclosed,\n\t\t\t\t\t\t\tunit_storypoints,\n\t\t\t\t\t\t\tunit_planned_work,\n\t\t\t\t\t\t\tunit_planned_task,\n\t\t\t\t\t\t\tworkday_length,\n\t\t\t\t\t\t\tsprint_id,\n\t\t\t\t\t\t\tcount_user_stories,\n\t\t\t\t\t\t\tcount_task_sprint,\n\t\t\t\t\t\t\tcount_splitted_user_stories_sprint,\n\t\t\t\t\t\t\tstorypoints_sprint,\n\t\t\t\t\t\t\tstorypoints_in_splitted_user_stories,\n\t\t\t\t\t\t\twork_planned_sprint,\n\t\t\t\t\t\t\twork_performed,\n\t\t\t\t\t\t\twork_moved,\n\t\t\t\t\t\t\tstorypoints_moved,\n\t\t\t\t\t\t\tcount_developer_team,\n\t\t\t\t\t\t\ttotal_developer_capacity,\n\t\t\t\t\t\t\tcount_developer_team_task,\n\t\t\t\t\t\t\ttotal_developer_capacity_task\n\t\t\t\tFROM gadiv_sprints \n\t\t\t\tLEFT JOIN gadiv_rel_sprint_closed_information ON sprint_id = id \n\t\t\t\tWHERE enddate < " . db_param(0) . " \n\t\t\t\tAND team_id=" . db_param(1) . " \n\t\t\t\tORDER BY id DESC" . $limit; $t_params = array($sprint[0]['end'], $team_id); return $this->executeQuery($t_sql, $t_params); }