Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually allow other host names, as well as allow you to put everything in the same database #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/oauth/ZohoOAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ private static function setConfigValues($configuration)
ZohoOAuthConstants::DATABASE_PORT,
ZohoOAuthConstants::DATABASE_PASSWORD,
ZohoOAuthConstants::DATABASE_USERNAME,
ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS_NAME
ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS_NAME,
ZohoOAuthConstants::DATABASE_NAME,
ZohoOAuthConstants::HOST_ADDRESS
);

if (! array_key_exists(ZohoOAuthConstants::ACCESS_TYPE, $configuration) || $configuration[ZohoOAuthConstants::ACCESS_TYPE] == "") {
Expand Down Expand Up @@ -160,4 +162,4 @@ public static function getClientInstance()
}
return ZohoOAuthClient::getInstanceWithOutParam();
}
}
}
9 changes: 7 additions & 2 deletions src/oauth/persistence/ZohoOAuthPersistenceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,16 @@ public function deleteOAuthTokens($userEmailId)

public function getMysqlConnection()
{
$mysqli_con = new \mysqli(ZohoOAuth::getConfigValue(ZohoOAuthConstants::HOST_ADDRESS).":". ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_PORT), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_USERNAME), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_PASSWORD), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_NAME));
$url = ZohoOAuth::getConfigValue(ZohoOAuthConstants::HOST_ADDRESS);
$port = ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_PORT);
if ($port != null && $port != "") {
$url .= ":" . $port;
}
$mysqli_con = new \mysqli($url , ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_USERNAME), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_PASSWORD), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_NAME));
if ($mysqli_con->connect_errno) {
Logger::severe("Failed to connect to MySQL: (" . $mysqli_con->connect_errno . ") " . $mysqli_con->connect_error);
echo "Failed to connect to MySQL: (" . $mysqli_con->connect_errno . ") " . $mysqli_con->connect_error;
}
return $mysqli_con;
}
}
}