Commit a2601b4a authored by juampynr's avatar juampynr Committed by Steven Jones

Issue #1261006 - Follow up: Tidy docs and add missing parent method.

parent 1d0ff080
......@@ -25,8 +25,8 @@ function db_drush_help($section) {
return dt('Unable to connect to database server.');
case 'error:PROVISION_CREATE_DB_FAILED' :
return dt('Unable to create new databases.');
case 'error:PROVISION_CREATE_DB_USER_FAILED' :
return dt('Unable to create new database users.');
case 'error:PROVISION_GRANT_DB_USER_FAILED' :
return dt('Unable to grant privileges to database users.');
case 'error:PROVISION_DROP_DB_FAILED' :
return dt('Unable to drop database.');
}
......@@ -71,10 +71,10 @@ class provisionService_db extends provisionService {
drush_set_error('PROVISION_CREATE_DB_FAILED');
}
if ($this->can_grant_privileges()) {
drush_log(dt('Provision can create database users.'), 'message');;
drush_log(dt('Provision can grant privileges on database users.'), 'message');;
}
else {
drush_set_error('PROVISION_CREATE_DB_USER_FAILED');
drush_set_error('PROVISION_GRANT_DB_USER_FAILED');
}
} else {
drush_set_error('PROVISION_CONNECT_DB_FAILED');
......@@ -239,6 +239,10 @@ class provisionService_db extends provisionService {
return FALSE;
}
function can_grant_privileges() {
return FALSE;
}
function grant($name, $username, $password, $host = '') {
return FALSE;
}
......
......@@ -36,18 +36,22 @@ class provisionService_db_mysql extends provisionService_db_pdo {
}
/**
* Verifies that Aegir can grant privileges to a user on a database
* Verifies that provision can grant privileges to a user on a database.
*
* @return
* boolean TRUE if the check was successful
* TRUE if the check was successful.
*/
function can_grant_privileges() {
$test = drush_get_option('aegir_db_prefix', 'site_');
$status = $this->grant($test, $test . 'user', $test . 'password', $test . 'host');
$dbname = drush_get_option('aegir_db_prefix', 'site_');
$user = $dbname . '_user';
$password = $dbname . '_password';
$host = $dbname . '_host';
if ($status = $this->grant($dbname, $user, $password, $host)) {
$this->revoke($dbname, $user, $host);
}
return $status;
}
function grant($name, $username, $password, $host = '') {
$host = ($host) ? $host : '%';
return $this->query("GRANT ALL PRIVILEGES ON `%s`.* TO `%s`@`%s` IDENTIFIED BY '%s'", $name, $username, $host, $password);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment