From a37b49d506e6bae8553ced66ba2a1d80bbb3d7dd Mon Sep 17 00:00:00 2001
From: nuxsmin
Date: Wed, 24 Oct 2018 01:59:58 +0200
Subject: [PATCH] * [ADD] Added PDF files displaying * [FIX] Minor bugfixes *
[MOD] Code refactoring
Signed-off-by: nuxsmin
---
app/config/strings.js.inc | 3 +-
.../web/Controllers/AccountController.php | 5 +-
.../web/Controllers/AccountFileController.php | 41 +-
.../Controllers/UserPassResetController.php | 4 +-
.../views/account/files-list.inc | 17 +-
.../Notification/NotificationHandler.php | 2 +-
.../Notification/NotificationRepository.php | 98 +++-
lib/SP/Services/Install/Installer.php | 2 +-
.../Notification/NotificationService.php | 6 +-
lib/SP/Util/ErrorUtil.php | 58 ++-
lib/SP/Util/FileUtil.php | 7 +-
public/js/app-actions.js | 345 ++++++------
public/js/app-actions.min.js | 109 ++--
public/js/app-requests.js | 16 -
public/js/app-requests.min.js | 8 +-
public/js/app-util.js | 19 +-
public/vendor/js/jquery.fileDownload.js | 493 ++++++++++++++++++
public/vendor/js/jquery.fileDownload.min.js | 13 +-
18 files changed, 947 insertions(+), 299 deletions(-)
create mode 100644 public/vendor/js/jquery.fileDownload.js
diff --git a/app/config/strings.js.inc b/app/config/strings.js.inc
index 75b30168..85c370f5 100644
--- a/app/config/strings.js.inc
+++ b/app/config/strings.js.inc
@@ -93,5 +93,6 @@ return [
68 => __('Actualizado'),
69 => __('Error al comprobar actualizaciones'),
70 => __('Avisos de sysPass'),
- 71 => __('Vaciar los tracks?')
+ 71 => __('Vaciar los tracks?'),
+ 72 => __('Archivo descargado')
];
\ No newline at end of file
diff --git a/app/modules/web/Controllers/AccountController.php b/app/modules/web/Controllers/AccountController.php
index fa9f6917..d4426004 100644
--- a/app/modules/web/Controllers/AccountController.php
+++ b/app/modules/web/Controllers/AccountController.php
@@ -218,6 +218,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn
$this->view->assign('accountData', $accountData);
+ $clientAddress = $this->configData->isDemoEnabled() ? '***' : $this->request->getClientAddress(true);
+
$this->eventDispatcher->notifyEvent('show.account.link',
new Event($this, EventMessage::factory()
->addDescription(__u('Enlace visualizado'))
@@ -225,11 +227,12 @@ final class AccountController extends ControllerBase implements CrudControllerIn
->addDetail(__u('Cliente'), $accountData->getClientName())
->addDetail(__u('Agente'), $this->router->request()->headers()->get('User-Agent'))
->addDetail(__u('HTTPS'), $this->router->request()->isSecure() ? __u('ON') : __u('OFF'))
+ ->addDetail(__u('IP'), $clientAddress)
->addData('userId', $publicLinkData->getUserId())
->addData('notify', $publicLinkData->isNotify()))
);
} else {
- ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_PAGE_NO_PERMISSION, 'account-link');
+ ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_PAGE_NO_PERMISSION, true, 'account-link');
}
$this->view();
diff --git a/app/modules/web/Controllers/AccountFileController.php b/app/modules/web/Controllers/AccountFileController.php
index 56b9b96b..49586b4d 100644
--- a/app/modules/web/Controllers/AccountFileController.php
+++ b/app/modules/web/Controllers/AccountFileController.php
@@ -49,6 +49,8 @@ use SP\Util\Util;
*/
final class AccountFileController extends ControllerBase implements CrudControllerInterface
{
+ const EXTENSIONS_VIEW = ['TXT'];
+
use JsonTrait, ItemTrait;
/**
@@ -89,7 +91,10 @@ final class AccountFileController extends ControllerBase implements CrudControll
return $this->returnJsonResponseData(['html' => $this->render()]);
}
- if (mb_strtoupper($fileData->getExtension()) === 'TXT') {
+ $extension = mb_strtoupper($fileData->getExtension());
+
+ if (in_array($extension, self::EXTENSIONS_VIEW)) {
+ $this->view->assign('extension', $extension);
$this->view->assign('data', htmlentities($fileData->getContent()));
$this->eventDispatcher->notifyEvent('show.accountFile',
@@ -122,26 +127,38 @@ final class AccountFileController extends ControllerBase implements CrudControll
try {
$this->checkSecurityToken($this->previousSk, $this->request);
+ // Set the security toke to its previous value because we can't tell
+ // the browser which will be the new security token (not so good...)
+ $this->session->setSecurityKey($this->previousSk);
+
if (null === ($fileData = $this->accountFileService->getById($id))) {
throw new SPException(__u('El archivo no existe'), SPException::INFO);
}
- // Enviamos el archivo al navegador
- header('Set-Cookie: fileDownload=true; path=/');
- header('Cache-Control: max-age=60, must-revalidate');
- header('Content-length: ' . $fileData->getSize());
- header('Content-type: ' . $fileData->getType());
- header('Content-Disposition: attachment; filename="' . $fileData->getName() . '"');
- header('Content-Description: PHP Generated Data');
- header('Content-transfer-encoding: binary');
-
$this->eventDispatcher->notifyEvent('download.accountFile',
new Event($this, EventMessage::factory()
->addDescription(__u('Archivo descargado'))
->addDetail(__u('Archivo'), $fileData->getName()))
);
- return $fileData->getContent();
+ $response = $this->router->response();
+ $response->header('Cache-Control', 'max-age=60, must-revalidate');
+ $response->header('Content-length', $fileData->getSize());
+ $response->header('Content-type', $fileData->getType());
+ $response->header('Content-Description', ' sysPass file');
+ $response->header('Content-transfer-encoding', 'binary');
+
+ $extension = mb_strtoupper($fileData->getExtension());
+
+ if ($extension === 'PDF') {
+ $response->header('Content-Disposition', 'inline; filename="' . $fileData->getName() . '"');
+ } else {
+ $response->header('Set-Cookie', 'fileDownload=true; path=/');
+ $response->header('Content-Disposition', 'attachment; filename="' . $fileData->getName() . '"');
+ }
+
+ $response->body($fileData->getContent());
+ $response->send(true);
} catch (\Exception $e) {
processException($e);
}
@@ -413,7 +430,7 @@ final class AccountFileController extends ControllerBase implements CrudControll
} catch (\Exception $e) {
processException($e);
- ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
+ ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION, true, 'files-list');
}
$this->view();
diff --git a/app/modules/web/Controllers/UserPassResetController.php b/app/modules/web/Controllers/UserPassResetController.php
index 543cfd7a..12f30a01 100644
--- a/app/modules/web/Controllers/UserPassResetController.php
+++ b/app/modules/web/Controllers/UserPassResetController.php
@@ -67,7 +67,7 @@ final class UserPassResetController extends ControllerBase
->getCustomLayout('request', strtolower($this->controllerName));
if (!$this->configData->isMailEnabled()) {
- ErrorUtil::showErrorInView($this->view, self::ERR_UNAVAILABLE, 'request');
+ ErrorUtil::showErrorInView($this->view, self::ERR_UNAVAILABLE, true, 'request');
}
$this->view();
@@ -156,7 +156,7 @@ final class UserPassResetController extends ControllerBase
if ($hash && $this->configData->isMailEnabled()) {
$this->view->assign('hash', $hash);
} else {
- ErrorUtil::showErrorInView($this->view, self::ERR_UNAVAILABLE, 'reset');
+ ErrorUtil::showErrorInView($this->view, self::ERR_UNAVAILABLE, true, 'reset');
}
$this->view();
diff --git a/app/modules/web/themes/material-blue/views/account/files-list.inc b/app/modules/web/themes/material-blue/views/account/files-list.inc
index 8c4fcbfa..43293aa5 100644
--- a/app/modules/web/themes/material-blue/views/account/files-list.inc
+++ b/app/modules/web/themes/material-blue/views/account/files-list.inc
@@ -9,7 +9,9 @@
-
+ getExtension());
+ ?>
-
attachment
@@ -40,15 +42,18 @@
title=""
data-item-id="getId(); ?>"
data-action-route=""
+ data-item-type=""
data-onclick="file/download">
getIconDownload()->getIcon(); ?>
-
+
+
getIconView()->getIcon(); ?>
+
diff --git a/lib/SP/Providers/Notification/NotificationHandler.php b/lib/SP/Providers/Notification/NotificationHandler.php
index 54d6e496..c6699833 100644
--- a/lib/SP/Providers/Notification/NotificationHandler.php
+++ b/lib/SP/Providers/Notification/NotificationHandler.php
@@ -150,7 +150,7 @@ final class NotificationHandler extends Provider implements EventReceiver
$eventMessage = $event->getEventMessage();
$data = $eventMessage->getData();
- if ($data['notify'] === true) {
+ if ($data['notify'][0] === true) {
$notificationData = new NotificationData();
$notificationData->setType(__('Notificación'));
$notificationData->setComponent(__('Cuentas'));
diff --git a/lib/SP/Repositories/Notification/NotificationRepository.php b/lib/SP/Repositories/Notification/NotificationRepository.php
index ef837a82..279050db 100644
--- a/lib/SP/Repositories/Notification/NotificationRepository.php
+++ b/lib/SP/Repositories/Notification/NotificationRepository.php
@@ -28,6 +28,7 @@ use SP\Core\Exceptions\ConstraintException;
use SP\Core\Exceptions\QueryException;
use SP\DataModel\ItemSearchData;
use SP\DataModel\NotificationData;
+use SP\Mvc\Model\QueryCondition;
use SP\Repositories\Repository;
use SP\Repositories\RepositoryItemInterface;
use SP\Repositories\RepositoryItemTrait;
@@ -386,19 +387,67 @@ final class NotificationRepository extends Repository implements RepositoryItemI
$queryData->setFrom('Notification');
$queryData->setOrder('`date` DESC');
- $filterUser = '(userId = ? OR (userId = NULL AND onlyAdmin = 0) OR sticky = 1)';
+ $queryCondition = new QueryCondition();
+ $queryCondition->addFilter('userId = ?', [$userId]);
+ $queryCondition->addFilter('(userId IS NULL AND onlyAdmin = 0)');
+ $queryCondition->addFilter('sticky = 1');
if ($itemSearchData->getSeachString() !== '') {
- $queryData->setWhere('(type LIKE ? OR component LIKE ? OR description LIKE ?) AND ' . $filterUser);
+ $queryData->setWhere(
+ '(type LIKE ? OR component LIKE ? OR description LIKE ?) AND '
+ . $queryCondition->getFilters(QueryCondition::CONDITION_OR)
+ );
$search = '%' . $itemSearchData->getSeachString() . '%';
- $queryData->addParam($search);
- $queryData->addParam($search);
- $queryData->addParam($search);
- $queryData->addParam($userId);
+ $queryData->setParams(array_merge([$search, $search, $search], $queryCondition->getParams()));
} else {
- $queryData->setWhere($filterUser);
- $queryData->addParam($userId);
+ $queryData->setWhere($queryCondition->getFilters(QueryCondition::CONDITION_OR));
+ $queryData->setParams($queryCondition->getParams());
+ }
+
+ $queryData->setLimit(
+ '?,?',
+ [$itemSearchData->getLimitStart(), $itemSearchData->getLimitCount()]
+ );
+
+ return $this->db->doSelect($queryData, true);
+ }
+
+ /**
+ * Searches for items by a given filter
+ *
+ * @param ItemSearchData $itemSearchData
+ * @param int $userId
+ *
+ * @return QueryResult
+ * @throws ConstraintException
+ * @throws QueryException
+ */
+ public function searchForAdmin(ItemSearchData $itemSearchData, $userId)
+ {
+ $queryData = new QueryData();
+ $queryData->setMapClassName(NotificationData::class);
+ $queryData->setSelect('id, type, component, description, `date`, checked, userId, sticky, onlyAdmin');
+ $queryData->setFrom('Notification');
+ $queryData->setOrder('`date` DESC');
+
+ $queryCondition = new QueryCondition();
+ $queryCondition->addFilter('userId = ?', [$userId]);
+ $queryCondition->addFilter('onlyAdmin = 1');
+ $queryCondition->addFilter('sticky = 1');
+
+ if ($itemSearchData->getSeachString() !== '') {
+ $queryData->setWhere(
+ '(type LIKE ? OR component LIKE ? OR description LIKE ?) AND '
+ . $queryCondition->getFilters(QueryCondition::CONDITION_OR)
+ );
+
+ $search = '%' . $itemSearchData->getSeachString() . '%';
+
+ $queryData->setParams(array_merge([$search, $search, $search], $queryCondition->getParams()));
+ } else {
+ $queryData->setWhere($queryCondition->getFilters(QueryCondition::CONDITION_OR));
+ $queryData->setParams($queryCondition->getParams());
}
$queryData->setLimit(
@@ -534,4 +583,37 @@ final class NotificationRepository extends Repository implements RepositoryItemI
return $this->db->doSelect($queryData);
}
+
+ /**
+ * @param $id
+ *
+ * @return QueryResult
+ * @throws ConstraintException
+ * @throws QueryException
+ */
+ public function getAllActiveForAdmin($id)
+ {
+ $query = /** @lang SQL */
+ 'SELECT id,
+ type,
+ component,
+ description,
+ `date`,
+ userId,
+ checked,
+ sticky,
+ onlyAdmin
+ FROM Notification
+ WHERE (userId = ? OR sticky = 1 OR userId IS NULL)
+ AND checked = 0
+ ORDER BY `date` DESC ';
+
+ $queryData = new QueryData();
+ $queryData->setMapClassName(NotificationData::class);
+ $queryData->setQuery($query);
+ $queryData->addParam($id);
+ $queryData->setOnErrorMessage(__u('Error al obtener las notificaciones'));
+
+ return $this->db->doSelect($queryData);
+ }
}
\ No newline at end of file
diff --git a/lib/SP/Services/Install/Installer.php b/lib/SP/Services/Install/Installer.php
index c70b88d4..5b3ab16d 100644
--- a/lib/SP/Services/Install/Installer.php
+++ b/lib/SP/Services/Install/Installer.php
@@ -57,7 +57,7 @@ final class Installer extends Service
*/
const VERSION = [3, 0, 0];
const VERSION_TEXT = '3.0-beta';
- const BUILD = 18102201;
+ const BUILD = 18102401;
/**
* @var DatabaseSetupInterface
diff --git a/lib/SP/Services/Notification/NotificationService.php b/lib/SP/Services/Notification/NotificationService.php
index 6f917ad9..e822f8a3 100644
--- a/lib/SP/Services/Notification/NotificationService.php
+++ b/lib/SP/Services/Notification/NotificationService.php
@@ -247,6 +247,10 @@ final class NotificationService extends Service
*/
public function getAllActiveForUserId($id)
{
+ if ($this->context->getUserData()->getIsAdminApp()) {
+ return $this->notificationRepository->getAllActiveForAdmin($id)->getDataAsArray();
+ }
+
return $this->notificationRepository->getAllActiveForUserId($id)->getDataAsArray();
}
@@ -264,7 +268,7 @@ final class NotificationService extends Service
$userData = $this->context->getUserData();
if ($userData->getIsAdminApp()) {
- return $this->notificationRepository->search($itemSearchData);
+ return $this->notificationRepository->searchForAdmin($itemSearchData, $userData->getId());
}
return $this->notificationRepository->searchForUserId($itemSearchData, $userData->getId());
diff --git a/lib/SP/Util/ErrorUtil.php b/lib/SP/Util/ErrorUtil.php
index 0ee0cd7f..bead0d44 100644
--- a/lib/SP/Util/ErrorUtil.php
+++ b/lib/SP/Util/ErrorUtil.php
@@ -61,37 +61,18 @@ final class ErrorUtil
$replace = null,
$render = true)
{
- if ($replace === null) {
- $view->resetTemplates();
-
- if ($view->hashContentTemplates()) {
- $view->resetContentTemplates();
- $view->addContentTemplate('error', Template::PARTIALS_DIR);
- } else {
- $view->addTemplate('error', Template::PARTIALS_DIR);
- }
- } else {
- if ($view->hashContentTemplates()) {
- $view->removeContentTemplate($replace);
- $view->addContentTemplate('error', Template::PARTIALS_DIR);
- } else {
- $view->removeTemplate($replace);
- $view->addTemplate('error', Template::PARTIALS_DIR);
- }
- }
-
switch (get_class($e)) {
case UpdatedMasterPassException::class:
- self::showErrorInView($view, self::ERR_UPDATE_MPASS, $render);
+ self::showErrorInView($view, self::ERR_UPDATE_MPASS, $render, $replace);
break;
case UnauthorizedPageException::class:
- self::showErrorInView($view, self::ERR_PAGE_NO_PERMISSION, $render);
+ self::showErrorInView($view, self::ERR_PAGE_NO_PERMISSION, $render, $replace);
break;
case AccountPermissionException::class:
- self::showErrorInView($view, self::ERR_ACCOUNT_NO_PERMISSION, $render);
+ self::showErrorInView($view, self::ERR_ACCOUNT_NO_PERMISSION, $render, $replace);
break;
default;
- self::showErrorInView($view, self::ERR_EXCEPTION, $render);
+ self::showErrorInView($view, self::ERR_EXCEPTION, $render, $replace);
}
}
@@ -101,9 +82,12 @@ final class ErrorUtil
* @param \SP\Mvc\View\Template $view
* @param int $type int con el tipo de error
* @param bool $render
+ * @param null $replace
*/
- public static function showErrorInView(Template $view, $type, $render = true)
+ public static function showErrorInView(Template $view, $type, $render = true, $replace = null)
{
+ self::addErrorTemplate($view, $replace);
+
$error = self::getErrorTypes($type);
$view->append('errors',
@@ -124,6 +108,32 @@ final class ErrorUtil
}
}
+ /**
+ * @param Template $view
+ * @param string|null $replace
+ */
+ private static function addErrorTemplate(Template $view, string $replace = null)
+ {
+ if ($replace === null) {
+ $view->resetTemplates();
+
+ if ($view->hashContentTemplates()) {
+ $view->resetContentTemplates();
+ $view->addContentTemplate('error', Template::PARTIALS_DIR);
+ } else {
+ $view->addTemplate('error', Template::PARTIALS_DIR);
+ }
+ } else {
+ if ($view->hashContentTemplates()) {
+ $view->removeContentTemplate($replace);
+ $view->addContentTemplate('error', Template::PARTIALS_DIR);
+ } else {
+ $view->removeTemplate($replace);
+ $view->addTemplate('error', Template::PARTIALS_DIR);
+ }
+ }
+ }
+
/**
* Return error message by type
*
diff --git a/lib/SP/Util/FileUtil.php b/lib/SP/Util/FileUtil.php
index 77e4922b..7e767d27 100644
--- a/lib/SP/Util/FileUtil.php
+++ b/lib/SP/Util/FileUtil.php
@@ -37,10 +37,7 @@ use SP\DataModel\FileData;
*/
final class FileUtil
{
- /**
- * @var array
- */
- public static $imageExtensions = ['JPG', 'PNG', 'GIF'];
+ const IMAGE_EXTENSIONS = ['JPG', 'PNG', 'GIF'];
/**
* Removes a directory in a recursive way
@@ -74,6 +71,6 @@ final class FileUtil
*/
public static function isImage(FileData $fileData)
{
- return in_array(mb_strtoupper($fileData->getExtension()), self::$imageExtensions, true);
+ return in_array(mb_strtoupper($fileData->getExtension()), self::IMAGE_EXTENSIONS, true);
}
}
\ No newline at end of file
diff --git a/public/js/app-actions.js b/public/js/app-actions.js
index c52a5ef3..6716ffa3 100644
--- a/public/js/app-actions.js
+++ b/public/js/app-actions.js
@@ -45,11 +45,10 @@ sysPass.Actions = function (log) {
data.sk = sysPassApp.sk.get();
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
opts.type = "html";
opts.addHistory = true;
- opts.data = data;
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, data);
return sysPassApp.requests.getActionCall(opts, function (response) {
const $content = $("#content");
@@ -168,17 +167,17 @@ sysPass.Actions = function (log) {
view: function ($obj) {
log.info("account:show");
- getContent(sysPassApp.requests.getRouteForQuery($obj.data("action-route"), $obj.data("item-id")), "account");
+ getContent({r: [$obj.data("action-route"), $obj.data("item-id")]}, "account");
},
viewHistory: function ($obj) {
log.info("account:showHistory");
- getContent(sysPassApp.requests.getRouteForQuery($obj.data("action-route"), $obj.val()), "account");
+ getContent({r: [$obj.data("action-route"), $obj.val()]}, "account");
},
edit: function ($obj) {
log.info("account:edit");
- getContent(sysPassApp.requests.getRouteForQuery($obj.data("action-route"), $obj.data("item-id")), "account");
+ getContent({r: [$obj.data("action-route"), $obj.data("item-id")]}, "account");
},
delete: function ($obj) {
log.info("account:delete");
@@ -224,13 +223,13 @@ sysPass.Actions = function (log) {
const id = parentId === 0 ? $obj.data("item-id") : parentId;
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("action-route") + "/" + id + "/" + parentId,
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), id, parentId],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
if (json.status !== 0) {
@@ -270,14 +269,14 @@ sysPass.Actions = function (log) {
const id = parentId === 0 ? $obj.data("item-id") : parentId;
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
opts.async = false;
- opts.data = {
- r: $obj.data("action-route") + "/" + id,
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), id],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
return sysPassApp.requests.getActionCall(opts);
},
@@ -289,7 +288,7 @@ sysPass.Actions = function (log) {
copy: function ($obj) {
log.info("account:copy");
- getContent(sysPassApp.requests.getRouteForQuery($obj.data("action-route"), $obj.data("item-id")), "account");
+ getContent({r: [$obj.data("action-route"), $obj.data("item-id")]}, "account");
},
saveFavorite: function ($obj, callback) {
log.info("account:saveFavorite");
@@ -332,7 +331,7 @@ sysPass.Actions = function (log) {
) {
sysPassApp.sk.set(json.csrf);
- getContent({r: json.data.nextAction['nextAction']}, "account");
+ getContent({r: json.data.nextAction}, "account");
}
});
},
@@ -360,9 +359,7 @@ sysPass.Actions = function (log) {
const parentId = $obj.data("parent-id");
const itemId = parentId === undefined ? $obj.data("item-id") : parentId;
- const route = sysPassApp.requests.getRouteForQuery($obj.data("action-route"), itemId);
-
- getContent(route, "account");
+ getContent({r: [$obj.data("action-route"), itemId]}, "account");
},
saveEditRestore: function ($obj) {
log.info("account:restore");
@@ -380,9 +377,7 @@ sysPass.Actions = function (log) {
if (json.data.itemId !== undefined
&& json.data.nextAction !== undefined
) {
- const route = sysPassApp.requests.getRouteForQuery(json.data.nextAction, json.data.itemId);
-
- getContent(route, "account");
+ getContent({r: [json.data.nextAction, json.data.itemId]}, "account");
}
});
},
@@ -392,12 +387,12 @@ sysPass.Actions = function (log) {
const opts = sysPassApp.requests.getRequestOpts();
opts.method = "get";
opts.type = "html";
- opts.url = ajaxUrl.entrypoint;
- opts.data = {
- r: $obj.data("action-route") + "/" + $obj.data("item-id"),
- del: $obj.data("delete"),
- sk: sysPassApp.sk.get()
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ del: $obj.data("delete"),
+ sk: sysPassApp.sk.get()
+ });
sysPassApp.requests.getActionCall(opts, function (response) {
$obj.html(response);
@@ -417,8 +412,8 @@ sysPass.Actions = function (log) {
}
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint + "?r=" + $frmSearch.data("action-route");
opts.method = "get";
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: $obj.data("action-route")});
opts.data = $frmSearch.serialize();
sysPassApp.requests.getActionCall(opts, function (json) {
@@ -447,9 +442,7 @@ sysPass.Actions = function (log) {
if (json.data.itemId !== undefined
&& json.data.nextAction !== undefined
) {
- const route = sysPassApp.requests.getRouteForQuery(json.data.nextAction, json.data.itemId);
-
- getContent(route, "account");
+ getContent({r: [json.data.nextAction, json.data.itemId]}, "account");
}
});
}
@@ -468,12 +461,12 @@ sysPass.Actions = function (log) {
$dst.clearOptions();
$dst.load(function (callback) {
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("action-route") + "/" + $obj.data("item-id"),
- sk: $obj.data("sk")
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ sk: sysPassApp.sk.get()
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
callback(json.data);
@@ -494,12 +487,12 @@ sysPass.Actions = function (log) {
$dst.clearOptions();
$dst.load(function (callback) {
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("item-route"),
- sk: sysPassApp.sk.get()
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: $obj.data("action-route"),
+ sk: sysPassApp.sk.get()
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
callback(json);
@@ -529,12 +522,12 @@ sysPass.Actions = function (log) {
const opts = sysPassApp.requests.getRequestOpts();
opts.type = "html";
opts.method = "get";
- opts.url = ajaxUrl.entrypoint;
- opts.data = {
- r: $obj.data("action-route") + "/" + $obj.data("item-id"),
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
sysPassApp.requests.getActionCall(opts, function (response) {
if (response.length === 0) {
@@ -576,7 +569,7 @@ sysPass.Actions = function (log) {
log.info("main:login");
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("route");
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: $obj.data("route")});
opts.method = "get";
opts.data = $obj.serialize();
@@ -664,7 +657,7 @@ sysPass.Actions = function (log) {
}
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data('action-route');
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: $obj.data('action-route')});
opts.method = "get";
opts.useFullLoading = !!taskId;
opts.data = $obj.serialize();
@@ -692,11 +685,10 @@ sysPass.Actions = function (log) {
log.info("main:getUpdates");
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint + "?r=status/checkRelease";
opts.method = "get";
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: "status/checkRelease", isAjax: 1});
opts.timeout = 10000;
opts.useLoading = false;
- opts.data = {isAjax: 1};
const $updates = $("#updates");
@@ -730,8 +722,12 @@ sysPass.Actions = function (log) {
log.info("main:getNotices");
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint + "?r=status/checkNotices";
opts.method = "get";
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: "status/checkNotices",
+ isAjax: 1
+ });
opts.timeout = 10000;
opts.useLoading = false;
opts.data = {isAjax: 1};
@@ -879,11 +875,13 @@ sysPass.Actions = function (log) {
log.info("config:import");
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route");
- opts.data = {
- sk: $obj.data("sk"),
- isAjax: 1
- };
+ opts.method = "get";
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: $obj.data("action-route"),
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
sysPassApp.msg.out(json);
@@ -911,12 +909,12 @@ sysPass.Actions = function (log) {
log.info("file:view");
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("action-route") + "/" + $obj.data("item-id"),
- sk: sysPassApp.sk.get()
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ sk: sysPassApp.sk.get()
+ });
sysPassApp.requests.getActionCall(opts, function (response) {
if (response.status !== 0) {
@@ -929,12 +927,26 @@ sysPass.Actions = function (log) {
download: function ($obj) {
log.info("file:download");
- const data = {
- r: $obj.data("action-route") + "/" + $obj.data("item-id"),
- sk: sysPassApp.sk.get()
- };
+ const fileType = $obj.data("item-type");
+ const url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ sk: sysPassApp.sk.get()
+ });
- $.fileDownload(ajaxUrl.entrypoint, {"httpMethod": "GET", "data": data});
+ if (fileType === 'PDF') {
+ window.open(url, '_blank');
+ return;
+ }
+
+ $.fileDownload(url,
+ {
+ httpMethod: "GET",
+ successCallback: function (url) {
+ sysPassApp.msg.ok(sysPassApp.config.LANG[72]);
+ }
+ }
+ );
},
delete: function ($obj) {
log.info("file:delete");
@@ -955,12 +967,12 @@ sysPass.Actions = function (log) {
title: sysPassApp.config.LANG[43],
onClick: function (e) {
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("action-route") + "/" + $obj.data("item-id"),
- sk: sysPassApp.sk.get()
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ sk: sysPassApp.sk.get(),
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
sysPassApp.msg.out(json);
@@ -986,19 +998,31 @@ sysPass.Actions = function (log) {
const accountId = $obj.data("account-id");
const opts = sysPassApp.requests.getRequestOpts();
+ opts.method = "get";
if (accountId) {
- opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route") + "/" + accountId + "/" + notify;
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), accountId, notify],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
} else {
- opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route");
- opts.data = $obj.serialize() + "&sk=" + sysPassApp.sk.get();
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: $obj.data("action-route"),
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
+
+ opts.data = $obj.serialize();
}
sysPassApp.requests.getActionCall(opts, function (json) {
sysPassApp.msg.out(json);
if (json.status === 0) {
- getContent({r: $obj.data("action-next") + "/" + accountId});
+ getContent({r: [$obj.data("action-next"), accountId]});
}
});
};
@@ -1045,16 +1069,20 @@ sysPass.Actions = function (log) {
onClick: function (e) {
e.preventDefault();
- const itemId = $obj.data("item-id");
const opts = sysPassApp.requests.getRequestOpts();
-
- opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route") + "/" + itemId;
+ opts.method = "get";
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
sysPassApp.msg.out(json);
if (json.status === 0) {
- getContent({r: $obj.data("action-next") + "/" + $obj.data("account-id")});
+ getContent({r: [$obj.data("action-next"), $obj.data("account-id")]});
}
});
}
@@ -1066,16 +1094,14 @@ sysPass.Actions = function (log) {
tabs.state.update($obj);
- const itemId = $obj.data("item-id");
-
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("action-route") + "/" + itemId,
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
sysPassApp.msg.out(json);
@@ -1084,9 +1110,7 @@ sysPass.Actions = function (log) {
const actionNext = $obj.data("action-next");
if (actionNext) {
- getContent({
- r: actionNext + "/" + $obj.data("account-id")
- });
+ getContent({r: [actionNext, $obj.data("account-id")]});
} else {
getContent({
r: tabs.state.tab.route,
@@ -1182,7 +1206,6 @@ sysPass.Actions = function (log) {
tabs.state.update($obj);
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
const items = grid.getSelection($obj);
@@ -1191,12 +1214,13 @@ sysPass.Actions = function (log) {
return;
}
- opts.data = {
- r: $obj.data("action-route") + (items.length === 0 ? "/" + $obj.data("item-id") : ''),
- items: items,
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), (items.length === 0 ? $obj.data("item-id") : null)],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
+ opts.data = {items: items};
sysPassApp.requests.getActionCall(opts, function (json) {
if (json.status !== 0) {
@@ -1226,14 +1250,14 @@ sysPass.Actions = function (log) {
grid.delete($obj, function (items) {
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("action-route") + (items.length === 0 ? "/" + $obj.data("item-id") : ''),
- items: items,
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), (items.length === 0 ? $obj.data("item-id") : null)],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
+ opts.data = {items: items};
sysPassApp.requests.getActionCall(opts, function (json) {
sysPassApp.msg.out(json);
@@ -1305,14 +1329,15 @@ sysPass.Actions = function (log) {
log.info("wiki:show");
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- pageName: $obj.data("pagename"),
- actionId: $obj.data("action-id"),
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: $obj.data("action-route"),
+ pageName: $obj.data("pagename"),
+ actionId: $obj.data("action-id"),
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
if (json.status !== 0) {
@@ -1333,16 +1358,14 @@ sysPass.Actions = function (log) {
tabs.state.update($obj);
- const itemId = $obj.data("item-id");
-
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("action-route") + "/" + itemId,
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
sysPassApp.msg.out(json);
@@ -1422,13 +1445,13 @@ sysPass.Actions = function (log) {
log.info("notification:check");
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("action-route") + "/" + $obj.data("item-id"),
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
if (json.status === 0) {
@@ -1472,19 +1495,21 @@ sysPass.Actions = function (log) {
grid.delete($obj, function (items) {
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("action-route") + (items.length === 0 ? "/" + $obj.data("item-id") : ''),
- items: items,
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), (items.length === 0 ? $obj.data("item-id") : null)],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
+ opts.data = {items: items};
sysPassApp.requests.getActionCall(opts, function (json) {
sysPassApp.msg.out(json);
- getContent({r: $obj.data("action-next")});
+ getContent({r: $obj.data("action-next")}).then(function () {
+ notification.getActive();
+ });
});
});
},
@@ -1492,13 +1517,13 @@ sysPass.Actions = function (log) {
log.info("notification:getActive");
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: "items/notifications",
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: "items/notifications",
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
const $badge = $(".notifications-badge");
@@ -1544,8 +1569,8 @@ sysPass.Actions = function (log) {
const $target = $($obj.data("target"));
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route");
opts.method = "get";
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: $obj.data("action-route"),});
opts.data = $obj.serialize();
sysPassApp.requests.getActionCall(opts, function (json) {
@@ -1691,13 +1716,13 @@ sysPass.Actions = function (log) {
const itemId = $obj.data("item-id");
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("action-route") + "/" + itemId,
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
sysPassApp.msg.out(json);
@@ -1706,9 +1731,7 @@ sysPass.Actions = function (log) {
const actionNext = $obj.data("action-next");
if (actionNext) {
- getContent({
- r: actionNext + "/" + itemId
- });
+ getContent({r: [actionNext, itemId]});
} else {
getContent({
r: tabs.state.tab.route,
@@ -1727,7 +1750,7 @@ sysPass.Actions = function (log) {
const opts = sysPassApp.requests.getRequestOpts();
opts.method = "get";
- opts.url = ajaxUrl.entrypoint + "?r=task/runTask/" + taskId;
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: ["task/runTask", taskId],});
return sysPassApp.requests.getActionEvent(opts, function (result) {
let text = result.task + " - " + result.message + " - " + result.time + " - " + result.progress + "%";
@@ -1742,13 +1765,13 @@ sysPass.Actions = function (log) {
log.info("track:unlock");
const opts = sysPassApp.requests.getRequestOpts();
- opts.url = ajaxUrl.entrypoint;
opts.method = "get";
- opts.data = {
- r: $obj.data("action-route") + "/" + $obj.data("item-id"),
- sk: sysPassApp.sk.get(),
- isAjax: 1
- };
+ opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
+ {
+ r: [$obj.data("action-route"), $obj.data("item-id")],
+ sk: sysPassApp.sk.get(),
+ isAjax: 1
+ });
sysPassApp.requests.getActionCall(opts, function (json) {
sysPassApp.msg.out(json);
diff --git a/public/js/app-actions.min.js b/public/js/app-actions.min.js
index 8a94c68d..10d23524 100644
--- a/public/js/app-actions.min.js
+++ b/public/js/app-actions.min.js
@@ -1,56 +1,57 @@
-var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(d,l,e){d instanceof String&&(d=String(d));for(var f=d.length,h=0;h
"),k=c.find("img");if(0===k.length)return h(b);k.hide();$.magnificPopup.open({items:{src:c,
-type:"inline"},callbacks:{open:function(){var a=this;k.on("click",function(){a.close()});setTimeout(function(){var a=sysPassApp.util.resizeImage(k);c.css({backgroundColor:"#fff",width:a.width,height:"auto"});k.show("slow")},500)}}})},q=function(){$.magnificPopup.close()},n={view:function(a){d.info("account:show");f(sysPassApp.requests.getRouteForQuery(a.data("action-route"),a.data("item-id")),"account")},viewHistory:function(a){d.info("account:showHistory");f(sysPassApp.requests.getRouteForQuery(a.data("action-route"),
-a.val()),"account")},edit:function(a){d.info("account:edit");f(sysPassApp.requests.getRouteForQuery(a.data("action-route"),a.data("item-id")),"account")},delete:function(a){d.info("account:delete");var b=''+sysPassApp.config.LANG[3]+"
";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(c){c=
-sysPassApp.requests.getRequestOpts();c.url=e.entrypoint;c.data={r:"account/saveDelete/"+a.data("item-id"),sk:sysPassApp.sk.get()};sysPassApp.requests.getActionCall(c,function(c){sysPassApp.msg.out(c);sysPassApp.sk.set(c.csrf);n.search(a)})}}})},viewPass:function(a){d.info("account:viewPass");var b=a.data("parent-id")||0,c=0===b?a.data("item-id"):b,k=sysPassApp.requests.getRequestOpts();k.url=e.entrypoint;k.method="get";k.data={r:a.data("action-route")+"/"+c+"/"+b,sk:sysPassApp.sk.get(),isAjax:1};
-sysPassApp.requests.getActionCall(k,function(a){0!==a.status?sysPassApp.msg.out(a):(a=$(a.data.html),h(a),l=setTimeout(function(){q()},3E4),a.on("mouseleave",function(){clearTimeout(l);l=setTimeout(function(){q()},3E4)}).on("mouseenter",function(){0!==l&&clearTimeout(l)}))})},viewPassHistory:function(a){d.info("account:viewPassHistory");n.viewPass(a)},copyPass:function(a){d.info("account:copyPass");var b=a.data("parent-id");b=0===b?a.data("item-id"):b;var c=sysPassApp.requests.getRequestOpts();c.url=
-e.entrypoint;c.method="get";c.async=!1;c.data={r:a.data("action-route")+"/"+b,sk:sysPassApp.sk.get(),isAjax:1};return sysPassApp.requests.getActionCall(c)},copyPassHistory:function(a){d.info("account:copyPassHistory");n.copyPassHistory(a)},copy:function(a){d.info("account:copy");f(sysPassApp.requests.getRouteForQuery(a.data("action-route"),a.data("item-id")),"account")},saveFavorite:function(a,b){d.info("account:saveFavorite");var c="on"===a.data("status"),k=c?a.data("action-route-off"):a.data("action-route-on"),
-r=sysPassApp.requests.getRequestOpts();r.url=e.entrypoint;r.data={r:k+"/"+a.data("item-id"),sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(r,function(k){sysPassApp.msg.out(k);0===k.status&&(a.data("status",c?"off":"on"),"function"===typeof b&&b())})},request:function(a){d.info("account:request");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("action-route")+"/"+a.data("item-id");b.data=a.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(b,
-function(a){sysPassApp.msg.out(a);0===a.status&&void 0!==a.data.nextAction&&(sysPassApp.sk.set(a.csrf),f({r:a.data.nextAction.nextAction},"account"))})},menu:function(a){a.hide();a.parent().children(".actions-optional").show(250)},sort:function(a){d.info("account:sort");var b=$("#frmSearch");b.find('input[name="skey"]').val(a.data("key"));b.find('input[name="sorder"]').val(a.data("dir"));b.find('input[name="start"]').val(a.data("start"));n.search()},editPass:function(a){d.info("account:editpass");
-var b=a.data("parent-id");b=void 0===b?a.data("item-id"):b;a=sysPassApp.requests.getRouteForQuery(a.data("action-route"),b);f(a,"account")},saveEditRestore:function(a){d.info("account:restore");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint;b.data={r:a.data("action-route")+"/"+a.data("history-id")+"/"+a.data("item-id"),sk:sysPassApp.sk.get()};sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);void 0!==a.data.itemId&&void 0!==a.data.nextAction&&(a=sysPassApp.requests.getRouteForQuery(a.data.nextAction,
-a.data.itemId),f(a,"account"))})},listFiles:function(a){d.info("account:getfiles");var b=sysPassApp.requests.getRequestOpts();b.method="get";b.type="html";b.url=e.entrypoint;b.data={r:a.data("action-route")+"/"+a.data("item-id"),del:a.data("delete"),sk:sysPassApp.sk.get()};sysPassApp.requests.getActionCall(b,function(c){a.html(c)})},search:function(a){d.info("account:search");var b=$("#frmSearch");b.find("input[name='sk']").val(sysPassApp.sk.get());b.find("input[name='skey']").val();b.find("input[name='sorder']").val();
-void 0!==a&&b.find("input[name='start']").val(0);a=sysPassApp.requests.getRequestOpts();a.url=e.entrypoint+"?r="+b.data("action-route");a.method="get";a.data=b.serialize();sysPassApp.requests.getActionCall(a,function(a){10===a.status&&sysPassApp.msg.out(a);$("#res-content").empty().html(a.data.html)})},save:function(a){d.info("account:save");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("action-route")+"/"+a.data("item-id");b.data=a.serialize();$("select.select-box-tags[data-hash][data-updated=true]").each(function(a,
-k){b.data+="&"+k.getAttribute("id")+"_update=1"});sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);void 0!==a.data.itemId&&void 0!==a.data.nextAction&&(a=sysPassApp.requests.getRouteForQuery(a.data.nextAction,a.data.itemId),f(a,"account"))})}},w={logout:function(){sysPassApp.util.redirect("index.php?r=login/logout")},login:function(a){d.info("main:login");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("route");b.method="get";b.data=a.serialize();sysPassApp.requests.getActionCall(b,
-function(b){var c=$(".extra-hidden");switch(b.status){case 0:sysPassApp.util.redirect(b.data.url);break;case 2:sysPassApp.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:visible:first").focus();0";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){var c;(b=a.find("input[name='taskId']").val())&&(c=v(b));var d=sysPassApp.requests.getRequestOpts();d.url=e.entrypoint+"?r="+a.data("action-route");d.method="get";d.useFullLoading=!!b;d.data=a.serialize();
-sysPassApp.requests.getActionCall(d,function(b){sysPassApp.msg.out(b);0!==b.status?a.find(":input[name=key]").val(""):(void 0!==c&&c.close(),setTimeout(function(){sysPassApp.util.redirect("index.php")},5E3))})}}})},getUpdates:function(){d.info("main:getUpdates");var a=sysPassApp.requests.getRequestOpts();a.url=e.entrypoint+"?r=status/checkRelease";a.method="get";a.timeout=1E4;a.useLoading=!1;a.data={isAjax:1};var b=$("#updates");sysPassApp.requests.getActionCall(a,function(a){0===a.status?0'+a.data.title+'\n cloud_download
\n \n '+a.data.description+""):b.html('check_circle
\n '+
+var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(c,k,e){c instanceof String&&(c=String(c));for(var f=c.length,h=0;h
"+b.responseText+"
",e.error(d),"html"===a.type&&$("#content").html(c.msg.html.error(d)),
+sysPass.Requests=function(c){var e=c.log,b=[],g={type:"json",url:"",method:"post",callback:"",async:!0,data:"",cache:!1,processData:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",timeout:0,addHistory:!1,hash:"",useLoading:!0,useFullLoading:!1};Object.seal(g);var k={get:function(){return b},add:function(a){var h=""===a.hash?c.util.hash.md5(JSON.stringify(a)):a.hash;if(0"+n+""+b.responseText+"
",e.error(d),"html"===a.type&&$("#content").html(c.msg.html.error(d)),
c.msg.error(d)):m()},complete:function(b){!0===a.useLoading&&c.theme.loading.hide();void 0!==c.theme&&c.theme.ajax.complete()}})},getActionEvent:function(a,b,c){var f=l(a.url);f+="?"+$.param(a.data);var d=new EventSource(f);d.addEventListener("message",function(a){a=JSON.parse(a.data);e.debug(a);1===a.end?(e.info("getActionEvent:Ending"),d.close(),"function"===typeof c&&c(a)):"function"===typeof b&&b(a)});d.addEventListener("error",function(a){e.error("getActionEvent:Error occured");d.close()});return d},
-getRouteForQuery:function(a,b){return"object"===typeof b?{r:a+"/"+b.join("/")}:{r:a+"/"+b}},history:k}};
+history:k}};
diff --git a/public/js/app-util.js b/public/js/app-util.js
index 4772612c..c6b23ef9 100644
--- a/public/js/app-util.js
+++ b/public/js/app-util.js
@@ -480,7 +480,7 @@ sysPass.Util = function (log) {
*/
const notifications = {
state: {
- lastHash : ''
+ lastHash: ''
},
send: function (title, message, id) {
log.info("sendNotification");
@@ -523,6 +523,22 @@ sysPass.Util = function (log) {
}
};
+ /**
+ * Returns a serialized URL for a GET request
+ * @param base
+ * @param parts
+ * @returns {string}
+ */
+ const getUrl = function (base, parts) {
+ return base + "?" + Object.keys(parts).map(function (key) {
+ if (Array.isArray(parts[key])) {
+ return key + "=" + parts[key].join("/");
+ }
+
+ return key + "=" + parts[key];
+ }).join("&");
+ };
+
return {
decodeEntities: decodeEntities,
resizeImage: resizeImage,
@@ -531,6 +547,7 @@ sysPass.Util = function (log) {
setContentSize: setContentSize,
redirect: redirect,
uniqueId: uniqueId,
+ getUrl: getUrl,
sendNotification: notifications.send,
password: password,
hash: hash
diff --git a/public/vendor/js/jquery.fileDownload.js b/public/vendor/js/jquery.fileDownload.js
new file mode 100644
index 00000000..353ac645
--- /dev/null
+++ b/public/vendor/js/jquery.fileDownload.js
@@ -0,0 +1,493 @@
+/*
+* jQuery File Download Plugin v1.4.5
+*
+* http://www.johnculviner.com
+*
+* Copyright (c) 2013 - John Culviner
+*
+* Licensed under the MIT license:
+* http://www.opensource.org/licenses/mit-license.php
+*
+* !!!!NOTE!!!!
+* You must also write a cookie in conjunction with using this plugin as mentioned in the orignal post:
+* http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads/
+* !!!!NOTE!!!!
+*/
+
+(function($, window){
+ // i'll just put them here to get evaluated on script load
+ var htmlSpecialCharsRegEx = /[<>&\r\n"']/gm;
+ var htmlSpecialCharsPlaceHolders = {
+ '<': 'lt;',
+ '>': 'gt;',
+ '&': 'amp;',
+ '\r': "#13;",
+ '\n': "#10;",
+ '"': 'quot;',
+ "'": '#39;' /*single quotes just to be safe, IE8 doesn't support ', so use ' instead */
+ };
+
+$.extend({
+ //
+ //$.fileDownload('/path/to/url/', options)
+ // see directly below for possible 'options'
+ fileDownload: function (fileUrl, options) {
+
+ //provide some reasonable defaults to any unspecified options below
+ var settings = $.extend({
+
+ //
+ //Requires jQuery UI: provide a message to display to the user when the file download is being prepared before the browser's dialog appears
+ //
+ preparingMessageHtml: null,
+
+ //
+ //Requires jQuery UI: provide a message to display to the user when a file download fails
+ //
+ failMessageHtml: null,
+
+ //
+ //the stock android browser straight up doesn't support file downloads initiated by a non GET: http://code.google.com/p/android/issues/detail?id=1780
+ //specify a message here to display if a user tries with an android browser
+ //if jQuery UI is installed this will be a dialog, otherwise it will be an alert
+ //Set to null to disable the message and attempt to download anyway
+ //
+ androidPostUnsupportedMessageHtml: "Unfortunately your Android browser doesn't support this type of file download. Please try again with a different browser.",
+
+ //
+ //Requires jQuery UI: options to pass into jQuery UI Dialog
+ //
+ dialogOptions: { modal: true },
+
+ //
+ //a function to call while the dowload is being prepared before the browser's dialog appears
+ //Args:
+ // url - the original url attempted
+ //
+ prepareCallback: function (url) { },
+
+ //
+ //a function to call after a file download successfully completed
+ //Args:
+ // url - the original url attempted
+ //
+ successCallback: function (url) { },
+
+ //
+ //a function to call after a file download request was canceled
+ //Args:
+ // url - the original url attempted
+ //
+ abortCallback: function (url) { },
+
+ //
+ //a function to call after a file download failed
+ //Args:
+ // responseHtml - the html that came back in response to the file download. this won't necessarily come back depending on the browser.
+ // in less than IE9 a cross domain error occurs because 500+ errors cause a cross domain issue due to IE subbing out the
+ // server's error message with a "helpful" IE built in message
+ // url - the original url attempted
+ // error - original error cautch from exception
+ //
+ failCallback: function (responseHtml, url, error) { },
+
+ //
+ // the HTTP method to use. Defaults to "GET".
+ //
+ httpMethod: "GET",
+
+ //
+ // if specified will perform a "httpMethod" request to the specified 'fileUrl' using the specified data.
+ // data must be an object (which will be $.param serialized) or already a key=value param string
+ //
+ data: null,
+
+ //
+ //a period in milliseconds to poll to determine if a successful file download has occured or not
+ //
+ checkInterval: 100,
+
+ //
+ //the cookie name to indicate if a file download has occured
+ //
+ cookieName: "fileDownload",
+
+ //
+ //the cookie value for the above name to indicate that a file download has occured
+ //
+ cookieValue: "true",
+
+ //
+ //the cookie path for above name value pair
+ //
+ cookiePath: "/",
+
+ //
+ //if specified it will be used when attempting to clear the above name value pair
+ //useful for when downloads are being served on a subdomain (e.g. downloads.example.com)
+ //
+ cookieDomain: null,
+
+ //
+ //the title for the popup second window as a download is processing in the case of a mobile browser
+ //
+ popupWindowTitle: "Initiating file download...",
+
+ //
+ //Functionality to encode HTML entities for a POST, need this if data is an object with properties whose values contains strings with quotation marks.
+ //HTML entity encoding is done by replacing all &,<,>,',",\r,\n characters.
+ //Note that some browsers will POST the string htmlentity-encoded whilst others will decode it before POSTing.
+ //It is recommended that on the server, htmlentity decoding is done irrespective.
+ //
+ encodeHTMLEntities: true
+
+ }, options);
+
+ var deferred = new $.Deferred();
+
+ //Setup mobile browser detection: Partial credit: http://detectmobilebrowser.com/
+ var userAgent = (navigator.userAgent || navigator.vendor || window.opera).toLowerCase();
+
+ var isIos; //has full support of features in iOS 4.0+, uses a new window to accomplish this.
+ var isAndroid; //has full support of GET features in 4.0+ by using a new window. Non-GET is completely unsupported by the browser. See above for specifying a message.
+ var isOtherMobileBrowser; //there is no way to reliably guess here so all other mobile devices will GET and POST to the current window.
+
+ if (/ip(ad|hone|od)/.test(userAgent)) {
+
+ isIos = true;
+
+ } else if (userAgent.indexOf('android') !== -1) {
+
+ isAndroid = true;
+
+ } else {
+
+ isOtherMobileBrowser = /avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|playbook|silk|iemobile|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(userAgent.substr(0, 4));
+
+ }
+
+ var httpMethodUpper = settings.httpMethod.toUpperCase();
+
+ if (isAndroid && httpMethodUpper !== "GET" && settings.androidPostUnsupportedMessageHtml) {
+ //the stock android browser straight up doesn't support file downloads initiated by non GET requests: http://code.google.com/p/android/issues/detail?id=1780
+
+ if ($().dialog) {
+ $("").html(settings.androidPostUnsupportedMessageHtml).dialog(settings.dialogOptions);
+ } else {
+ alert(settings.androidPostUnsupportedMessageHtml);
+ }
+
+ return deferred.reject();
+ }
+
+ var $preparingDialog = null;
+
+ var internalCallbacks = {
+
+ onPrepare: function (url) {
+
+ //wire up a jquery dialog to display the preparing message if specified
+ if (settings.preparingMessageHtml) {
+
+ $preparingDialog = $("
").html(settings.preparingMessageHtml).dialog(settings.dialogOptions);
+
+ } else if (settings.prepareCallback) {
+
+ settings.prepareCallback(url);
+
+ }
+
+ },
+
+ onSuccess: function (url) {
+
+ //remove the perparing message if it was specified
+ if ($preparingDialog) {
+ $preparingDialog.dialog('close');
+ }
+
+ settings.successCallback(url);
+
+ deferred.resolve(url);
+ },
+
+ onAbort: function (url) {
+
+ //remove the perparing message if it was specified
+ if ($preparingDialog) {
+ $preparingDialog.dialog('close');
+ };
+
+ settings.abortCallback(url);
+
+ deferred.reject(url);
+ },
+
+ onFail: function (responseHtml, url, error) {
+
+ //remove the perparing message if it was specified
+ if ($preparingDialog) {
+ $preparingDialog.dialog('close');
+ }
+
+ //wire up a jquery dialog to display the fail message if specified
+ if (settings.failMessageHtml) {
+ $("
").html(settings.failMessageHtml).dialog(settings.dialogOptions);
+ }
+
+ settings.failCallback(responseHtml, url, error);
+
+ deferred.reject(responseHtml, url);
+ }
+ };
+
+ internalCallbacks.onPrepare(fileUrl);
+
+ //make settings.data a param string if it exists and isn't already
+ if (settings.data !== null && typeof settings.data !== "string") {
+ settings.data = $.param(settings.data);
+ }
+
+
+ var $iframe,
+ downloadWindow,
+ formDoc,
+ $form;
+
+ if (httpMethodUpper === "GET") {
+
+ if (settings.data !== null) {
+ //need to merge any fileUrl params with the data object
+
+ var qsStart = fileUrl.indexOf('?');
+
+ if (qsStart !== -1) {
+ //we have a querystring in the url
+
+ if (fileUrl.substring(fileUrl.length - 1) !== "&") {
+ fileUrl = fileUrl + "&";
+ }
+ } else {
+
+ fileUrl = fileUrl + "?";
+ }
+
+ fileUrl = fileUrl + settings.data;
+ }
+
+ if (isIos || isAndroid) {
+
+ downloadWindow = window.open(fileUrl);
+ downloadWindow.document.title = settings.popupWindowTitle;
+ window.focus();
+
+ } else if (isOtherMobileBrowser) {
+
+ window.location(fileUrl);
+
+ } else {
+
+ //create a temporary iframe that is used to request the fileUrl as a GET request
+ $iframe = $("