Fix if statements

This commit is contained in:
brantje 2017-01-03 21:12:24 +01:00
parent 0de232ffab
commit f30f986d60
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
8 changed files with 21 additions and 33 deletions

View file

@ -59,7 +59,7 @@ class FileController extends ApiController {
return new JSONResponse($this->fileService->deleteFile($file_id, $this->userId));
}
public function updateFile($file_id, $file_data, $filename, $mimetype, $size){
public function updateFile($file_id, $file_data, $filename){
try{
$file = $this->fileService->getFile($file_id, $this->userId);
} catch (\Exception $doesNotExistException){

View file

@ -33,7 +33,7 @@ class TranslationController extends ApiController {
* @NoCSRFRequired
* @PublicPage
*/
public function getLanguageStrings($lang) {
public function getLanguageStrings() {
$translations = array(
// js/app/controllers/bookmarklet.js
'generating.sharing.keys' => $this->trans->t('Generating sharing keys ( %step / 2)'),

View file

@ -149,6 +149,6 @@ class VaultController extends ApiController {
* @NoCSRFRequired
*/
public function delete($vault_id) {
return;
return new JSONResponse($vault_id);
}
}

View file

@ -60,13 +60,11 @@ class SharingACLMapper extends Mapper {
public function getItemACL($user_id, $item_guid) {
$q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ? AND ";
$filter = [$item_guid];
if ($user_id === null){
$q .= 'user_id is null';
}
else {
$q .= 'user_id = ? ';
$filter[] = $user_id;
$q .= ($user_id === null) ? 'user_id is null' : 'user_id = ? ';
if ($user_id !== null){
$filter[] = $user_id;
}
return $this->findEntity($q, $filter);
}

View file

@ -125,9 +125,8 @@ class CredentialService {
$acl = $this->sharingACL->getItemACL($user_id, $credential->getGuid());
if ($acl->hasPermission(SharingACL::READ)) {
return $credential;
} else {
throw new DoesNotExistException("Did expect one result but found none when executing");
}
throw new DoesNotExistException("Did expect one result but found none when executing");
}
}

View file

@ -65,10 +65,7 @@ class CronService {
'', array(),
$link, $credential->getUserId(), Activity::TYPE_ITEM_EXPIRED);
$this->notificationService->credentialExpiredNotification($credential);
} else {
$this->logger->debug($credential->getLabel() .' is expired, already notified!', array('app' => 'passman'));
}
}
}
}

View file

@ -39,7 +39,8 @@ class SettingsService {
'vault_key_strength',
'check_version',
'https_check',
'disable_contextmenu'
'disable_contextmenu',
'settings_loaded'
);
public function __construct($UserId, IConfig $config, $AppName) {
@ -74,14 +75,11 @@ class SettingsService {
* @return mixed
*/
public function getAppSetting($key, $default_value = null) {
if (isset($this->settings[$key])) {
$value = $this->settings[$key];
if (in_array($key, $this->numeric_settings)) {
$value = intval($value);
}
} else {
$value = $this->config->getAppValue('passman', $key, $default_value);
$value = ($this->settings[$key]) ? $this->settings[$key] : $this->config->getAppValue('passman', $key, $default_value);
if (in_array($key, $this->numeric_settings)) {
$value = intval($value);
}
return $value;
}

View file

@ -19,19 +19,15 @@ class ShareMiddleware extends Middleware {
public function beforeController($controller, $methodName) {
if ($controller instanceof ShareController) {
$http_response_code = \OCP\AppFramework\Http::STATUS_FORBIDDEN;
$result = 'FORBIDDEN';
$http_response_code = Http::STATUS_OK;
$result = array();
$publicMethods = array('createPublicShare', 'getPublicCredentialData');
$user_pub_methods = array('updateSharedCredentialACL', 'getFile', 'getItemAcl');
$setting = (in_array($methodName, $publicMethods)) ? 'link_sharing_enabled' : 'user_sharing_enabled';
$sharing_enabled = ($this->settings->isEnabled($setting));
if (in_array($methodName, array('updateSharedCredentialACL', 'getFile', 'getItemAcl'))) {
if(in_array($methodName, $user_pub_methods)){
$sharing_enabled = ($this->settings->isEnabled('link_sharing_enabled') || $this->settings->isEnabled('user_sharing_enabled'));
} else {
$publicMethods = array('createPublicShare', 'getPublicCredentialData');
$setting = (in_array($methodName, $publicMethods)) ? 'link_sharing_enabled' : 'user_sharing_enabled';
$sharing_enabled = ($this->settings->isEnabled($setting));
if ($methodName === 'getVaultItems' || $methodName === 'getPendingRequests') {
$http_response_code = Http::STATUS_OK;
$result = array();
}
}