mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-02-20 01:41:27 +01:00
* [DEV] New API methods and improvements (work in progress)
This commit is contained in:
@@ -37,7 +37,6 @@ use SP\Core\Session;
|
||||
use SP\Core\Template;
|
||||
use SP\Http\Request;
|
||||
use SP\Http\Response;
|
||||
use SP\Util\Checks;
|
||||
use SP\Util\Util;
|
||||
|
||||
define('APP_ROOT', '..');
|
||||
|
||||
7
api.php
7
api.php
@@ -25,6 +25,7 @@
|
||||
|
||||
use SP\Api\ApiRequest;
|
||||
use SP\Core\Init;
|
||||
use SP\Http\Response;
|
||||
|
||||
define('APP_ROOT', '.');
|
||||
|
||||
@@ -38,9 +39,9 @@ try {
|
||||
$ApiRequest = new ApiRequest();
|
||||
exit($ApiRequest->runApi());
|
||||
} catch (Exception $e) {
|
||||
\SP\Http\Response::printJson(
|
||||
array(
|
||||
Response::printJson(
|
||||
[
|
||||
'message' => $e->getMessage(),
|
||||
'help' => ApiRequest::getHelp()
|
||||
));
|
||||
]);
|
||||
}
|
||||
@@ -25,11 +25,14 @@
|
||||
|
||||
namespace SP\Account;
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Crypt;
|
||||
use SP\DataModel\AccountData;
|
||||
use SP\DataModel\AccountExtData;
|
||||
use SP\DataModel\AccountHistoryData;
|
||||
use SP\DataModel\CustomFieldData;
|
||||
use SP\DataModel\GroupAccountsData;
|
||||
use SP\Mgmt\CustomFields\CustomField;
|
||||
use SP\Mgmt\Files\FileUtil;
|
||||
use SP\Mgmt\Groups\GroupAccounts;
|
||||
use SP\Mgmt\Groups\GroupAccountsUtil;
|
||||
@@ -303,16 +306,18 @@ class Account extends AccountBase implements AccountInterface
|
||||
$Data->setMapClass($this->accountData);
|
||||
$Data->addParam($this->accountData->getAccountId(), 'id');
|
||||
|
||||
/** @var AccountExtData $queryRes */
|
||||
/** @var AccountExtData|array $queryRes */
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('No se pudieron obtener los datos de la cuenta'));
|
||||
} elseif (is_array($queryRes) && count($queryRes) === 0){
|
||||
throw new SPException(SPException::SP_CRITICAL, _('La cuenta no existe'));
|
||||
}
|
||||
|
||||
// Obtener los usuarios y grupos secundarios y las etiquetas
|
||||
$this->accountData->setUsersId(UserAccounts::getUsersForAccount($queryRes->getAccountId()));
|
||||
$this->accountData->setUserGroupsId(GroupAccountsUtil::getGroupsForAccount($queryRes->getAccountId()));
|
||||
$this->accountData->setUsersId(UserAccounts::getUsersForAccount($this->accountData->getAccountId()));
|
||||
$this->accountData->setUserGroupsId(GroupAccountsUtil::getGroupsForAccount($this->accountData->getAccountId()));
|
||||
$this->accountData->setTags(AccountTags::getTags($queryRes));
|
||||
|
||||
return $this->accountData;
|
||||
@@ -464,6 +469,10 @@ class Account extends AccountBase implements AccountInterface
|
||||
try {
|
||||
GroupAccounts::getItem()->delete($this->accountData->getAccountId());
|
||||
FileUtil::deleteAccountFiles($this->accountData->getAccountId());
|
||||
|
||||
$CustomFieldData = new CustomFieldData();
|
||||
$CustomFieldData->setModule(ActionsInterface::ACTION_ACC);
|
||||
CustomField::getItem($CustomFieldData)->delete($this->accountData->getAccountId());
|
||||
} catch (SPException $e) {
|
||||
$Log->setLogLevel(Log::ERROR);
|
||||
$Log->addDescription($e->getMessage());
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace SP\Api;
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
use SP\Auth\Auth;
|
||||
use SP\Auth\AuthDataBase;
|
||||
use SP\Auth\AuthResult;
|
||||
use SP\Auth\AuthUtil;
|
||||
use SP\Core\Acl;
|
||||
use SP\Core\Session;
|
||||
@@ -43,7 +45,7 @@ use SP\Util\Json;
|
||||
*
|
||||
* @package SP\Api
|
||||
*/
|
||||
abstract class ApiBase
|
||||
abstract class ApiBase implements ApiInterface
|
||||
{
|
||||
/**
|
||||
* El ID de la acción
|
||||
@@ -69,10 +71,6 @@ abstract class ApiBase
|
||||
* @var mixed
|
||||
*/
|
||||
protected $params;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $actionsMap = [];
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -88,32 +86,12 @@ abstract class ApiBase
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido'));
|
||||
}
|
||||
|
||||
$this->userId = ApiTokensUtil::getUserIdForToken($params->authToken);
|
||||
$this->actionId = $this->getActionId($params->action);
|
||||
$this->auth = true;
|
||||
$this->params = $params;
|
||||
$this->userId = ApiTokensUtil::getUserIdForToken($this->getParam('authToken', true));
|
||||
$this->actionId = $this->getActionId($this->getParam('action', true));
|
||||
|
||||
if (isset($params->userPass)) {
|
||||
|
||||
$UserData = new UserData();
|
||||
$UserData->setUserId($this->userId);
|
||||
$UserData->setUserPass($params->userPass);
|
||||
|
||||
User::getItem($UserData)->getById($this->userId);
|
||||
|
||||
$UserPass = UserPass::getItem($UserData);
|
||||
$Auth = new Auth($UserData);
|
||||
|
||||
if (!$UserData->isUserIsDisabled()
|
||||
&& $Auth->doAuth()
|
||||
&& $UserPass->loadUserMPass()
|
||||
&& $UserPass->checkUserUpdateMPass()
|
||||
) {
|
||||
$this->mPass = $UserPass->getClearUserMPass();
|
||||
SessionUtil::loadUserSession($UserData);
|
||||
} else {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido'));
|
||||
}
|
||||
if ($this->getParam('userPass') !== null) {
|
||||
$this->doAuth();
|
||||
}
|
||||
|
||||
Session::setSessionType(Session::SESSION_API);
|
||||
@@ -127,7 +105,9 @@ abstract class ApiBase
|
||||
*/
|
||||
protected function getActionId($action)
|
||||
{
|
||||
return (is_array($this->actionsMap) && isset($this->actionsMap[$action])) ? $this->actionsMap[$action] : 0;
|
||||
$actions = $this->getActions();
|
||||
|
||||
return isset($actions[$action]) ? $actions[$action] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,11 +132,90 @@ abstract class ApiBase
|
||||
*/
|
||||
protected function wrapJSON(&$data)
|
||||
{
|
||||
$json = array(
|
||||
$json = [
|
||||
'action' => Acl::getActionName($this->actionId, true),
|
||||
'data' => $data
|
||||
);
|
||||
];
|
||||
|
||||
return Json::getJson($json);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el valor de un parámetro
|
||||
*
|
||||
* @param string $name Nombre del parámetro
|
||||
* @param bool $required Si es requerido
|
||||
* @param mixed $default Valor por defecto
|
||||
* @return int|string
|
||||
* @throws SPException
|
||||
*/
|
||||
protected function getParam($name, $required = false, $default = null)
|
||||
{
|
||||
if ($required === true && !isset($this->params->$name)) {
|
||||
debugLog(__FUNCTION__ . ':' . $name);
|
||||
|
||||
throw new SPException(SPException::SP_WARNING, _('Parámetros incorrectos'));
|
||||
}
|
||||
|
||||
if (isset($this->params->$name)) {
|
||||
return $this->params->$name;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Realizar la autentificación del usuario
|
||||
*
|
||||
* @throws SPException
|
||||
*/
|
||||
protected function doAuth()
|
||||
{
|
||||
$UserData = new UserData();
|
||||
$UserData->setUserId($this->userId);
|
||||
$UserData->setUserPass($this->getParam('userPass'));
|
||||
|
||||
$UserData = User::getItem($UserData)->getById($this->userId);
|
||||
|
||||
$Auth = new Auth($UserData);
|
||||
$resAuth = $Auth->doAuth();
|
||||
|
||||
if ($resAuth !== false) {
|
||||
/** @var AuthResult $AuthResult */
|
||||
foreach ($resAuth as $AuthResult) {
|
||||
$data = $AuthResult->getData();
|
||||
|
||||
if ($data->getAuthenticated() && $data->getStatusCode() === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido'));
|
||||
}
|
||||
|
||||
$UserPass = UserPass::getItem($UserData);
|
||||
|
||||
if (!$UserData->isUserIsDisabled()
|
||||
&& $UserPass->checkUserUpdateMPass()
|
||||
&& $UserPass->loadUserMPass()
|
||||
) {
|
||||
$this->auth = true;
|
||||
$this->mPass = $UserPass->getClearUserMPass();
|
||||
SessionUtil::loadUserSession($UserData);
|
||||
} else {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si se ha realizado la autentificación
|
||||
*
|
||||
* @throws SPException
|
||||
*/
|
||||
protected function checkAuth()
|
||||
{
|
||||
if ($this->auth === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido'));
|
||||
}
|
||||
}
|
||||
}
|
||||
40
inc/SP/Api/ApiInterface.class.php
Normal file
40
inc/SP/Api/ApiInterface.class.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Api;
|
||||
|
||||
/**
|
||||
* Interface ApiInterface
|
||||
*
|
||||
* @package SP\Api
|
||||
*/
|
||||
interface ApiInterface
|
||||
{
|
||||
/**
|
||||
* Devuelve las acciones que implementa la API
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getActions();
|
||||
}
|
||||
@@ -55,13 +55,15 @@ class ApiRequest extends Request
|
||||
private $params;
|
||||
|
||||
/** @var string */
|
||||
private $verb = null;
|
||||
private $verb;
|
||||
|
||||
/** @var ReflectionClass */
|
||||
private $ApiReflection;
|
||||
|
||||
/**
|
||||
* ApiRequest constructor.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -104,11 +106,12 @@ class ApiRequest extends Request
|
||||
*/
|
||||
private function getData()
|
||||
{
|
||||
$data = self::parse(file_get_contents('php://input'), '', true);
|
||||
$request = file_get_contents('php://input');
|
||||
$data = self::parse($request, '', true);
|
||||
|
||||
$this->params = json_decode($data);
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE || !is_object($this->params)) {
|
||||
if (!is_object($this->params) || json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Datos inválidos'));
|
||||
}
|
||||
}
|
||||
@@ -120,9 +123,7 @@ class ApiRequest extends Request
|
||||
*/
|
||||
private function checkBasicData()
|
||||
{
|
||||
if (!isset($this->params->authToken)
|
||||
|| !isset($this->params->action)
|
||||
) {
|
||||
if (!isset($this->params->authToken, $this->params->action)) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Parámetros incorrectos'));
|
||||
}
|
||||
}
|
||||
@@ -134,7 +135,7 @@ class ApiRequest extends Request
|
||||
*/
|
||||
private function checkAction()
|
||||
{
|
||||
$this->ApiReflection = new ReflectionClass('\SP\Api\SyspassApi');
|
||||
$this->ApiReflection = new ReflectionClass(SyspassApi::class);
|
||||
|
||||
if (!$this->ApiReflection->hasMethod($this->params->action)) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Acción inválida'));
|
||||
@@ -148,14 +149,10 @@ class ApiRequest extends Request
|
||||
*/
|
||||
public static function getHelp()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
self::AUTH_TOKEN => _('Token de autorización'),
|
||||
self::ACTION => _('Acción a realizar'),
|
||||
self::USER_PASS => _('Clave de usuario (opcional)'),
|
||||
self::SEARCH => _('Cadena a buscar'),
|
||||
self::SEARCH_COUNT => _('Numero de cuentas a mostar en la búsqueda'),
|
||||
self::ITEM => _('Item a devolver')
|
||||
);
|
||||
self::ACTION => _('Acción a realizar')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,6 +170,7 @@ class ApiRequest extends Request
|
||||
* Obtiene una nueva instancia de la Api
|
||||
*
|
||||
* @return SyspassApi
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function runApi()
|
||||
{
|
||||
|
||||
@@ -27,8 +27,6 @@ namespace SP\Api;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Acl;
|
||||
use SP\Storage\DB;
|
||||
use SP\Log\Email;
|
||||
use SP\Html\Html;
|
||||
@@ -99,7 +97,7 @@ class ApiTokens
|
||||
$Data->addParam($this->userId, 'userid');
|
||||
$Data->addParam($this->actionId, 'actionid');
|
||||
$Data->addParam(Session::getUserData()->getUserId(), 'createdby');
|
||||
$Data->addParam(($this->getUserToken()) ? $this->token : $this->generateToken(), 'token');
|
||||
$Data->addParam($this->getUserToken() ? $this->token : $this->generateToken(), 'token');
|
||||
|
||||
try {
|
||||
DB::getQuery($Data);
|
||||
@@ -160,7 +158,7 @@ class ApiTokens
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->userId, 'userid');
|
||||
$Data->addParam($this->generateToken(),'token');
|
||||
$Data->addParam($this->generateToken(), 'token');
|
||||
|
||||
try {
|
||||
DB::getQuery($Data);
|
||||
@@ -169,6 +167,16 @@ class ApiTokens
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generar un token de acceso
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generateToken()
|
||||
{
|
||||
return sha1(uniqid('sysPass-API', true) . time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el token de la API de un usuario
|
||||
*
|
||||
@@ -225,7 +233,7 @@ class ApiTokens
|
||||
$Data->addParam($this->userId, 'userid');
|
||||
$Data->addParam($this->actionId, 'actionid');
|
||||
$Data->addParam(Session::getUserData()->getUserId(), 'createdby');
|
||||
$Data->addParam(($this->getUserToken()) ? $this->token : $this->generateToken(), 'token');
|
||||
$Data->addParam($this->getUserToken() ? $this->token : $this->generateToken(), 'token');
|
||||
|
||||
try {
|
||||
DB::getQuery($Data);
|
||||
@@ -247,11 +255,11 @@ class ApiTokens
|
||||
*/
|
||||
public function deleteToken()
|
||||
{
|
||||
$query = 'DELETE FROM authTokens WHERE authtoken_id = :id LIMIT 1';
|
||||
$query = 'DELETE FROM authTokens WHERE authtoken_id = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->tokenId, 'id');
|
||||
$Data->addParam($this->tokenId);
|
||||
|
||||
try {
|
||||
DB::getQuery($Data);
|
||||
@@ -313,14 +321,4 @@ class ApiTokens
|
||||
{
|
||||
$this->actionId = $actionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generar un token de acceso
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generateToken()
|
||||
{
|
||||
return sha1(uniqid() . time());
|
||||
}
|
||||
}
|
||||
@@ -60,9 +60,9 @@ class ApiTokensUtil
|
||||
|
||||
$Data = new QueryData();
|
||||
|
||||
if (!is_null($tokenId)) {
|
||||
$query .= 'WHERE authtoken_id = :id LIMIT 1';
|
||||
$Data->addParam($tokenId, 'id');
|
||||
if (null !== $tokenId) {
|
||||
$query .= 'WHERE authtoken_id = ? LIMIT 1';
|
||||
$Data->addParam($tokenId);
|
||||
} else {
|
||||
$query .= 'ORDER BY user_login';
|
||||
}
|
||||
@@ -134,14 +134,16 @@ class ApiTokensUtil
|
||||
*/
|
||||
public static function getTokenActions()
|
||||
{
|
||||
$actions = array(
|
||||
$actions = [
|
||||
ActionsInterface::ACTION_ACC_SEARCH => Acl::getActionName(ActionsInterface::ACTION_ACC_SEARCH),
|
||||
ActionsInterface::ACTION_ACC_VIEW => Acl::getActionName(ActionsInterface::ACTION_ACC_VIEW),
|
||||
ActionsInterface::ACTION_ACC_VIEW_PASS => Acl::getActionName(ActionsInterface::ACTION_ACC_VIEW_PASS),
|
||||
ActionsInterface::ACTION_ACC_DELETE => Acl::getActionName(ActionsInterface::ACTION_ACC_DELETE),
|
||||
ActionsInterface::ACTION_ACC_NEW => Acl::getActionName(ActionsInterface::ACTION_ACC_NEW),
|
||||
ActionsInterface::ACTION_CFG_BACKUP => Acl::getActionName(ActionsInterface::ACTION_CFG_BACKUP),
|
||||
ActionsInterface::ACTION_CFG_EXPORT => Acl::getActionName(ActionsInterface::ACTION_CFG_EXPORT),
|
||||
);
|
||||
ActionsInterface::ACTION_MGM_CATEGORIES => Acl::getActionName(ActionsInterface::ACTION_MGM_CATEGORIES),
|
||||
ActionsInterface::ACTION_MGM_CUSTOMERS => Acl::getActionName(ActionsInterface::ACTION_MGM_CUSTOMERS)
|
||||
];
|
||||
|
||||
return $actions;
|
||||
}
|
||||
@@ -155,11 +157,11 @@ class ApiTokensUtil
|
||||
*/
|
||||
public static function getUserIdForToken($token)
|
||||
{
|
||||
$query = 'SELECT authtoken_userId FROM authTokens WHERE authtoken_token = :token LIMIT 1';
|
||||
$query = 'SELECT authtoken_userId FROM authTokens WHERE authtoken_token = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($token, 'token');
|
||||
$Data->addParam($token);
|
||||
|
||||
try {
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
@@ -32,6 +32,14 @@ use SP\Core\Acl;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Crypt;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\AccountExtData;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\DataModel\CustomerData;
|
||||
use SP\DataModel\ItemSearchData;
|
||||
use SP\Mgmt\Categories\Category;
|
||||
use SP\Mgmt\Categories\CategorySearch;
|
||||
use SP\Mgmt\Customers\Customer;
|
||||
use SP\Mgmt\Customers\CustomerSearch;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
@@ -42,15 +50,6 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'
|
||||
*/
|
||||
class SyspassApi extends ApiBase
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $actionsMap = array(
|
||||
'getAccountPassword' => ActionsInterface::ACTION_ACC_VIEW_PASS,
|
||||
'getAccountSearch' => ActionsInterface::ACTION_ACC_SEARCH,
|
||||
'getAccountData' => ActionsInterface::ACTION_ACC_VIEW
|
||||
);
|
||||
|
||||
/**
|
||||
* Devolver la clave de una cuenta
|
||||
*
|
||||
@@ -61,11 +60,9 @@ class SyspassApi extends ApiBase
|
||||
{
|
||||
$this->checkActionAccess(ActionsInterface::ACTION_ACC_VIEW_PASS);
|
||||
|
||||
if (!isset($this->params->accountId)) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Parámetros incorrectos'));
|
||||
}
|
||||
$accountId = $this->getParam('id', true, 0);
|
||||
|
||||
$AccountData = new AccountData($this->params->accountId);
|
||||
$AccountData = new AccountData($accountId);
|
||||
$Account = new Account($AccountData);
|
||||
$Account->getData();
|
||||
|
||||
@@ -75,7 +72,7 @@ class SyspassApi extends ApiBase
|
||||
$access = ($Acl->checkAccountAccess()
|
||||
&& Acl::checkUserAccess(ActionsInterface::ACTION_ACC_VIEW_PASS));
|
||||
|
||||
if (!$access){
|
||||
if (!$access) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Acceso no permitido'));
|
||||
}
|
||||
|
||||
@@ -104,17 +101,15 @@ class SyspassApi extends ApiBase
|
||||
{
|
||||
$this->checkActionAccess(ActionsInterface::ACTION_ACC_SEARCH);
|
||||
|
||||
if (!isset($this->params->searchText)) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Parámetros incorrectos'));
|
||||
}
|
||||
|
||||
$count = (isset($this->params->searchCount)) ? (int)$this->params->searchCount : 0;
|
||||
$text = $this->getParam('searchText', true, '');
|
||||
|
||||
$Search = new AccountSearch();
|
||||
$Search->setTxtSearch($this->params->searchText);
|
||||
$Search->setLimitCount($count);
|
||||
$Search->setTxtSearch($text);
|
||||
$Search->setLimitCount($this->getParam('searchCount', false, 0));
|
||||
$Search->setCategoryId($this->getParam('categoryId', false, 0));
|
||||
$Search->setCustomerId($this->getParam('customerId', false, 0));
|
||||
|
||||
$ret = array($this->params, $Search->getAccounts());
|
||||
$ret = [$this->params, $Search->getAccounts()];
|
||||
|
||||
return $this->wrapJSON($ret);
|
||||
}
|
||||
@@ -129,18 +124,16 @@ class SyspassApi extends ApiBase
|
||||
{
|
||||
$this->checkActionAccess(ActionsInterface::ACTION_ACC_VIEW);
|
||||
|
||||
if (!isset($this->params->accountId)) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Parámetros incorrectos'));
|
||||
}
|
||||
$accountId = $this->getParam('id', true, 0);
|
||||
|
||||
$Account = new Account(new AccountData($this->params->accountId));
|
||||
$Account = new Account(new AccountExtData($accountId));
|
||||
$Acl = new Acl(ActionsInterface::ACTION_ACC_VIEW);
|
||||
$Acl->setAccountData($Account->getAccountDataForACL());
|
||||
|
||||
$access = ($Acl->checkAccountAccess()
|
||||
&& Acl::checkUserAccess(ActionsInterface::ACTION_ACC_VIEW));
|
||||
|
||||
if (!$access){
|
||||
if (!$access) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Acceso no permitido'));
|
||||
}
|
||||
|
||||
@@ -149,4 +142,227 @@ class SyspassApi extends ApiBase
|
||||
|
||||
return $this->wrapJSON($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Añadir una nueva cuenta
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function addAccount()
|
||||
{
|
||||
debugLog(__FUNCTION__);
|
||||
|
||||
$this->checkAuth();
|
||||
$this->checkActionAccess(ActionsInterface::ACTION_ACC_NEW);
|
||||
|
||||
$AccountData = new AccountExtData();
|
||||
$AccountData->setAccountUserId($this->userId);
|
||||
$AccountData->setAccountName($this->getParam('name', true));
|
||||
$AccountData->setAccountPass($this->getParam('pass', true));
|
||||
$AccountData->setAccountCustomerId($this->getParam('customerId', true));
|
||||
$AccountData->setAccountCategoryId($this->getParam('categoryId', true));
|
||||
$AccountData->setAccountLogin($this->getParam('login', true));
|
||||
$AccountData->setAccountUrl($this->getParam('url'));
|
||||
$AccountData->setAccountNotes($this->getParam('notes'));
|
||||
|
||||
$Account = new Account($AccountData);
|
||||
|
||||
if ($Account->createAccount()) {
|
||||
$ret = [
|
||||
'accountId' => $AccountData->getAccountId(),
|
||||
'result' => _('Cuenta creada'),
|
||||
'resultCode' => 0
|
||||
];
|
||||
|
||||
return $this->wrapJSON($ret);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminar una cuenta
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function deleteAccount()
|
||||
{
|
||||
$this->checkActionAccess(ActionsInterface::ACTION_ACC_DELETE);
|
||||
|
||||
$AccountData = new AccountData();
|
||||
$AccountData->setAccountId($this->getParam('id', true));
|
||||
|
||||
$Account = new Account($AccountData);
|
||||
|
||||
if ($Account->deleteAccount()) {
|
||||
$ret = [
|
||||
'accountId' => $AccountData->getAccountId(),
|
||||
'result' => _('Cuenta eliminada'),
|
||||
'resultCode' => 0
|
||||
];
|
||||
|
||||
return $this->wrapJSON($ret);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve el listado de categorías
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function getCategories()
|
||||
{
|
||||
$this->checkActionAccess(ActionsInterface::ACTION_MGM_CATEGORIES);
|
||||
|
||||
$SearchData = new ItemSearchData();
|
||||
$SearchData->setSeachString($this->getParam('name', false, ''));
|
||||
$SearchData->setLimitStart($this->getParam('start', false, 0));
|
||||
$SearchData->setLimitCount($this->getParam('count', false, 100));
|
||||
|
||||
$ret = CategorySearch::getItem()->getMgmtSearch($SearchData);
|
||||
|
||||
return $this->wrapJSON($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Añade una nueva categoría
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function addCategory()
|
||||
{
|
||||
$this->checkActionAccess(ActionsInterface::ACTION_MGM_CATEGORIES);
|
||||
|
||||
$CategoryData = new CategoryData();
|
||||
$CategoryData->setCategoryName($this->getParam('name', true));
|
||||
$CategoryData->setCategoryDescription($this->getParam('description'));
|
||||
|
||||
$Category = Category::getItem($CategoryData)->add();
|
||||
|
||||
$ret = [
|
||||
'categoryId' => $Category->getItemData()->getCategoryId(),
|
||||
'result' => _('Categoría creada'),
|
||||
'resultCode' => 0
|
||||
];
|
||||
|
||||
return $this->wrapJSON($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Elimina una categoría
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function deleteCategory()
|
||||
{
|
||||
$this->checkActionAccess(ActionsInterface::ACTION_MGM_CATEGORIES);
|
||||
|
||||
$id = $this->getParam('id', true);
|
||||
Category::getItem()->delete($id);
|
||||
|
||||
$ret = [
|
||||
'categoryId' => $id,
|
||||
'result' => _('Categoría eliminada'),
|
||||
'resultCode' => 0
|
||||
];
|
||||
|
||||
return $this->wrapJSON($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve el listado de clientes
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function getCustomers()
|
||||
{
|
||||
$this->checkActionAccess(ActionsInterface::ACTION_MGM_CUSTOMERS);
|
||||
|
||||
$SearchData = new ItemSearchData();
|
||||
$SearchData->setSeachString($this->getParam('name', false, ''));
|
||||
$SearchData->setLimitStart($this->getParam('start', false, 0));
|
||||
$SearchData->setLimitCount($this->getParam('count', false, 100));
|
||||
|
||||
$ret = CustomerSearch::getItem()->getMgmtSearch($SearchData);
|
||||
|
||||
return $this->wrapJSON($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Añade un nuevo cliente
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function addCustomer()
|
||||
{
|
||||
$this->checkActionAccess(ActionsInterface::ACTION_MGM_CUSTOMERS);
|
||||
|
||||
$CustomerData = new CustomerData();
|
||||
$CustomerData->setCustomerName($this->getParam('name', true));
|
||||
$CustomerData->setCustomerDescription($this->getParam('description'));
|
||||
|
||||
$Customer = Customer::getItem($CustomerData)->add();
|
||||
|
||||
$ret = [
|
||||
'customerId' => $Customer->getItemData()->getCustomerId(),
|
||||
'result' => _('Cliente creado'),
|
||||
'resultCode' => 0
|
||||
];
|
||||
|
||||
return $this->wrapJSON($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Elimina un cñiente
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function deleteCustomer()
|
||||
{
|
||||
$this->checkActionAccess(ActionsInterface::ACTION_MGM_CUSTOMERS);
|
||||
|
||||
$id = $this->getParam('id', true);
|
||||
Customer::getItem()->delete($id);
|
||||
|
||||
$ret = [
|
||||
'customerId' => $id,
|
||||
'result' => _('Cliente eliminado'),
|
||||
'resultCode' => 0
|
||||
];
|
||||
|
||||
return $this->wrapJSON($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve las acciones que implementa la API
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getActions()
|
||||
{
|
||||
return [
|
||||
'getAccountPassword' => ActionsInterface::ACTION_ACC_VIEW_PASS,
|
||||
'getAccountSearch' => ActionsInterface::ACTION_ACC_SEARCH,
|
||||
'getAccountData' => ActionsInterface::ACTION_ACC_VIEW,
|
||||
'deleteAccount' => ActionsInterface::ACTION_ACC_DELETE,
|
||||
'addAccount' => ActionsInterface::ACTION_ACC_NEW,
|
||||
'backup' => ActionsInterface::ACTION_CFG_BACKUP,
|
||||
'getCategories' => ActionsInterface::ACTION_MGM_CATEGORIES,
|
||||
'addCategory' => ActionsInterface::ACTION_MGM_CATEGORIES,
|
||||
'deleteCategory' => ActionsInterface::ACTION_MGM_CATEGORIES,
|
||||
'getCustomers' => ActionsInterface::ACTION_MGM_CUSTOMERS,
|
||||
'addCustomer' => ActionsInterface::ACTION_MGM_CUSTOMERS,
|
||||
'deleteCustomer' => ActionsInterface::ACTION_MGM_CUSTOMERS,
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class Auth extends PluginAwareBase
|
||||
$pResult = call_user_func([$this, $pAuth]);
|
||||
|
||||
if ($pResult !== false) {
|
||||
$auths[] = ['auth' => $pAuth, 'data' => $pResult];
|
||||
$auths[] = new AuthResult($pAuth, $pResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
70
inc/SP/Auth/AuthResult.class.php
Normal file
70
inc/SP/Auth/AuthResult.class.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2016, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Auth;
|
||||
|
||||
/**
|
||||
* Class AuthData
|
||||
*
|
||||
* @package SP\Auth
|
||||
*/
|
||||
class AuthResult
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $auth;
|
||||
/**
|
||||
* @var AuthDataBase
|
||||
*/
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* AuthResult constructor.
|
||||
*
|
||||
* @param string $auth
|
||||
* @param AuthDataBase $data
|
||||
*/
|
||||
public function __construct($auth, AuthDataBase $data)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAuth()
|
||||
{
|
||||
return $this->auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AuthDataBase
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
@@ -352,7 +352,6 @@ class ItemActionController implements ItemControllerInterface
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_DELETE:
|
||||
Customer::getItem()->delete($this->itemId);
|
||||
$this->deleteCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Cliente eliminado'));
|
||||
break;
|
||||
@@ -389,7 +388,6 @@ class ItemActionController implements ItemControllerInterface
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_DELETE:
|
||||
Category::getItem()->delete($this->itemId);
|
||||
$this->deleteCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Categoría eliminada'));
|
||||
break;
|
||||
@@ -589,7 +587,6 @@ class ItemActionController implements ItemControllerInterface
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_DELETE:
|
||||
$Account->deleteAccount();
|
||||
$this->deleteCustomFieldData();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Cuenta eliminada'));
|
||||
break;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace SP\Controller;
|
||||
|
||||
use SP\Auth\Auth;
|
||||
use SP\Auth\AuthResult;
|
||||
use SP\Auth\AuthUtil;
|
||||
use SP\Auth\Browser\BrowserAuthData;
|
||||
use SP\Auth\Database\DatabaseAuthData;
|
||||
@@ -115,8 +116,10 @@ class LoginController
|
||||
|
||||
if ($result !== false) {
|
||||
// Ejecutar la acción asociada al tipo de autentificación
|
||||
foreach ($result as $auth) {
|
||||
$this->{$auth['auth']}($auth['data']);
|
||||
|
||||
/** @var AuthResult $AuthResult */
|
||||
foreach ($result as $AuthResult) {
|
||||
$this->{$AuthResult->getAuth()}($AuthResult->getData());
|
||||
}
|
||||
} else {
|
||||
throw new AuthException(SPException::SP_INFO, _('Login incorrecto'), '', self::STATUS_INVALID_LOGIN);
|
||||
@@ -218,7 +221,7 @@ class LoginController
|
||||
$UserPass = $this->loadMasterPass();
|
||||
|
||||
// Obtenemos la clave maestra del usuario
|
||||
if ($UserPass->getClearUserMPass()) {
|
||||
if ($UserPass->getClearUserMPass() !== '') {
|
||||
// Actualizar el último login del usuario
|
||||
UserUtil::setUserLastLogin($this->UserData->getUserId());
|
||||
|
||||
@@ -263,6 +266,8 @@ class LoginController
|
||||
|
||||
throw new AuthException(SPException::SP_INFO, _('Clave maestra incorrecta'), '', self::STATUS_INVALID_MASTER_PASS);
|
||||
} else {
|
||||
SessionUtil::saveSessionMPass($UserPass->getClearUserMPass());
|
||||
|
||||
Log::writeNewLog(_('Login'), _('Clave maestra actualizada'));
|
||||
}
|
||||
} else if ($oldPass) {
|
||||
@@ -272,6 +277,8 @@ class LoginController
|
||||
|
||||
throw new AuthException(SPException::SP_INFO, _('Clave maestra incorrecta'), '', self::STATUS_INVALID_MASTER_PASS);
|
||||
} else {
|
||||
SessionUtil::saveSessionMPass($UserPass->getClearUserMPass());
|
||||
|
||||
Log::writeNewLog(_('Login'), _('Clave maestra actualizada'));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -214,7 +214,15 @@ class Acl implements ActionsInterface
|
||||
self::ACTION_ACC_REQUEST => ['acc_request', _('Peticiones')],
|
||||
self::ACTION_MGM => ['mgm', _('Gestión Aplicación')],
|
||||
self::ACTION_MGM_CATEGORIES => ['mgm_categories', _('Gestión Categorías')],
|
||||
self::ACTION_MGM_CATEGORIES_SEARCH => ['mgm_categories_search', _('Buscar Categorías')],
|
||||
self::ACTION_MGM_CATEGORIES_NEW => ['mgm_categories_add', _('Añadir Categoría')],
|
||||
self::ACTION_MGM_CATEGORIES_EDIT => ['mgm_categories_edit', _('Editar Categoría')],
|
||||
self::ACTION_MGM_CATEGORIES_DELETE => ['mgm_categories_delete', _('Eliminar Categoría')],
|
||||
self::ACTION_MGM_CUSTOMERS => ['mgm_customers', _('Gestión Clientes')],
|
||||
self::ACTION_MGM_CUSTOMERS_SEARCH => ['mgm_customers', _('Buscar Clientes')],
|
||||
self::ACTION_MGM_CUSTOMERS_NEW => ['mgm_customers_add', _('Añadir Cliente')],
|
||||
self::ACTION_MGM_CUSTOMERS_EDIT => ['mgm_customers_edit', _('Editar Cliente')],
|
||||
self::ACTION_MGM_CUSTOMERS_DELETE => ['mgm_customers_delete', _('Eliminar Cliente')],
|
||||
self::ACTION_MGM_CUSTOMFIELDS => ['mgm_customfields', _('Gestión Campos Personalizados')],
|
||||
self::ACTION_MGM_APITOKENS => ['mgm_apitokens', _('Gestión Autorizaciones API')],
|
||||
self::ACTION_MGM_FILES => ['mgm_files', _('Gestión de Archivos')],
|
||||
|
||||
@@ -508,9 +508,6 @@ class Init
|
||||
{
|
||||
self::wrLogoutInfo();
|
||||
SessionUtil::cleanSession();
|
||||
|
||||
// session_unset();
|
||||
// session_destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,7 +115,11 @@ class Language
|
||||
*/
|
||||
private function getBrowserLang()
|
||||
{
|
||||
return str_replace('-', '_', substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5));
|
||||
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||
return str_replace('-', '_', substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5));
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,7 @@ class Session
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $default
|
||||
* @return bool|int
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getSessionKey($key, $default = '')
|
||||
{
|
||||
|
||||
@@ -53,6 +53,8 @@ class SessionUtil
|
||||
|
||||
/**
|
||||
* Establecer la clave pública RSA en la sessión
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public static function loadPublicKey()
|
||||
{
|
||||
@@ -125,31 +127,35 @@ class SessionUtil
|
||||
*/
|
||||
public static function cleanSession()
|
||||
{
|
||||
Session::unsetSessionKey('uid');
|
||||
Session::unsetSessionKey('uisadminapp');
|
||||
Session::unsetSessionKey('uisadminacc');
|
||||
Session::unsetSessionKey('uprofile');
|
||||
Session::unsetSessionKey('ulogin');
|
||||
Session::unsetSessionKey('uname');
|
||||
Session::unsetSessionKey('ugroup');
|
||||
Session::unsetSessionKey('ugroupn');
|
||||
Session::unsetSessionKey('uemail');
|
||||
Session::unsetSessionKey('uisldap');
|
||||
Session::unsetSessionKey('usrprofile');
|
||||
Session::unsetSessionKey('searchFilters');
|
||||
Session::unsetSessionKey('accParentId');
|
||||
Session::unsetSessionKey('mPass');
|
||||
Session::unsetSessionKey('mPassPwd');
|
||||
Session::unsetSessionKey('mPassIV');
|
||||
Session::unsetSessionKey('sidStartTime');
|
||||
Session::unsetSessionKey('startActivity');
|
||||
Session::unsetSessionKey('lastActivity');
|
||||
Session::unsetSessionKey('lastAccountId');
|
||||
Session::unsetSessionKey('theme');
|
||||
Session::unsetSessionKey('2fapass');
|
||||
Session::unsetSessionKey('locale');
|
||||
Session::unsetSessionKey('userpreferences');
|
||||
Session::unsetSessionKey('tempmasterpass');
|
||||
Session::unsetSessionKey('accountcolor');
|
||||
foreach ($_SESSION as $key => $value){
|
||||
unset($_SESSION[$key]);
|
||||
}
|
||||
|
||||
// Session::unsetSessionKey('userData');
|
||||
// Session::unsetSessionKey('usrprofile');
|
||||
// Session::unsetSessionKey('searchFilters');
|
||||
// Session::unsetSessionKey('updated');
|
||||
// Session::unsetSessionKey('sessionTimeout');
|
||||
// Session::unsetSessionKey('reload');
|
||||
// Session::unsetSessionKey('sk');
|
||||
// Session::unsetSessionKey('mPass');
|
||||
// Session::unsetSessionKey('mPassPwd');
|
||||
// Session::unsetSessionKey('mPassIV');
|
||||
// Session::unsetSessionKey('sidStartTime');
|
||||
// Session::unsetSessionKey('startActivity');
|
||||
// Session::unsetSessionKey('lastActivity');
|
||||
// Session::unsetSessionKey('lastAccountId');
|
||||
// Session::unsetSessionKey('theme');
|
||||
// Session::unsetSessionKey('2fapass');
|
||||
// Session::unsetSessionKey('pubkey');
|
||||
// Session::unsetSessionKey('locale');
|
||||
// Session::unsetSessionKey('userpreferences');
|
||||
// Session::unsetSessionKey('tempmasterpass');
|
||||
// Session::unsetSessionKey('accountcolor');
|
||||
// Session::unsetSessionKey('curlcookiesession');
|
||||
// Session::unsetSessionKey('dokuwikisession');
|
||||
// Session::unsetSessionKey('sessiontype');
|
||||
// Session::unsetSessionKey('config');
|
||||
// Session::unsetSessionKey('configTime');
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,10 @@ class CategoryData extends DataModelBase implements DataModelInterface
|
||||
* @var string
|
||||
*/
|
||||
public $category_description = '';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $category_hash = '';
|
||||
|
||||
/**
|
||||
* CategoryData constructor.
|
||||
@@ -126,4 +130,12 @@ class CategoryData extends DataModelBase implements DataModelInterface
|
||||
{
|
||||
return $this->category_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCategoryHash()
|
||||
{
|
||||
return $this->category_hash;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ namespace SP\DataModel;
|
||||
*
|
||||
* @package SP\DataModel
|
||||
*/
|
||||
class UserPassData
|
||||
class UserPassData extends DataModelBase
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
|
||||
@@ -28,9 +28,12 @@ namespace SP\Mgmt\Categories;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\DataModel\CustomFieldData;
|
||||
use SP\Log\Email;
|
||||
use SP\Mgmt\CustomFields\CustomField;
|
||||
use SP\Mgmt\ItemInterface;
|
||||
use SP\Mgmt\ItemSelectInterface;
|
||||
use SP\Mgmt\ItemTrait;
|
||||
@@ -58,12 +61,13 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
}
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'INSERT INTO categories SET category_name = ? ,category_description = ?';
|
||||
'INSERT INTO categories SET category_name = ?, category_description = ?, category_hash = ?';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getCategoryName());
|
||||
$Data->addParam($this->itemData->getCategoryDescription());
|
||||
$Data->addParam($this->makeItemHash($this->itemData->getCategoryName()));
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error al crear la categoría'));
|
||||
@@ -81,15 +85,19 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar duplicados
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function checkDuplicatedOnAdd()
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT category_id FROM categories WHERE category_name = ?';
|
||||
'SELECT category_id FROM categories WHERE category_hash = ? OR category_name = ?';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->makeItemHash($this->itemData->getCategoryName()));
|
||||
$Data->addParam($this->itemData->getCategoryName());
|
||||
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() >= 1);
|
||||
@@ -103,7 +111,7 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
public function delete($id)
|
||||
{
|
||||
if (is_array($id)) {
|
||||
foreach ($id as $itemId){
|
||||
foreach ($id as $itemId) {
|
||||
$this->delete($itemId);
|
||||
}
|
||||
|
||||
@@ -129,9 +137,21 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
|
||||
$Log = new Log(_('Eliminar Categoría'));
|
||||
$Log->addDetails(Html::strongText(_('Categoría')), sprintf('%s (%d)', $oldCategory->getCategoryName(), $id));
|
||||
|
||||
try {
|
||||
$CustomFieldData = new CustomFieldData();
|
||||
$CustomFieldData->setModule(ActionsInterface::ACTION_MGM_CATEGORIES);
|
||||
CustomField::getItem($CustomFieldData)->delete($id);
|
||||
} catch (SPException $e) {
|
||||
$Log->setLogLevel(Log::ERROR);
|
||||
$Log->addDescription($e->getMessage());
|
||||
}
|
||||
|
||||
$Log->writeLog();
|
||||
|
||||
Email::sendEmail($Log);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,13 +204,15 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
$query = /** @lang SQL */
|
||||
'UPDATE categories
|
||||
SET category_name = ?,
|
||||
category_description = ?
|
||||
category_description = ?,
|
||||
category_hash = ?
|
||||
WHERE category_id = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getCategoryName());
|
||||
$Data->addParam($this->itemData->getCategoryDescription());
|
||||
$Data->addParam($this->makeItemHash($this->itemData->getCategoryName()));
|
||||
$Data->addParam($this->itemData->getCategoryId());
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
@@ -213,10 +235,11 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
public function checkDuplicatedOnUpdate()
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT category_id FROM categories WHERE category_name = ? AND category_id <> ?';
|
||||
'SELECT category_id FROM categories WHERE (category_hash = ? OR category_name = ?) AND category_id <> ?';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->makeItemHash($this->itemData->getCategoryName()));
|
||||
$Data->addParam($this->itemData->getCategoryName());
|
||||
$Data->addParam($this->itemData->getCategoryId());
|
||||
|
||||
|
||||
@@ -28,8 +28,11 @@ namespace SP\Mgmt\Customers;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\DataModel\CustomerData;
|
||||
use SP\DataModel\CustomFieldData;
|
||||
use SP\Log\Email;
|
||||
use SP\Mgmt\CustomFields\CustomField;
|
||||
use SP\Mgmt\ItemInterface;
|
||||
use SP\Mgmt\ItemSelectInterface;
|
||||
use SP\Mgmt\ItemTrait;
|
||||
@@ -67,7 +70,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getCustomerName());
|
||||
$Data->addParam($this->itemData->getCustomerDescription());
|
||||
$Data->addParam($this->itemData->getCustomerHash());
|
||||
$Data->addParam($this->makeItemHash($this->itemData->getCustomerName()));
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error al crear el cliente'));
|
||||
@@ -95,28 +98,11 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->mkCustomerHash());
|
||||
$Data->addParam($this->makeItemHash($this->itemData->getCustomerName()));
|
||||
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear un hash con el nombre del cliente.
|
||||
* Esta función crear un hash para detectar clientes duplicados mediante
|
||||
* la eliminación de carácteres especiales y capitalización
|
||||
*
|
||||
* @return string con el hash generado
|
||||
*/
|
||||
private function mkCustomerHash()
|
||||
{
|
||||
$charsSrc = [
|
||||
'.', ' ', '_', ', ', '-', ';',
|
||||
'\'', '"', ':', '(', ')', '|', '/'];
|
||||
$newValue = strtolower(str_replace($charsSrc, '', DBUtil::escape($this->itemData->getCustomerName())));
|
||||
|
||||
return md5($newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int|array
|
||||
* @return mixed
|
||||
@@ -125,7 +111,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
public function delete($id)
|
||||
{
|
||||
if (is_array($id)) {
|
||||
foreach ($id as $itemId){
|
||||
foreach ($id as $itemId) {
|
||||
$this->delete($itemId);
|
||||
}
|
||||
|
||||
@@ -151,6 +137,17 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
|
||||
$Log = new Log(_('Eliminar Cliente'));
|
||||
$Log->addDetails(Html::strongText(_('Cliente')), sprintf('%s (%d)', $oldCustomer->getCustomerName(), $id));
|
||||
|
||||
|
||||
try {
|
||||
$CustomFieldData = new CustomFieldData();
|
||||
$CustomFieldData->setModule(ActionsInterface::ACTION_MGM_CUSTOMERS);
|
||||
CustomField::getItem($CustomFieldData)->delete($id);
|
||||
} catch (SPException $e) {
|
||||
$Log->setLogLevel(Log::ERROR);
|
||||
$Log->addDescription($e->getMessage());
|
||||
}
|
||||
|
||||
$Log->writeLog();
|
||||
|
||||
Email::sendEmail($Log);
|
||||
@@ -216,7 +213,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getCustomerName());
|
||||
$Data->addParam($this->itemData->getCustomerDescription());
|
||||
$Data->addParam($this->mkCustomerHash());
|
||||
$Data->addParam($this->makeItemHash($this->itemData->getCustomerName()));
|
||||
$Data->addParam($this->itemData->getCustomerId());
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
@@ -243,7 +240,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->mkCustomerHash());
|
||||
$Data->addParam($this->makeItemHash($this->itemData->getCustomerName()));
|
||||
$Data->addParam($this->itemData->getCustomerId());
|
||||
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() >= 1);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
namespace SP\Mgmt;
|
||||
use SP\DataModel\DataModelInterface;
|
||||
use SP\Storage\DBUtil;
|
||||
|
||||
|
||||
/**
|
||||
@@ -54,4 +55,21 @@ trait ItemTrait
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear un hash con el nombre del elemento.
|
||||
*
|
||||
* Esta función crear un hash para detectar nombres de elementos duplicados mediante
|
||||
* la eliminación de carácteres especiales y capitalización
|
||||
*
|
||||
* @param $name
|
||||
* @return string con el hash generado
|
||||
*/
|
||||
protected function makeItemHash($name)
|
||||
{
|
||||
$charsSrc = ['.', ' ', '_', ', ', '-', ';', '\'', '"', ':', '(', ')', '|', '/'];
|
||||
$newValue = strtolower(str_replace($charsSrc, '', DBUtil::escape($name)));
|
||||
|
||||
return md5($newValue);
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,12 @@ class User extends UserBase implements ItemInterface, ItemSelectInterface
|
||||
WHERE user_id = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
|
||||
if (is_object($this->itemData)) {
|
||||
$Data->setMapClass($this->itemData);
|
||||
} else {
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
}
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
|
||||
@@ -343,3 +343,5 @@ REFERENCES `usrGroups` (`usergroup_id`)
|
||||
ON UPDATE NO ACTION;
|
||||
ALTER TABLE `accounts`
|
||||
ADD INDEX `IDX_parentId` USING BTREE (`account_parentId` ASC);
|
||||
ALTER TABLE `categories`
|
||||
ADD COLUMN `category_hash` VARBINARY(40) NOT NULL DEFAULT 0 AFTER `category_description`;
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
#fancyContainer #wikiPage {
|
||||
#box-popup #wikiPage {
|
||||
text-align: left;
|
||||
min-width: 300px;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage li,
|
||||
#fancyContainer #wikiPage ol {
|
||||
#box-popup #wikiPage li,
|
||||
#box-popup #wikiPage ol {
|
||||
padding: 0;
|
||||
margin: 0 0 0 1.5em;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage ul li {
|
||||
#box-popup #wikiPage ul li {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage ol li {
|
||||
#box-popup #wikiPage ol li {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage li .li {
|
||||
#box-popup #wikiPage li .li {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage pre {
|
||||
#box-popup #wikiPage pre {
|
||||
overflow: auto;
|
||||
word-wrap: normal;
|
||||
border: 1px solid #ccc;
|
||||
@@ -30,42 +30,42 @@
|
||||
padding: .7em 1em;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage h1 {
|
||||
#box-popup #wikiPage h1 {
|
||||
font-size: 2em;
|
||||
margin: 0 0 .444em;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage h2 {
|
||||
#box-popup #wikiPage h2 {
|
||||
font-size: 1.5em;
|
||||
margin: 0 0 .666em;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage h3 {
|
||||
#box-popup #wikiPage h3 {
|
||||
font-size: 1.125em;
|
||||
margin: 0 0 .888em;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage h4 {
|
||||
#box-popup #wikiPage h4 {
|
||||
font-size: 1em;
|
||||
margin: 0 0 1em;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage h5 {
|
||||
#box-popup #wikiPage h5 {
|
||||
font-size: .875em;
|
||||
margin: 0 0 1.1428em;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage h6 {
|
||||
#box-popup #wikiPage h6 {
|
||||
font-size: .75em;
|
||||
margin: 0 0 1.333em;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPage h1,
|
||||
#fancyContainer #wikiPage h2,
|
||||
#fancyContainer #wikiPage h3,
|
||||
#fancyContainer #wikiPage h4,
|
||||
#fancyContainer #wikiPage h5,
|
||||
#fancyContainer #wikiPage h6 {
|
||||
#box-popup #wikiPage h1,
|
||||
#box-popup #wikiPage h2,
|
||||
#box-popup #wikiPage h3,
|
||||
#box-popup #wikiPage h4,
|
||||
#box-popup #wikiPage h5,
|
||||
#box-popup #wikiPage h6 {
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
line-height: 1.2;
|
||||
@@ -74,17 +74,17 @@
|
||||
border-bottom: 1px solid #777777;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPageInfo {
|
||||
#box-popup #wikiPageInfo {
|
||||
margin: 1em 0;
|
||||
border-top: 1px solid #607d8b;
|
||||
color: #607d8b;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPageInfo ul {
|
||||
#box-popup #wikiPageInfo ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#fancyContainer #wikiPageInfo li {
|
||||
#box-popup #wikiPageInfo li {
|
||||
float: left;
|
||||
padding: .5em;
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
#fancyContainer #wikiPage{text-align:left;min-width:300px}#fancyContainer #wikiPage li,#fancyContainer #wikiPage ol{padding:0;margin:0 0 0 1.5em}#fancyContainer #wikiPage ul li{color:#999}#fancyContainer #wikiPage ol li{color:#666}#fancyContainer #wikiPage li .li{color:#333}#fancyContainer #wikiPage pre{overflow:auto;word-wrap:normal;border:1px solid #ccc;border-radius:2px;box-shadow:inset 0 0 .5em #ccc;padding:.7em 1em}#fancyContainer #wikiPage h1{font-size:2em;margin:0 0 .444em}#fancyContainer #wikiPage h2{font-size:1.5em;margin:0 0 .666em}#fancyContainer #wikiPage h3{font-size:1.125em;margin:0 0 .888em}#fancyContainer #wikiPage h4{font-size:1em;margin:0 0 1em}#fancyContainer #wikiPage h5{font-size:.875em;margin:0 0 1.1428em}#fancyContainer #wikiPage h6{font-size:.75em;margin:0 0 1.333em}#fancyContainer #wikiPage h1,#fancyContainer #wikiPage h2,#fancyContainer #wikiPage h3,#fancyContainer #wikiPage h4,#fancyContainer #wikiPage h5,#fancyContainer #wikiPage h6{font-weight:bold;padding:0;line-height:1.2;clear:left;color:#777;border-bottom:1px solid #777}#fancyContainer #wikiPageInfo{margin:1em 0;border-top:1px solid #607d8b;color:#607d8b}#fancyContainer #wikiPageInfo ul{list-style:none}#fancyContainer #wikiPageInfo li{float:left;padding:.5em}
|
||||
#box-popup #wikiPage{text-align:left;min-width:300px}#box-popup #wikiPage li,#box-popup #wikiPage ol{padding:0;margin:0 0 0 1.5em}#box-popup #wikiPage ul li{color:#999}#box-popup #wikiPage ol li{color:#666}#box-popup #wikiPage li .li{color:#333}#box-popup #wikiPage pre{overflow:auto;word-wrap:normal;border:1px solid #ccc;border-radius:2px;box-shadow:inset 0 0 .5em #ccc;padding:.7em 1em}#box-popup #wikiPage h1{font-size:2em;margin:0 0 .444em}#box-popup #wikiPage h2{font-size:1.5em;margin:0 0 .666em}#box-popup #wikiPage h3{font-size:1.125em;margin:0 0 .888em}#box-popup #wikiPage h4{font-size:1em;margin:0 0 1em}#box-popup #wikiPage h5{font-size:.875em;margin:0 0 1.1428em}#box-popup #wikiPage h6{font-size:.75em;margin:0 0 1.333em}#box-popup #wikiPage h1,#box-popup #wikiPage h2,#box-popup #wikiPage h3,#box-popup #wikiPage h4,#box-popup #wikiPage h5,#box-popup #wikiPage h6{font-weight:bold;padding:0;line-height:1.2;clear:left;color:#777;border-bottom:1px solid #777}#box-popup #wikiPageInfo{margin:1em 0;border-top:1px solid #607d8b;color:#607d8b}#box-popup #wikiPageInfo ul{list-style:none}#box-popup #wikiPageInfo li{float:left;padding:.5em}
|
||||
@@ -264,7 +264,7 @@ pre, code, samp, kbd {
|
||||
}
|
||||
|
||||
#content td.descField,
|
||||
#fancyContainer td.descField {
|
||||
#box-popup td.descField {
|
||||
text-align: right;
|
||||
padding-right: 20px;
|
||||
width: 25%;
|
||||
@@ -274,7 +274,7 @@ pre, code, samp, kbd {
|
||||
}
|
||||
|
||||
#content td.valField,
|
||||
#fancyContainer td.valField {
|
||||
#box-popup td.valField {
|
||||
padding-left: 1em;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -397,7 +397,7 @@ pre, code, samp, kbd {
|
||||
}
|
||||
|
||||
#content .data .list-wrap,
|
||||
#fancyContainer .list-wrap{
|
||||
#box-popup .list-wrap {
|
||||
max-height: 10em;
|
||||
overflow: auto;
|
||||
padding: .5em;
|
||||
@@ -405,14 +405,14 @@ pre, code, samp, kbd {
|
||||
}
|
||||
|
||||
#content .data .list-wrap ul,
|
||||
#fancyContainer .list-wrap ul{
|
||||
#box-popup .list-wrap ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0
|
||||
}
|
||||
|
||||
#content .data .list-wrap li,
|
||||
#fancyContainer .list-wrap li {
|
||||
#box-popup .list-wrap li {
|
||||
display: flex;
|
||||
background: #f2f2f2;
|
||||
padding: .5em;
|
||||
@@ -421,23 +421,23 @@ pre, code, samp, kbd {
|
||||
}
|
||||
|
||||
#content .data .list-wrap li:hover,
|
||||
#fancyContainer .list-wrap li:hover{
|
||||
#box-popup .list-wrap li:hover {
|
||||
background: #e8eaf6;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#content .data .list-wrap div.files-item-info,
|
||||
#fancyContainer .list-wrap div.files-item-info {
|
||||
#box-popup .list-wrap div.files-item-info {
|
||||
flex-grow: 2;
|
||||
}
|
||||
|
||||
#content .data .list-wrap div.files-item-info img,
|
||||
#fancyContainer .list-wrap div.files-item-info img{
|
||||
#box-popup .list-wrap div.files-item-info img {
|
||||
margin: 0 .5em;
|
||||
}
|
||||
|
||||
#content .data .list-wrap div.files-item-actions,
|
||||
#fancyContainer .list-wrap div.files-item-actions{
|
||||
#box-popup .list-wrap div.files-item-actions {
|
||||
padding: .3em 0;
|
||||
}
|
||||
|
||||
@@ -921,7 +921,7 @@ pre, code, samp, kbd {
|
||||
color: #555
|
||||
}
|
||||
|
||||
#fancyContainer {
|
||||
#box-popup {
|
||||
min-width: 25em;
|
||||
max-width: 50em;
|
||||
margin: 5em auto;
|
||||
@@ -929,7 +929,12 @@ pre, code, samp, kbd {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
#fancyContainer > h2 {
|
||||
#box-popup.box-password-view {
|
||||
min-width: 20em;
|
||||
max-width: 25em;
|
||||
}
|
||||
|
||||
#box-popup > h2 {
|
||||
width: 100%;
|
||||
font-size: 18px;
|
||||
color: white;
|
||||
@@ -939,50 +944,50 @@ pre, code, samp, kbd {
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
#fancyContainer > table {
|
||||
#box-popup > table {
|
||||
width: 100%;
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
#fancyContainer select {
|
||||
#box-popup select {
|
||||
width: 220px
|
||||
}
|
||||
|
||||
#fancyContainer #resFancyAccion {
|
||||
#box-popup #resFancyAccion {
|
||||
display: none
|
||||
}
|
||||
|
||||
#fancyContainer #resCheck {
|
||||
#box-popup #resCheck {
|
||||
display: inline-block;
|
||||
width: 80%;
|
||||
height: 4em;
|
||||
padding: 1em 0
|
||||
}
|
||||
|
||||
#fancyContainer.image {
|
||||
#box-popup.image {
|
||||
background-color: transparent;
|
||||
max-width: 100%;
|
||||
margin: 0 auto;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
#fancyContainer.image img {
|
||||
#box-popup.image img {
|
||||
width: auto;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#fancyContainer.image > div.title {
|
||||
#box-popup.image > div.title {
|
||||
background-color: #607d8b;
|
||||
color: #fff;
|
||||
padding: .5em;
|
||||
}
|
||||
|
||||
#fancyContainer.help {
|
||||
#box-popup.help {
|
||||
min-height: 100px;
|
||||
background-color: #f5f5f5
|
||||
}
|
||||
|
||||
#fancyContainer.help p {
|
||||
#box-popup.help p {
|
||||
font-size: 14px;
|
||||
text-align: justify;
|
||||
line-height: 2em
|
||||
|
||||
2
inc/themes/material-blue/css/styles.min.css
vendored
2
inc/themes/material-blue/css/styles.min.css
vendored
File diff suppressed because one or more lines are too long
@@ -2,8 +2,8 @@
|
||||
/** @var \SP\DataModel\CategoryData $category */
|
||||
/** @var \SP\Core\UI\ThemeIconsBase $icons */
|
||||
?>
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></h2>
|
||||
<div id="box-popup" class="box-password-view">
|
||||
<h2 class="center"><?php echo $header; ?></h2>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/** @var \SP\DataModel\CategoryData $category */
|
||||
/** @var \SP\Core\UI\ThemeIconsBase $icons */
|
||||
?>
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></h2>
|
||||
<div id="box-popup">
|
||||
<h2 class="center"><?php echo $header; ?></h2>
|
||||
|
||||
<form method="post" name="frmCategories" id="frmCategories" class="form-action"
|
||||
data-onsubmit="appMgmt/save"
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
?>
|
||||
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></H2>
|
||||
<div id="box-popup">
|
||||
<h2 class="center"><?php echo $header; ?></H2>
|
||||
|
||||
<form method="post" name="frmCustomers" id="frmCustomers" class="form-action"
|
||||
data-onsubmit="appMgmt/save"
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
?>
|
||||
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></H2>
|
||||
<div id="box-popup">
|
||||
<h2 class="center"><?php echo $header; ?></H2>
|
||||
|
||||
<form method="post" name="frmCustomFields" id="frmCustomFields" class="form-action"
|
||||
data-onsubmit="appMgmt/save"
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
/** @var $groupUsers \SP\DataModel\GroupUsersData */
|
||||
?>
|
||||
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></H2>
|
||||
<div id="box-popup">
|
||||
<h2 class="center"><?php echo $header; ?></H2>
|
||||
|
||||
<form method="post" name="frmGroups" id="frmGroups" class="form-action"
|
||||
data-onsubmit="appMgmt/save"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
/** @var $profile \SP\DataModel\ProfileData */
|
||||
?>
|
||||
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></H2>
|
||||
<div id="box-popup">
|
||||
<h2 class="center"><?php echo $header; ?></H2>
|
||||
|
||||
<form method="post" name="frmProfiles" id="frmProfiles" class="form-action"
|
||||
data-onsubmit="appMgmt/save"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* @var $link SP\DataModel\PublicLinkListData
|
||||
*/
|
||||
?>
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></H2>
|
||||
<div id="box-popup">
|
||||
<h2 class="center"><?php echo $header; ?></H2>
|
||||
<table class="fancydata">
|
||||
<tbody>
|
||||
<tr>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/** @var $tag \SP\DataModel\TagData */
|
||||
/** @var $icons \SP\Core\UI\ThemeIconsBase */
|
||||
?>
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></h2>
|
||||
<div id="box-popup">
|
||||
<h2 class="center"><?php echo $header; ?></h2>
|
||||
|
||||
<form method="post" name="frmTags" id="frmTags" class="form-action"
|
||||
data-onsubmit="appMgmt/save"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></H2>
|
||||
<div id="box-popup">
|
||||
<h2 class="center"><?php echo $header; ?></H2>
|
||||
|
||||
<form method="post" name="frmTokens" id="frmTokens" class="form-action"
|
||||
data-onsubmit="appMgmt/save"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
/** @var $user \SP\DataModel\UserData */
|
||||
?>
|
||||
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></h2>
|
||||
<div id="box-popup">
|
||||
<h2 class="center"><?php echo $header; ?></h2>
|
||||
|
||||
<form method="post" name="frmUsers" id="frmUsers" class="form-action"
|
||||
data-onsubmit="appMgmt/save"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
/** @var $user \SP\DataModel\UserData */
|
||||
?>
|
||||
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></h2>
|
||||
<div id="box-popup">
|
||||
<h2 class="center"><?php echo $header; ?></h2>
|
||||
|
||||
<form method="post" name="updUsrPass" id="frmUpdUsrPass" class="form-action" data-onsubmit="appMgmt/save">
|
||||
<table class="fancydata">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2 class="midround"><?php echo (is_array($header) && !empty($header[0])) ? $header[0] : _('Ver Wiki'); ?></h2>
|
||||
<div id="box-popup">
|
||||
<h2 class="center"><?php echo (is_array($header) && !empty($header[0])) ? $header[0] : _('Ver Wiki'); ?></h2>
|
||||
|
||||
<div id="wikiPage">
|
||||
<?php if (is_array($pageData) && !empty($pageData[0])): ?>
|
||||
|
||||
@@ -133,7 +133,7 @@ sysPass.Actions = function (Common) {
|
||||
},
|
||||
callbacks: {
|
||||
open: function () {
|
||||
Common.appTriggers().views.common("#fancyContainer");
|
||||
Common.appTriggers().views.common("#box-popup");
|
||||
},
|
||||
close: function () {
|
||||
if ($obj.data("item-dst")) {
|
||||
|
||||
56
js/app-actions.min.js
vendored
56
js/app-actions.min.js
vendored
@@ -4,31 +4,31 @@ $jscomp.polyfill("Array.prototype.find",function(c){return c?c:function(c,h){ret
|
||||
sysPass.Actions=function(c){var d=c.log,h=0,e={doAction:"/ajax/ajax_getContent.php",updateItems:"/ajax/ajax_getItems.php",user:{savePreferences:"/ajax/ajax_userPrefsSave.php",password:"/ajax/ajax_usrpass.php",passreset:"/ajax/ajax_passReset.php"},main:{login:"/ajax/ajax_doLogin.php",install:"/ajax/ajax_install.php",twofa:"/ajax/ajax_2fa.php",getUpdates:"/ajax/ajax_checkUpds.php"},checks:"/ajax/ajax_checkConnection.php",config:{save:"/ajax/ajax_configSave.php","export":"/ajax/ajax_export.php","import":"/ajax/ajax_import.php"},
|
||||
file:"/ajax/ajax_filesMgmt.php",link:"/ajax/ajax_itemSave.php",account:{save:"/ajax/ajax_itemSave.php",showPass:"/ajax/ajax_accViewPass.php",saveFavorite:"/ajax/ajax_itemSave.php",request:"/ajax/ajax_sendRequest.php",getFiles:"/ajax/ajax_accGetFiles.php",search:"/ajax/ajax_accSearch.php"},appMgmt:{show:"/ajax/ajax_itemShow.php",save:"/ajax/ajax_itemSave.php",search:"/ajax/ajax_itemSearch.php"},eventlog:"/ajax/ajax_eventlog.php",wiki:{show:"/ajax/ajax_wiki.php"}},g=function(a){a={actionId:a.actionId,
|
||||
itemId:"undefined"!==typeof a.itemId?a.itemId:0,isAjax:1};var b=c.appRequests().getRequestOpts();b.url=e.doAction;b.type="html";b.addHistory=!0;b.data=a;c.appRequests().getActionCall(b,function(a){$("#content").empty().html(a)})},m=function(a){d.info("updateItems");var b=$("#"+a.data("item-dst"))[0].selectize;b.clearOptions();b.load(function(b){var f=c.appRequests().getRequestOpts();f.url=e.updateItems;f.method="get";f.data={sk:c.sk.get(),itemType:a.data("item-type")};c.appRequests().getActionCall(f,
|
||||
function(a){b(a.items)})})},p=function(a,b){$.magnificPopup.open({items:{src:b,type:"inline"},callbacks:{open:function(){c.appTriggers().views.common("#fancyContainer")},close:function(){a.data("item-dst")&&m(a)}},showCloseBtn:!1})},r=function(a,b){var f=$('<div id="fancyContainer" class="image">'+b+"</div>"),d=f.find("img");d.hide();$.magnificPopup.open({items:{src:f,type:"inline"},callbacks:{open:function(){var a=this;d.on("click",function(){a.close()});setTimeout(function(){var a=c.resizeImage(d);
|
||||
f.css({backgroundColor:"#fff",width:a.width,height:"auto"});d.show("slow")},500)}}})},q={logout:function(){var a=window.location.search;c.redirect(0<a.length?"index.php"+a+"&logout=1":"index.php?logout=1")},login:function(a){d.info("main:login");var b=c.appRequests().getRequestOpts();b.url=e.main.login;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){switch(b.status){case 0:c.redirect(b.data.url);break;case 2:c.msg.out(b);a.find("input[type='text'],input[type='password']").val("");
|
||||
a.find("input:first").focus();$("#mpass").prop("disabled",!1).val("");$("#smpass").show();break;case 5:c.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();$("#oldpass").prop("disabled",!1).val("");$("#soldpass").show();break;default:c.msg.out(b),a.find("input[type='text'],input[type='password']").val(""),a.find("input:first").focus()}})},install:function(a){d.info("main:install");var b=c.appRequests().getRequestOpts();b.url=e.main.install;b.data=
|
||||
a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0==a.status&&setTimeout(function(){c.redirect("index.php")},1E3)})},twofa:function(a){d.info("main:twofa");var b=c.appRequests().getRequestOpts();b.url=e.main.twofa;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0==a.status&&setTimeout(function(){c.redirect("index.php")},1E3)})},getUpdates:function(a){d.info("main:getUpdates");a=c.appRequests().getRequestOpts();a.url=e.main.getUpdates;a.type="html";
|
||||
a.method="get";a.timeout=1E4;a.useLoading=!1;a.data={isAjax:1};c.appRequests().getActionCall(a,function(a){$("#updates").html(a);"undefined"!==typeof componentHandler&&componentHandler.upgradeDom()},function(){$("#updates").html("!")})}},l={show:function(a){d.info("account:show");g({actionId:a.data("action-id"),itemId:a.data("item-id")})},showHistory:function(a){d.info("account:showHistory");g({actionId:a.data("action-id"),itemId:a.val()})},edit:function(a){d.info("account:edit");g({actionId:a.data("action-id"),
|
||||
itemId:a.data("item-id")})},"delete":function(a){d.info("account:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[3]+"</p></div>";showDialog({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b=c.appRequests().getRequestOpts();b.url=e.account.save;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(a){c.msg.out(a);
|
||||
l.search()})}}})},showpass:function(a){d.info("account:showpass");var b=a.data("parent-id"),f=c.appRequests().getRequestOpts();f.url=e.appMgmt.show;f.data={itemId:0==b?a.data("item-id"):b,actionId:a.data("action-id"),isHistory:a.data("history"),isFull:1,sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(f,function(b){0!==b.status?c.msg.out(b):(b=$(b.data.html),p(a,b),b.on("mouseleave",function(){clearTimeout(h);h=setTimeout(function(){$.magnificPopup.close()},3E4)}).on("mouseenter",function(){0!==
|
||||
h&&clearTimeout(h)}))})},copypass:function(a){d.info("account:copypass");var b=a.data("parent-id"),f=c.appRequests().getRequestOpts();f.url=e.appMgmt.show;f.async=!1;f.data={itemId:0==b?a.data("item-id"):b,actionId:a.data("action-id"),isHistory:a.data("history"),isFull:0,sk:c.sk.get(),isAjax:1};a=c.appRequests().getActionCall(f);"undefined"!==typeof a.responseJSON.csrf&&c.sk.set(a.responseJSON.csrf);return a},copy:function(a){d.info("account:copy");g({actionId:a.data("action-id"),itemId:a.data("item-id")})},
|
||||
savefavorite:function(a,b){d.info("account:saveFavorite");var f="on"===a.data("status"),k={actionId:f?a.data("action-id-off"):a.data("action-id-on"),itemId:a.data("item-id"),sk:c.sk.get(),isAjax:1},g=c.appRequests().getRequestOpts();g.url=e.account.saveFavorite;g.data=k;c.appRequests().getActionCall(g,function(d){c.msg.out(d);0===d.status&&(a.data("status",f?"off":"on"),"function"===typeof b&&b())})},request:function(a){d.info("account:request");var b=c.appRequests().getRequestOpts();b.url=e.account.request;
|
||||
b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},menu:function(a){a.hide();a.parent().children(".actions-optional").show(250)},sort:function(a){d.info("account:sort");var c=$("#frmSearch");c.find('input[name="skey"]').val(a.data("key"));c.find('input[name="sorder"]').val(a.data("dir"));c.find('input[name="start"]').val(a.data("start"));l.search()},editpass:function(a){d.info("account:editpass");var c=a.data("parent-id");g({actionId:a.data("action-id"),itemId:0==c?a.data("item-id"):
|
||||
c})},restore:function(a){d.info("account:restore");l.save(a)},getfiles:function(a){d.info("account:getfiles");var b=c.appRequests().getRequestOpts();b.method="get";b.type="html";b.url=e.account.getFiles;b.data={id:a.data("item-id"),del:a.data("delete"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(c){a.html(c)})},search:function(){d.info("account:search");var a=$("#frmSearch");a.find("input[name='sk']").val(c.sk.get());a.find("input[name='skey']").val();a.find("input[name='sorder']").val();
|
||||
var b=c.appRequests().getRequestOpts();b.url=e.account.search;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){10===b.status&&c.msg.out(b);c.sk.set(b.sk);$("#res-content").empty().html(b.html);a.find("input:first").focus()})},save:function(a){d.info("account:save");var b=c.appRequests().getRequestOpts();b.url=e.account.save;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},n={refreshTab:!0,show:function(a){d.info("appMgmt:show");if(a.data("item-dst")||
|
||||
!a.data("activetab"))n.refreshTab=!1;var b=c.appRequests().getRequestOpts();b.url=e.appMgmt.show;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),activeTab:a.data("activetab"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(b){0!==b.status?c.msg.out(b):p(a,b.data.html)})},"delete":function(a){d.info("appMgmt:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[12]+"</p></div>",f=a.data("selection"),k=[];if(f&&($(f).find(".is-selected").each(function(a,
|
||||
c){var b=$(this);k.push(b.data("item-id"))}),0===k.length))return;showDialog({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b.preventDefault();b=c.appRequests().getRequestOpts();b.url=e.appMgmt.save;b.data={itemId:f?k:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(b){c.msg.out(b);a.data("nextaction-id")&&g({actionId:a.data("nextaction-id"),
|
||||
itemId:a.data("activetab")})})}}})},save:function(a){d.info("appMgmt:save");var b=c.appRequests().getRequestOpts();b.url=e.appMgmt.save;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&(!0===n.refreshTab&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")}),$.magnificPopup.close())})},search:function(a){d.info("appMgmt:search");var b=$(a.data("target")),f=c.appRequests().getRequestOpts();f.url=e.appMgmt.search;f.data=a.serialize();c.appRequests().getActionCall(f,
|
||||
function(a){0===a.status?b.html(a.data.html):b.html(c.msg.html.error(a.description));c.sk.set(a.csrf)})},nav:function(a){d.info("appMgmt:nav");var b=$("#"+a.data("action-form"));b.find("[name='start']").val(a.data("start"));b.find("[name='count']").val(a.data("count"));b.find("[name='sk']").val(c.sk.get());n.search(b)},ldapSync:function(a){d.info("appMgmt:ldapSync");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[57]+"</p></div>";showDialog({text:b,negative:{title:c.config().LANG[44],
|
||||
onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b=c.appRequests().getRequestOpts();b.url=e.appMgmt.save;b.data={actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}}})}};return{doAction:g,appMgmt:n,account:l,file:{view:function(a){d.info("file:view");var b=c.appRequests().getRequestOpts();b.url=e.file;b.type="html";b.data={fileId:a.data("item-id"),sk:c.sk.get(),
|
||||
actionId:a.data("action-id")};c.appRequests().getActionCall(b,function(b){"undefined"!==typeof b.status&&1===b.status?c.msg.out(b):b?r(a,b):c.msg.error(c.config().LANG[14])})},download:function(a){d.info("file:download");a={fileId:a.data("item-id"),sk:c.sk.get(),actionId:a.data("action-id")};$.fileDownload(c.config().APP_ROOT+e.file,{httpMethod:"POST",data:a})},"delete":function(a){d.info("file:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[15]+"</p></div>";showDialog({text:b,
|
||||
negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b=c.appRequests().getRequestOpts();b.url=e.file;b.data={fileId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&(a=$("#list-account-files"),l.getfiles(a))})}}})}},checks:{ldap:function(a){d.info("checks:ldap");a=$(a.data("src"));a.find("[name='sk']").val(c.sk.get());
|
||||
var b=c.appRequests().getRequestOpts();b.url=e.checks;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);var b=$("#ldap-results");b.find(".list-wrap").html(c.appTheme().html.getList(a.data));b.show("slow")})},wiki:function(a){d.info("checks:wiki");a=$(a.data("src"));a.find("[name='sk']").val(c.sk.get());var b=c.appRequests().getRequestOpts();b.url=e.checks;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&$("#dokuWikiResCheck").html(a.data)})}},
|
||||
config:{save:function(a){d.info("config:save");var b=c.appRequests().getRequestOpts();b.url=e.config.save;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},backup:function(a){d.info("config:backup");var b=c.appRequests().getRequestOpts();b.url=e.config["export"];b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===
|
||||
b.status&&"undefined"!==typeof a.data("nextaction-id")&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},"export":function(a){d.info("config:export");var b=c.appRequests().getRequestOpts();b.url=e.config["export"];b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},"import":function(a){d.info("config:import");var b=c.appRequests().getRequestOpts();
|
||||
b.url=e.config["import"];b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})}},main:q,user:{savePreferences:function(a){d.info("user:savePreferences");var b=c.appRequests().getRequestOpts();b.url=e.user.savePreferences;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);setTimeout(function(){window.location.replace("index.php")},
|
||||
2E3)})},saveSecurity:function(a){d.info("user:saveSecurity");var b=c.appRequests().getRequestOpts();b.url=e.user.savePreferences;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},password:function(a){d.info("user:password");var b=c.appRequests().getRequestOpts();b.type="html";b.method="get";b.url=e.user.password;b.data={actionId:a.data("action-id"),itemId:a.data("item-id"),sk:a.data("sk"),isAjax:1};c.appRequests().getActionCall(b,
|
||||
function(b){0===b.length?q.logout():p(a,b)})},passreset:function(a){d.info("user:passreset");var b=c.appRequests().getRequestOpts();b.url=e.user.passreset;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},link:{save:function(a){d.info("link:save");var b=c.appRequests().getRequestOpts();b.url=e.link;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};a='<div id="alert"><p id="alert-text">'+c.config().LANG[48]+"</p></div>";showDialog({text:a,
|
||||
negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},positive:{title:c.config().LANG[43],onClick:function(a){a.preventDefault();b.data.notify=1;c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}}})},refresh:function(a){d.info("link:refresh");var b={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),activeTab:a.data("activetab")},f=c.appRequests().getRequestOpts();f.url=e.link;f.data=b;c.appRequests().getActionCall(f,
|
||||
function(b){c.msg.out(b);0===b.status&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})}},eventlog:{nav:function(a){if("undefined"===typeof a.data("start"))return!1;var b=c.appRequests().getRequestOpts();b.url=e.eventlog;b.type="html";b.data={start:a.data("start"),current:a.data("current")};c.appRequests().getActionCall(b,function(a){$("#content").html(a);c.scrollUp()})},clear:function(a){var b='<div id="alert"><p id="alert-text">'+c.config().LANG[20]+"</p></div>";showDialog({text:b,
|
||||
negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b.preventDefault();b=c.appRequests().getRequestOpts();b.url=e.eventlog;b.data={clear:1,sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(b){c.msg.out(b);0==b.status&&g({actionId:a.data("nextaction-id")})})}}})}},ajaxUrl:e}};
|
||||
function(a){b(a.items)})})},p=function(a,b){$.magnificPopup.open({items:{src:b,type:"inline"},callbacks:{open:function(){c.appTriggers().views.common("#box-popup")},close:function(){a.data("item-dst")&&m(a)}},showCloseBtn:!1})},r=function(a,b){var f=$('<div id="fancyContainer" class="image">'+b+"</div>"),d=f.find("img");d.hide();$.magnificPopup.open({items:{src:f,type:"inline"},callbacks:{open:function(){var a=this;d.on("click",function(){a.close()});setTimeout(function(){var a=c.resizeImage(d);f.css({backgroundColor:"#fff",
|
||||
width:a.width,height:"auto"});d.show("slow")},500)}}})},q={logout:function(){var a=window.location.search;c.redirect(0<a.length?"index.php"+a+"&logout=1":"index.php?logout=1")},login:function(a){d.info("main:login");var b=c.appRequests().getRequestOpts();b.url=e.main.login;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){switch(b.status){case 0:c.redirect(b.data.url);break;case 2:c.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();
|
||||
$("#mpass").prop("disabled",!1).val("");$("#smpass").show();break;case 5:c.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();$("#oldpass").prop("disabled",!1).val("");$("#soldpass").show();break;default:c.msg.out(b),a.find("input[type='text'],input[type='password']").val(""),a.find("input:first").focus()}})},install:function(a){d.info("main:install");var b=c.appRequests().getRequestOpts();b.url=e.main.install;b.data=a.serialize();c.appRequests().getActionCall(b,
|
||||
function(a){c.msg.out(a);0==a.status&&setTimeout(function(){c.redirect("index.php")},1E3)})},twofa:function(a){d.info("main:twofa");var b=c.appRequests().getRequestOpts();b.url=e.main.twofa;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0==a.status&&setTimeout(function(){c.redirect("index.php")},1E3)})},getUpdates:function(a){d.info("main:getUpdates");a=c.appRequests().getRequestOpts();a.url=e.main.getUpdates;a.type="html";a.method="get";a.timeout=1E4;a.useLoading=!1;
|
||||
a.data={isAjax:1};c.appRequests().getActionCall(a,function(a){$("#updates").html(a);"undefined"!==typeof componentHandler&&componentHandler.upgradeDom()},function(){$("#updates").html("!")})}},l={show:function(a){d.info("account:show");g({actionId:a.data("action-id"),itemId:a.data("item-id")})},showHistory:function(a){d.info("account:showHistory");g({actionId:a.data("action-id"),itemId:a.val()})},edit:function(a){d.info("account:edit");g({actionId:a.data("action-id"),itemId:a.data("item-id")})},"delete":function(a){d.info("account:delete");
|
||||
var b='<div id="alert"><p id="alert-text">'+c.config().LANG[3]+"</p></div>";showDialog({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b=c.appRequests().getRequestOpts();b.url=e.account.save;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(a){c.msg.out(a);l.search()})}}})},showpass:function(a){d.info("account:showpass");
|
||||
var b=a.data("parent-id"),f=c.appRequests().getRequestOpts();f.url=e.appMgmt.show;f.data={itemId:0==b?a.data("item-id"):b,actionId:a.data("action-id"),isHistory:a.data("history"),isFull:1,sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(f,function(b){0!==b.status?c.msg.out(b):(b=$(b.data.html),p(a,b),b.on("mouseleave",function(){clearTimeout(h);h=setTimeout(function(){$.magnificPopup.close()},3E4)}).on("mouseenter",function(){0!==h&&clearTimeout(h)}))})},copypass:function(a){d.info("account:copypass");
|
||||
var b=a.data("parent-id"),f=c.appRequests().getRequestOpts();f.url=e.appMgmt.show;f.async=!1;f.data={itemId:0==b?a.data("item-id"):b,actionId:a.data("action-id"),isHistory:a.data("history"),isFull:0,sk:c.sk.get(),isAjax:1};a=c.appRequests().getActionCall(f);"undefined"!==typeof a.responseJSON.csrf&&c.sk.set(a.responseJSON.csrf);return a},copy:function(a){d.info("account:copy");g({actionId:a.data("action-id"),itemId:a.data("item-id")})},savefavorite:function(a,b){d.info("account:saveFavorite");var f=
|
||||
"on"===a.data("status"),k={actionId:f?a.data("action-id-off"):a.data("action-id-on"),itemId:a.data("item-id"),sk:c.sk.get(),isAjax:1},g=c.appRequests().getRequestOpts();g.url=e.account.saveFavorite;g.data=k;c.appRequests().getActionCall(g,function(d){c.msg.out(d);0===d.status&&(a.data("status",f?"off":"on"),"function"===typeof b&&b())})},request:function(a){d.info("account:request");var b=c.appRequests().getRequestOpts();b.url=e.account.request;b.data=a.serialize();c.appRequests().getActionCall(b,
|
||||
function(a){c.msg.out(a)})},menu:function(a){a.hide();a.parent().children(".actions-optional").show(250)},sort:function(a){d.info("account:sort");var c=$("#frmSearch");c.find('input[name="skey"]').val(a.data("key"));c.find('input[name="sorder"]').val(a.data("dir"));c.find('input[name="start"]').val(a.data("start"));l.search()},editpass:function(a){d.info("account:editpass");var c=a.data("parent-id");g({actionId:a.data("action-id"),itemId:0==c?a.data("item-id"):c})},restore:function(a){d.info("account:restore");
|
||||
l.save(a)},getfiles:function(a){d.info("account:getfiles");var b=c.appRequests().getRequestOpts();b.method="get";b.type="html";b.url=e.account.getFiles;b.data={id:a.data("item-id"),del:a.data("delete"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(c){a.html(c)})},search:function(){d.info("account:search");var a=$("#frmSearch");a.find("input[name='sk']").val(c.sk.get());a.find("input[name='skey']").val();a.find("input[name='sorder']").val();var b=c.appRequests().getRequestOpts();b.url=e.account.search;
|
||||
b.data=a.serialize();c.appRequests().getActionCall(b,function(b){10===b.status&&c.msg.out(b);c.sk.set(b.sk);$("#res-content").empty().html(b.html);a.find("input:first").focus()})},save:function(a){d.info("account:save");var b=c.appRequests().getRequestOpts();b.url=e.account.save;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},n={refreshTab:!0,show:function(a){d.info("appMgmt:show");if(a.data("item-dst")||!a.data("activetab"))n.refreshTab=!1;var b=c.appRequests().getRequestOpts();
|
||||
b.url=e.appMgmt.show;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),activeTab:a.data("activetab"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(b){0!==b.status?c.msg.out(b):p(a,b.data.html)})},"delete":function(a){d.info("appMgmt:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[12]+"</p></div>",f=a.data("selection"),k=[];if(f&&($(f).find(".is-selected").each(function(a,c){var b=$(this);k.push(b.data("item-id"))}),0===k.length))return;showDialog({text:b,
|
||||
negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b.preventDefault();b=c.appRequests().getRequestOpts();b.url=e.appMgmt.save;b.data={itemId:f?k:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(b){c.msg.out(b);a.data("nextaction-id")&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})}}})},save:function(a){d.info("appMgmt:save");
|
||||
var b=c.appRequests().getRequestOpts();b.url=e.appMgmt.save;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&(!0===n.refreshTab&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")}),$.magnificPopup.close())})},search:function(a){d.info("appMgmt:search");var b=$(a.data("target")),f=c.appRequests().getRequestOpts();f.url=e.appMgmt.search;f.data=a.serialize();c.appRequests().getActionCall(f,function(a){0===a.status?b.html(a.data.html):b.html(c.msg.html.error(a.description));
|
||||
c.sk.set(a.csrf)})},nav:function(a){d.info("appMgmt:nav");var b=$("#"+a.data("action-form"));b.find("[name='start']").val(a.data("start"));b.find("[name='count']").val(a.data("count"));b.find("[name='sk']").val(c.sk.get());n.search(b)},ldapSync:function(a){d.info("appMgmt:ldapSync");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[57]+"</p></div>";showDialog({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],
|
||||
onClick:function(b){b=c.appRequests().getRequestOpts();b.url=e.appMgmt.save;b.data={actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}}})}};return{doAction:g,appMgmt:n,account:l,file:{view:function(a){d.info("file:view");var b=c.appRequests().getRequestOpts();b.url=e.file;b.type="html";b.data={fileId:a.data("item-id"),sk:c.sk.get(),actionId:a.data("action-id")};c.appRequests().getActionCall(b,function(b){"undefined"!==typeof b.status&&
|
||||
1===b.status?c.msg.out(b):b?r(a,b):c.msg.error(c.config().LANG[14])})},download:function(a){d.info("file:download");a={fileId:a.data("item-id"),sk:c.sk.get(),actionId:a.data("action-id")};$.fileDownload(c.config().APP_ROOT+e.file,{httpMethod:"POST",data:a})},"delete":function(a){d.info("file:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[15]+"</p></div>";showDialog({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},
|
||||
positive:{title:c.config().LANG[43],onClick:function(b){b=c.appRequests().getRequestOpts();b.url=e.file;b.data={fileId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&(a=$("#list-account-files"),l.getfiles(a))})}}})}},checks:{ldap:function(a){d.info("checks:ldap");a=$(a.data("src"));a.find("[name='sk']").val(c.sk.get());var b=c.appRequests().getRequestOpts();b.url=e.checks;b.data=a.serialize();c.appRequests().getActionCall(b,
|
||||
function(a){c.msg.out(a);var b=$("#ldap-results");b.find(".list-wrap").html(c.appTheme().html.getList(a.data));b.show("slow")})},wiki:function(a){d.info("checks:wiki");a=$(a.data("src"));a.find("[name='sk']").val(c.sk.get());var b=c.appRequests().getRequestOpts();b.url=e.checks;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&$("#dokuWikiResCheck").html(a.data)})}},config:{save:function(a){d.info("config:save");var b=c.appRequests().getRequestOpts();b.url=
|
||||
e.config.save;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},backup:function(a){d.info("config:backup");var b=c.appRequests().getRequestOpts();b.url=e.config["export"];b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&g({actionId:a.data("nextaction-id"),
|
||||
itemId:a.data("activetab")})})},"export":function(a){d.info("config:export");var b=c.appRequests().getRequestOpts();b.url=e.config["export"];b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},"import":function(a){d.info("config:import");var b=c.appRequests().getRequestOpts();b.url=e.config["import"];b.data=a.serialize();c.appRequests().getActionCall(b,
|
||||
function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})}},main:q,user:{savePreferences:function(a){d.info("user:savePreferences");var b=c.appRequests().getRequestOpts();b.url=e.user.savePreferences;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);setTimeout(function(){window.location.replace("index.php")},2E3)})},saveSecurity:function(a){d.info("user:saveSecurity");var b=c.appRequests().getRequestOpts();
|
||||
b.url=e.user.savePreferences;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},password:function(a){d.info("user:password");var b=c.appRequests().getRequestOpts();b.type="html";b.method="get";b.url=e.user.password;b.data={actionId:a.data("action-id"),itemId:a.data("item-id"),sk:a.data("sk"),isAjax:1};c.appRequests().getActionCall(b,function(b){0===b.length?q.logout():p(a,b)})},passreset:function(a){d.info("user:passreset");
|
||||
var b=c.appRequests().getRequestOpts();b.url=e.user.passreset;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},link:{save:function(a){d.info("link:save");var b=c.appRequests().getRequestOpts();b.url=e.link;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};a='<div id="alert"><p id="alert-text">'+c.config().LANG[48]+"</p></div>";showDialog({text:a,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.appRequests().getActionCall(b,
|
||||
function(a){c.msg.out(a)})}},positive:{title:c.config().LANG[43],onClick:function(a){a.preventDefault();b.data.notify=1;c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}}})},refresh:function(a){d.info("link:refresh");var b={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),activeTab:a.data("activetab")},f=c.appRequests().getRequestOpts();f.url=e.link;f.data=b;c.appRequests().getActionCall(f,function(b){c.msg.out(b);0===b.status&&g({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})}},
|
||||
eventlog:{nav:function(a){if("undefined"===typeof a.data("start"))return!1;var b=c.appRequests().getRequestOpts();b.url=e.eventlog;b.type="html";b.data={start:a.data("start"),current:a.data("current")};c.appRequests().getActionCall(b,function(a){$("#content").html(a);c.scrollUp()})},clear:function(a){var b='<div id="alert"><p id="alert-text">'+c.config().LANG[20]+"</p></div>";showDialog({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},
|
||||
positive:{title:c.config().LANG[43],onClick:function(b){b.preventDefault();b=c.appRequests().getRequestOpts();b.url=e.eventlog;b.data={clear:1,sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(b){c.msg.out(b);0==b.status&&g({actionId:a.data("nextaction-id")})})}}})}},ajaxUrl:e}};
|
||||
|
||||
Reference in New Issue
Block a user