error reporting in apitoggleqvitter.php

This commit is contained in:
Hannes Mannerheim 2015-07-10 14:30:14 +02:00
parent b905b2fafb
commit 1746928089

View File

@ -1,6 +1,6 @@
<?php <?php
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · /* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
· · · ·
· · · ·
· Q V I T T E R · · Q V I T T E R ·
@ -15,7 +15,7 @@
· o> \\\\_\ · · o> \\\\_\ ·
· \\) \____) · · \\) \____) ·
· · · ·
· · · ·
· · · ·
· Qvitter is free software: you can redistribute it and / or modify it · · Qvitter is free software: you can redistribute it and / or modify it ·
· under the terms of the GNU Affero General Public License as published by · · under the terms of the GNU Affero General Public License as published by ·
@ -31,10 +31,10 @@
· along with Qvitter. If not, see <http://www.gnu.org/licenses/>. · · along with Qvitter. If not, see <http://www.gnu.org/licenses/>. ·
· · · ·
· Contact h@nnesmannerhe.im if you have any questions. · · Contact h@nnesmannerhe.im if you have any questions. ·
· · · ·
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */ · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) { exit(1); }
class ApiToggleQvitterAction extends ApiAuthAction class ApiToggleQvitterAction extends ApiAuthAction
@ -57,9 +57,6 @@ class ApiToggleQvitterAction extends ApiAuthAction
/** /**
* Handle the request * Handle the request
* *
* Try to save the user's colors in her design. Create a new design
* if the user doesn't already have one.
*
* @param array $args $_REQUEST data (unused) * @param array $args $_REQUEST data (unused)
* *
* @return void * @return void
@ -70,29 +67,35 @@ class ApiToggleQvitterAction extends ApiAuthAction
$user = common_current_user(); $user = common_current_user();
$profile = $user->getProfile(); $profile = $user->getProfile();
// what to toggle
if(QvitterPlugin::settings('enabledbydefault')) { if(QvitterPlugin::settings('enabledbydefault')) {
$state = Profile_prefs::getConfigData($profile, 'qvitter', 'disable_qvitter'); $toggle = 'disable_qvitter';
if($state == 1) { } else {
Profile_prefs::setData($profile, 'qvitter', 'disable_qvitter', 0); $toggle = 'enable_qvitter';
} }
else {
Profile_prefs::setData($profile, 'qvitter', 'disable_qvitter', 1); // new value
} $state = Profile_prefs::getConfigData($profile, 'qvitter', $toggle);
} if($state == 1) {
else { $new_state = 0;
$state = Profile_prefs::getConfigData($profile, 'qvitter', 'enable_qvitter'); } else {
if($state == 1) { $new_state = 1;
Profile_prefs::setData($profile, 'qvitter', 'enable_qvitter', 0); }
}
else { try {
Profile_prefs::setData($profile, 'qvitter', 'enable_qvitter', 1); $pref_saved = Profile_prefs::setData($profile, 'qvitter', $toggle, $new_state);
} $result['success'] = true;
} } catch (ServerException $e) {
$result['success'] = false;
$result['error'] = $e;
$result['success'] = true; }
if(!$pref_saved) {
$result['success'] = false;
$result['error'] = 'Probably couldn\'t get topic from pref table';
}
$this->initDocument('json'); $this->initDocument('json');
$this->showJsonObjects($result); $this->showJsonObjects($result);
$this->endDocument('json'); $this->endDocument('json');