Skip to content

Commit

Permalink
fmSQLPass - #178 - Added support for PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
WillyXJ committed Oct 18, 2016
1 parent b5927af commit 21292af
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
4 changes: 4 additions & 0 deletions server/fm-modules/fmSQLPass/change.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.3-alpha3 (2016-??-??)
=======================
* Server - [feature] Added support for PostgreSQL. (Issue #178)

1.3-alpha2 (2016-10-17)
=======================
* Server - [improvement] Added item name to the delete confirmations. (Issue #185)
Expand Down
6 changes: 4 additions & 2 deletions server/fm-modules/fmSQLPass/classes/class_servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function printForm($data = '', $action = 'add') {
$server_id = 0;
$server_name = $server_groups = $server_type = $server_port = null;
$server_cred_user = $server_cred_password = $server_credentials = null;
$server_type = 'database';
$server_type = 'MySQL';
$ucaction = ucfirst($action);

/** Build groups options */
Expand All @@ -327,6 +327,7 @@ function printForm($data = '', $action = 'add') {
$server_name_length = getColumnLength('fm_' . $__FM_CONFIG['fmSQLPass']['prefix'] . 'servers', 'server_name');

$server_types = buildSelect('server_type', 'server_type', $this->getServerTypes(), $server_type);
$server_port = ($server_port) ? $server_port : $__FM_CONFIG['fmSQLPass']['default']['ports'][$server_type];
$groups = (is_array($group_options)) ? buildSelect('server_groups', 1, $group_options, $server_groups, 4, null, true) : __('Server Groups need to be defined first.');

/** Handle credentials */
Expand Down Expand Up @@ -356,7 +357,7 @@ function printForm($data = '', $action = 'add') {
</tr>
<tr>
<th width="33&#37;" scope="row"><label for="server_port">%s</label></th>
<td width="67&#37;"><input type="number" name="server_port" value="%d" placeholder="3306" onkeydown="return validateNumber(event)" maxlength="5" max="65535" /></td>
<td width="67&#37;"><input type="number" name="server_port" id="server_port" value="%d" placeholder="3306" onkeydown="return validateNumber(event)" maxlength="5" max="65535" /></td>
</tr>
<tr>
<th width="33&#37;" scope="row"><label for="server_groups">%s</label></th>
Expand Down Expand Up @@ -404,6 +405,7 @@ function getServerTypes() {

foreach ($db_support as $db_type) {
$php_function = (strtolower($db_type) == 'postgresql') ? 'pg' : strtolower($db_type);
if ($php_function == 'mysql' && useMySQLi()) $php_function .= 'i';
if (function_exists($php_function . '_connect') && function_exists('change' . $db_type . 'UserPassword')) $fm_supported_servers[] = $db_type;
}

Expand Down
2 changes: 1 addition & 1 deletion server/fm-modules/fmSQLPass/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function installfmSQLPassSchema($database, $module, $noisy = 'noisy') {
`server_id` int(11) NOT NULL AUTO_INCREMENT,
`account_id` int(11) NOT NULL DEFAULT '1',
`server_serial_no` int(10) NOT NULL,
`server_type` enum('MySQL') NOT NULL,
`server_type` enum('MySQL','PostgreSQL') NOT NULL,
`server_port` int(5) DEFAULT NULL,
`server_name` varchar(255) NOT NULL,
`server_groups` text,
Expand Down
5 changes: 5 additions & 0 deletions server/fm-modules/fmSQLPass/js/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
return false;
});
$("#manage_item_contents").delegate("#server_type", "change", function(e) {
var server_ports = ' . json_encode($__FM_CONFIG['fmSQLPass']['default']['ports']) . ';
$("#server_port").val(server_ports[$(this).val()]);
});
});
';
?>
24 changes: 23 additions & 1 deletion server/fm-modules/fmSQLPass/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function upgradefmSQLPassSchema($module_name) {
$running_version = getOption('version', 0, $module_name);

/** Checks to support older versions (ie n-3 upgrade scenarios */
$success = version_compare($running_version, '1.0-rc1', '<') ? upgradefmSQLPass_01009($__FM_CONFIG, $running_version) : true;
$success = version_compare($running_version, '1.3-alpha3', '<') ? upgradefmSQLPass_01303($__FM_CONFIG, $running_version) : true;
if (!$success) return $fmdb->last_error;

return true;
Expand Down Expand Up @@ -206,4 +206,26 @@ function upgradefmSQLPass_01009($__FM_CONFIG, $running_version) {
return true;
}

/** 1.3-alpha2 */
function upgradefmSQLPass_01303($__FM_CONFIG, $running_version) {
global $fmdb, $module_name;

$success = version_compare($running_version, '1.0-rc1', '<') ? upgradefmSQLPass_01009($__FM_CONFIG, $running_version) : true;
if (!$success) return false;

$table[] = "ALTER TABLE `fm_{$__FM_CONFIG['fmSQLPass']['prefix']}servers` CHANGE `server_type` `server_type` ENUM('MySQL','PostgreSQL') NOT NULL";

/** Run queries */
if (count($table) && $table[0]) {
foreach ($table as $schema) {
$fmdb->query($schema);
if (!$fmdb->result || $fmdb->sql_errors) return false;
}
}

setOption('version', '1.3-alpha3', 'auto', false, 0, $module_name);

return true;
}

?>

0 comments on commit 21292af

Please sign in to comment.