|
|
@@ -78,11 +78,13 @@ class Invites extends Organizr
|
|
|
)
|
|
|
];
|
|
|
} else {
|
|
|
- $query = 'SELECT * FROM invites WHERE invitedby="'.$this->user['username'].'";';
|
|
|
$response = [
|
|
|
array(
|
|
|
'function' => 'fetchAll',
|
|
|
- 'query' => $query
|
|
|
+ 'query' => array (
|
|
|
+ 'SELECT * FROM invites WHERE invitedby = ?',
|
|
|
+ $this->user['username']
|
|
|
+ )
|
|
|
)
|
|
|
];
|
|
|
}
|
|
|
@@ -92,10 +94,6 @@ class Invites extends Organizr
|
|
|
|
|
|
public function _invitesPluginCreateCode($array)
|
|
|
{
|
|
|
- if (!$this->_invitesPluginUpgradeDB()) {
|
|
|
- $this->setAPIResponse('error', 'Invites Plugin - Error Upgrading Database', 409);
|
|
|
- return $false;
|
|
|
- }
|
|
|
$code = ($array['code']) ?? null;
|
|
|
$username = ($array['username']) ?? null;
|
|
|
$email = ($array['email']) ?? null;
|
|
|
@@ -179,18 +177,31 @@ class Invites extends Organizr
|
|
|
|
|
|
public function _invitesPluginDeleteCode($code)
|
|
|
{
|
|
|
- $response = [
|
|
|
- array(
|
|
|
- 'function' => 'fetch',
|
|
|
- 'query' => array(
|
|
|
- 'SELECT * FROM invites WHERE code = ? COLLATE NOCASE',
|
|
|
- $code
|
|
|
+ if ($this->qualifyRequest(1, false)) {
|
|
|
+ $response = [
|
|
|
+ array(
|
|
|
+ 'function' => 'fetch',
|
|
|
+ 'query' => array(
|
|
|
+ 'SELECT * FROM invites WHERE code = ? COLLATE NOCASE',
|
|
|
+ $code
|
|
|
+ )
|
|
|
)
|
|
|
- )
|
|
|
- ];
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ $response = [
|
|
|
+ array(
|
|
|
+ 'function' => 'fetch',
|
|
|
+ 'query' => array(
|
|
|
+ 'SELECT * FROM invites WHERE invitedby = ? AND code = ? COLLATE NOCASE',
|
|
|
+ $this->user['username'],
|
|
|
+ $code
|
|
|
+ )
|
|
|
+ )
|
|
|
+ ];
|
|
|
+ }
|
|
|
$info = $this->processQueries($response);
|
|
|
if (!$info) {
|
|
|
- $this->setAPIResponse('error', 'Code not found', 404);
|
|
|
+ $this->setAPIResponse('error', 'Code not found'.$response, 404);
|
|
|
return false;
|
|
|
}
|
|
|
$response = [
|
|
|
@@ -557,53 +568,4 @@ class Invites extends Organizr
|
|
|
return (!empty($plexUser) ? $plexUser : null);
|
|
|
}
|
|
|
|
|
|
- public function _invitesPluginUpgradeDB()
|
|
|
- {
|
|
|
- $DBVersion = "1.1";
|
|
|
- if ($this->config['INVITES-db-version'] < $DBVersion) {
|
|
|
- $response = [
|
|
|
- array(
|
|
|
- 'function' => 'fetchAll',
|
|
|
- 'query' => 'PRAGMA table_info("invites")'
|
|
|
- )
|
|
|
- ];
|
|
|
- $sqlquery = $this->processQueries($response);
|
|
|
- $key = array_search("invitedby", array_column($sqlquery, 'name'));
|
|
|
- if (!$key) {
|
|
|
- $sqlalterquery = [
|
|
|
- array(
|
|
|
- 'function' => 'fetchAll',
|
|
|
- 'query' => 'ALTER TABLE invites ADD invitedby text;'
|
|
|
- )
|
|
|
- ];
|
|
|
- $sqlalter = $this->processQueries($sqlalterquery);
|
|
|
- $sqlquery = $this->processQueries($response);
|
|
|
- $key = array_search("invitedby", array_column($sqlquery, 'name'));
|
|
|
- if ($key) {
|
|
|
- $dbVersion = array (
|
|
|
- "INVITES-db-version" => $DBVersion,
|
|
|
- );
|
|
|
- $this->updateConfigItems($dbVersion);
|
|
|
- $this->setAPIResponse('success', 'Database upgraded successfully.', 200);
|
|
|
- $this->writeLog('info', 'Invites Plugin - Database upgraded successfully.', 'SYSTEM');
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- $this->writeLog('error', 'Invites Plugin - Error Upgrading Database', 'SYSTEM');
|
|
|
- $this->setAPIResponse('error', 'Invites Plugin - Error Upgrading Database', 409);
|
|
|
- return false;
|
|
|
- }
|
|
|
- } else {
|
|
|
- $dbVersion = array (
|
|
|
- "INVITES-db-version" => $DBVersion,
|
|
|
- );
|
|
|
- $this->updateConfigItems($dbVersion);
|
|
|
- $this->setAPIResponse('success', 'Database upgraded successfully.', 200);
|
|
|
- return true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- $this->setAPIResponse('success', 'Database up to date.', 200);
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
}
|