mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-23 08:46:49 +01:00
[ADD] New search box for management grids.
This commit is contained in:
@@ -23,9 +23,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use SP\Controller\ItemMgmt;
|
||||
use SP\Controller\ItemsMgmt;
|
||||
use SP\Controller\UsersMgmt;
|
||||
use SP\Controller\AccItemMgmt;
|
||||
use SP\Controller\AppItemMgmt;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\Template;
|
||||
@@ -61,133 +60,133 @@ switch ($actionId) {
|
||||
$Tpl->assign('header', _('Ver Usuario'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Tpl->assign('isView', true);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getUser();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_USERS_EDIT:
|
||||
$Tpl->assign('header', _('Editar Usuario'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getUser();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_USERS_NEW:
|
||||
$Tpl->assign('header', _('Nuevo Usuario'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getUser();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_GROUPS_VIEW:
|
||||
$Tpl->assign('header', _('Ver Grupo'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Tpl->assign('isView', true);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getGroup();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_GROUPS_EDIT:
|
||||
$Tpl->assign('header', _('Editar Grupo'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getGroup();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_GROUPS_NEW:
|
||||
$Tpl->assign('header', _('Nuevo Grupo'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getGroup();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_PROFILES_VIEW:
|
||||
$Tpl->assign('header', _('Ver Perfil'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Tpl->assign('isView', true);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getProfile();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_PROFILES_EDIT:
|
||||
$Tpl->assign('header', _('Editar Perfil'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getProfile();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_PROFILES_NEW:
|
||||
$Tpl->assign('header', _('Nuevo Perfil'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getProfile();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_VIEW:
|
||||
$Tpl->assign('header', _('Ver Cliente'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_MGM);
|
||||
$Tpl->assign('isView', true);
|
||||
$Controller = new ItemMgmt($Tpl);
|
||||
$Controller = new AppItemMgmt($Tpl);
|
||||
$Controller->getCustomer();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_EDIT:
|
||||
$Tpl->assign('header', _('Editar Cliente'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_MGM);
|
||||
$Controller = new ItemMgmt($Tpl);
|
||||
$Controller = new AppItemMgmt($Tpl);
|
||||
$Controller->getCustomer();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMERS_NEW:
|
||||
$Tpl->assign('header', _('Nuevo Cliente'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_MGM);
|
||||
$Controller = new ItemMgmt($Tpl);
|
||||
$Controller = new AppItemMgmt($Tpl);
|
||||
$Controller->getCustomer();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_VIEW:
|
||||
$Tpl->assign('header', _('Ver Categoría'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_MGM);
|
||||
$Tpl->assign('isView', true);
|
||||
$Controller = new ItemMgmt($Tpl);
|
||||
$Controller = new AppItemMgmt($Tpl);
|
||||
$Controller->getCategory();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_EDIT:
|
||||
$Tpl->assign('header', _('Editar Categoría'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_MGM);
|
||||
$Controller = new ItemMgmt($Tpl);
|
||||
$Controller = new AppItemMgmt($Tpl);
|
||||
$Controller->getCategory();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CATEGORIES_NEW:
|
||||
$Tpl->assign('header', _('Nueva Categoría'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_MGM);
|
||||
$Controller = new ItemMgmt($Tpl);
|
||||
$Controller = new AppItemMgmt($Tpl);
|
||||
$Controller->getCategory();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS_VIEW:
|
||||
$Tpl->assign('header', _('Ver Autorización'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Tpl->assign('isView', true);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getToken();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS_NEW:
|
||||
$Tpl->assign('header', _('Nueva Autorización'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getToken();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS_EDIT:
|
||||
$Tpl->assign('header', _('Editar Autorización'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getToken();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS_NEW:
|
||||
$Tpl->assign('header', _('Nuevo Campo'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_MGM);
|
||||
$Controller = new ItemMgmt($Tpl);
|
||||
$Controller = new AppItemMgmt($Tpl);
|
||||
$Controller->getCustomField();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS_EDIT:
|
||||
$Tpl->assign('header', _('Editar Campo'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_MGM);
|
||||
$Controller = new ItemMgmt($Tpl);
|
||||
$Controller = new AppItemMgmt($Tpl);
|
||||
$Controller->getCustomField();
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_PUBLICLINKS_VIEW:
|
||||
$Tpl->assign('header', _('Ver Enlace Público'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_MGM_PUBLICLINKS);
|
||||
$Tpl->assign('isView', true);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getPublicLink();
|
||||
break;
|
||||
default :
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
*/
|
||||
|
||||
use SP\Config\Config;
|
||||
use SP\Controller\ItemsMgmtSearch;
|
||||
use SP\Controller\AccItemsMgmtSearch;
|
||||
use SP\Controller\AppItemsMgmtSearch;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Core\Template;
|
||||
@@ -55,22 +56,45 @@ $limitCount = Request::analyze('count', Config::getValue('account_count'));
|
||||
$Tpl = new Template();
|
||||
$Tpl->assign('index', Request::analyze('activeTab', 0));
|
||||
|
||||
$Controller = new ItemsMgmtSearch($Tpl);
|
||||
|
||||
switch ($actionId) {
|
||||
case \SP\Core\ActionsInterface::ACTION_USR_USERS_SEARCH:
|
||||
$Controller = new AccItemsMgmtSearch($Tpl);
|
||||
$Controller->getUsers($search, $limitStart, $limitCount);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_USR_GROUPS_SEARCH:
|
||||
$Controller = new AccItemsMgmtSearch($Tpl);
|
||||
$Controller->getGroups($search, $limitStart, $limitCount);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_USR_PROFILES_SEARCH:
|
||||
$Controller = new AccItemsMgmtSearch($Tpl);
|
||||
$Controller->getProfiles($search, $limitStart, $limitCount);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_APITOKENS_SEARCH:
|
||||
$Controller = new AccItemsMgmtSearch($Tpl);
|
||||
$Controller->getTokens($search, $limitStart, $limitCount);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_PUBLICLINKS_SEARCH:
|
||||
$Controller = new AccItemsMgmtSearch($Tpl);
|
||||
$Controller->getPublicLinks($search, $limitStart, $limitCount);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_CATEGORIES_SEARCH:
|
||||
$Controller = new AppItemsMgmtSearch($Tpl);
|
||||
$Controller->getCategories($search, $limitStart, $limitCount);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_CUSTOMERS_SEARCH:
|
||||
$Controller = new AppItemsMgmtSearch($Tpl);
|
||||
$Controller->getCustomers($search, $limitStart, $limitCount);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_CUSTOMFIELDS_SEARCH:
|
||||
$Controller = new AppItemsMgmtSearch($Tpl);
|
||||
$Controller->getCustomFields($search, $limitStart, $limitCount);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_FILES_SEARCH:
|
||||
$Controller = new AppItemsMgmtSearch($Tpl);
|
||||
$Controller->getFiles($search, $limitStart, $limitCount);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_ACCOUNTS_SEARCH:
|
||||
$Controller = new AppItemsMgmtSearch($Tpl);
|
||||
$Controller->getAccounts($search, $limitStart, $limitCount);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
use SP\Config\Config;
|
||||
use SP\Controller\Account;
|
||||
use SP\Controller\Search;
|
||||
use SP\Controller\AccountsSearch;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\Session;
|
||||
@@ -90,7 +90,7 @@ switch ($actionId) {
|
||||
|
||||
$Tpl->assign('lastAction', $lastAction);
|
||||
|
||||
$Controller = new Search($Tpl);
|
||||
$Controller = new AccountsSearch($Tpl);
|
||||
$Controller->getSearchBox();
|
||||
$Controller->getSearch();
|
||||
break;
|
||||
@@ -132,7 +132,7 @@ switch ($actionId) {
|
||||
case ActionsInterface::ACTION_USR_PROFILES:
|
||||
case ActionsInterface::ACTION_MGM_APITOKENS:
|
||||
case ActionsInterface::ACTION_MGM_PUBLICLINKS:
|
||||
$Controller = new \SP\Controller\UsersMgmt($Tpl);
|
||||
$Controller = new \SP\Controller\AccItemsMgmt($Tpl);
|
||||
$Controller->useTabs();
|
||||
$Controller->getUsersList();
|
||||
$Controller->getGroupsList();
|
||||
@@ -148,7 +148,7 @@ switch ($actionId) {
|
||||
case ActionsInterface::ACTION_MGM_CUSTOMFIELDS:
|
||||
case ActionsInterface::ACTION_MGM_FILES:
|
||||
case ActionsInterface::ACTION_MGM_ACCOUNTS:
|
||||
$Controller = new \SP\Controller\ItemsMgmt($Tpl);
|
||||
$Controller = new \SP\Controller\AppItemsMgmt($Tpl);
|
||||
$Controller->useTabs();
|
||||
$Controller->getCategories();
|
||||
$Controller->getCustomers();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use SP\Controller\ItemsMgmt;
|
||||
use SP\Controller\AppItemsMgmt;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Http\Request;
|
||||
@@ -51,6 +51,6 @@ if (!$sk || !SessionUtil::checkSessionKey($sk)) {
|
||||
Response::printXML(_('CONSULTA INVÁLIDA'));
|
||||
}
|
||||
|
||||
$Controller = new ItemsMgmt();
|
||||
$Controller = new AppItemsMgmt();
|
||||
$Controller->getAccountFiles();
|
||||
$Controller->view();
|
||||
@@ -23,7 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use SP\Controller\Search;
|
||||
use SP\Controller\AccountsSearch;
|
||||
use SP\Core\Init;
|
||||
use SP\Http\Request;
|
||||
use SP\Core\SessionUtil;
|
||||
@@ -46,7 +46,7 @@ if (!$sk || !SessionUtil::checkSessionKey($sk)) {
|
||||
Response::printJSON(_('CONSULTA INVÁLIDA'));
|
||||
}
|
||||
|
||||
$Controller = new Search();
|
||||
$Controller = new AccountsSearch();
|
||||
$Controller->getSearch();
|
||||
|
||||
$data = array(
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use SP\Controller\UsersMgmt;
|
||||
use SP\Controller\AccItemMgmt;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\Template;
|
||||
use SP\Http\Request;
|
||||
@@ -47,7 +47,7 @@ if (!$userId) {
|
||||
|
||||
$Tpl = new Template();
|
||||
$Tpl->assign('userId', $userId);
|
||||
$Controller = new UsersMgmt($Tpl);
|
||||
$Controller = new AccItemMgmt($Tpl);
|
||||
$Controller->getUserPass();
|
||||
$Tpl->addTemplate('js-common');
|
||||
$Controller->view();
|
||||
@@ -163,7 +163,7 @@ class AccountUtil
|
||||
* @param string $search La cadena a buscar
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function getAccountsMgmtDataSearch($limitCount, $limitStart = 0, $search = '')
|
||||
public static function getAccountsMgmtSearch($limitCount, $limitStart = 0, $search = '')
|
||||
{
|
||||
$Data = new QueryData();
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class Api
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido'));
|
||||
}
|
||||
|
||||
$this->_userId = ApiTokens::getUserIdForToken($authToken);
|
||||
$this->_userId = ApiTokensUtil::getUserIdForToken($authToken);
|
||||
$this->_actionId = $actionId;
|
||||
$this->_auth = true;
|
||||
|
||||
|
||||
@@ -66,100 +66,6 @@ class ApiTokens
|
||||
*/
|
||||
private $_refreshToken = false;
|
||||
|
||||
/**
|
||||
* Obtener los tokens de la API
|
||||
*
|
||||
* @param int $tokenId opcional, con el Id del token a consultar
|
||||
* @param bool $returnRawData Devolver la consulta tal cual
|
||||
* @return array|object con la lista de tokens
|
||||
*/
|
||||
public static function getTokens($tokenId = null, $returnRawData = false)
|
||||
{
|
||||
$query = 'SELECT authtoken_id,' .
|
||||
'authtoken_userId,' .
|
||||
'authtoken_actionId, ' .
|
||||
'authtoken_token, ' .
|
||||
'user_login ' .
|
||||
'FROM authTokens ' .
|
||||
'LEFT JOIN usrData ON user_id = authtoken_userId ';
|
||||
|
||||
$Data = new QueryData();
|
||||
|
||||
if (!is_null($tokenId)) {
|
||||
$query .= "WHERE authtoken_id = :id LIMIT 1";
|
||||
$Data->addParam($tokenId, 'id');
|
||||
} else {
|
||||
$query .= "ORDER BY user_login";
|
||||
}
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
if (!$returnRawData) {
|
||||
DB::setReturnArray();
|
||||
}
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!$returnRawData) {
|
||||
foreach ($queryRes as &$token) {
|
||||
$token->authtoken_actionId = Acl::getActionName($token->authtoken_actionId);
|
||||
}
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelver un array de acciones posibles para los tokens
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTokenActions()
|
||||
{
|
||||
$actions = array(
|
||||
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_CFG_BACKUP => Acl::getActionName(ActionsInterface::ACTION_CFG_BACKUP),
|
||||
ActionsInterface::ACTION_CFG_EXPORT => Acl::getActionName(ActionsInterface::ACTION_CFG_EXPORT),
|
||||
);
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el usuario a partir del token
|
||||
*
|
||||
* @param $token string El token de autorización
|
||||
* @return bool|mixed
|
||||
* @throws SPException
|
||||
*/
|
||||
public static function getUserIdForToken($token)
|
||||
{
|
||||
$query = 'SELECT authtoken_userId FROM authTokens WHERE authtoken_token = :token LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($token, 'token');
|
||||
|
||||
try {
|
||||
$queryRes = DB::getResults($Data);
|
||||
} catch (SPException $e) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error interno'));
|
||||
}
|
||||
|
||||
if (DB::$lastNumRows === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $queryRes->authtoken_userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $refreshToken
|
||||
*/
|
||||
|
||||
189
inc/SP/Api/ApiTokensUtil.class.php
Normal file
189
inc/SP/Api/ApiTokensUtil.class.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2015 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;
|
||||
|
||||
use SP\Core\Acl;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\SPException;
|
||||
use SP\Storage\DB;
|
||||
use SP\Storage\QueryData;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
/**
|
||||
* Class ApiTokensUtil con utilidades para la gestión de tokens API
|
||||
*
|
||||
* @package SP\Api
|
||||
*/
|
||||
class ApiTokensUtil
|
||||
{
|
||||
/**
|
||||
* Obtener los tokens de la API
|
||||
*
|
||||
* @param int $tokenId opcional, con el Id del token a consultar
|
||||
* @param bool $returnRawData Devolver la consulta tal cual
|
||||
* @return array|object con la lista de tokens
|
||||
*/
|
||||
public static function getTokens($tokenId = null, $returnRawData = false)
|
||||
{
|
||||
$query = 'SELECT authtoken_id,' .
|
||||
'authtoken_userId,' .
|
||||
'authtoken_actionId, ' .
|
||||
'authtoken_token, ' .
|
||||
'user_login ' .
|
||||
'FROM authTokens ' .
|
||||
'LEFT JOIN usrData ON user_id = authtoken_userId ';
|
||||
|
||||
$Data = new QueryData();
|
||||
|
||||
if (!is_null($tokenId)) {
|
||||
$query .= "WHERE authtoken_id = :id LIMIT 1";
|
||||
$Data->addParam($tokenId, 'id');
|
||||
} else {
|
||||
$query .= "ORDER BY user_login";
|
||||
}
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
if (!$returnRawData) {
|
||||
DB::setReturnArray();
|
||||
}
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!$returnRawData) {
|
||||
foreach ($queryRes as &$token) {
|
||||
$token->authtoken_actionId = Acl::getActionName($token->authtoken_actionId);
|
||||
}
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los tokens de la API de una búsqueda
|
||||
*
|
||||
* @param $limitCount
|
||||
* @param int $limitStart
|
||||
* @param string $search
|
||||
* @return array|object con la lista de tokens
|
||||
*/
|
||||
public static function getTokensMgmtSearch($limitCount, $limitStart = 0, $search = '')
|
||||
{
|
||||
$query = 'SELECT authtoken_id,' .
|
||||
'authtoken_userId,' .
|
||||
'authtoken_actionId, ' .
|
||||
'authtoken_token, ' .
|
||||
'user_login ' .
|
||||
'FROM authTokens ' .
|
||||
'LEFT JOIN usrData ON user_id = authtoken_userId ';
|
||||
|
||||
$Data = new QueryData();
|
||||
|
||||
if (!empty($search)) {
|
||||
$search = '%' . $search . '%';
|
||||
$query .= ' WHERE user_login LIKE ?';
|
||||
|
||||
$Data->addParam($search);
|
||||
}
|
||||
|
||||
$query .= ' ORDER BY user_login';
|
||||
$query .= ' LIMIT ?, ?';
|
||||
|
||||
$Data->addParam($limitStart);
|
||||
$Data->addParam($limitCount);
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($queryRes as &$token) {
|
||||
$token->authtoken_actionId = Acl::getActionName($token->authtoken_actionId);
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelver un array de acciones posibles para los tokens
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTokenActions()
|
||||
{
|
||||
$actions = array(
|
||||
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_CFG_BACKUP => Acl::getActionName(ActionsInterface::ACTION_CFG_BACKUP),
|
||||
ActionsInterface::ACTION_CFG_EXPORT => Acl::getActionName(ActionsInterface::ACTION_CFG_EXPORT),
|
||||
);
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el usuario a partir del token
|
||||
*
|
||||
* @param $token string El token de autorización
|
||||
* @return bool|mixed
|
||||
* @throws SPException
|
||||
*/
|
||||
public static function getUserIdForToken($token)
|
||||
{
|
||||
$query = 'SELECT authtoken_userId FROM authTokens WHERE authtoken_token = :token LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($token, 'token');
|
||||
|
||||
try {
|
||||
$queryRes = DB::getResults($Data);
|
||||
} catch (SPException $e) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error interno'));
|
||||
}
|
||||
|
||||
if (DB::$lastNumRows === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $queryRes->authtoken_userId;
|
||||
}
|
||||
}
|
||||
189
inc/SP/Controller/AccItemMgmt.class.php
Normal file
189
inc/SP/Controller/AccItemMgmt.class.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2015 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\Controller;
|
||||
|
||||
use SP\Api\ApiTokens;
|
||||
use SP\Api\ApiTokensUtil;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Session;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Core\Template;
|
||||
use SP\Log\Log;
|
||||
use SP\Mgmt\CustomFields;
|
||||
use SP\Mgmt\PublicLinkUtil;
|
||||
use SP\Mgmt\User\Groups;
|
||||
use SP\Mgmt\User\Profile;
|
||||
use SP\Mgmt\User\ProfileUtil;
|
||||
use SP\Mgmt\User\UserUtil;
|
||||
use SP\Storage\DBUtil;
|
||||
use SP\Util\Checks;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
class AccItemMgmt extends Controller implements ActionsInterface
|
||||
{
|
||||
/**
|
||||
* Máximo numero de acciones antes de agrupar
|
||||
*/
|
||||
const MAX_NUM_ACTIONS = 3;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $_module = 0;
|
||||
/**
|
||||
* @var Icons
|
||||
*/
|
||||
private $_icons;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param $template Template con instancia de plantilla
|
||||
*/
|
||||
public function __construct(Template $template = null)
|
||||
{
|
||||
parent::__construct($template);
|
||||
|
||||
$this->view->assign('isDemo', Checks::demoIsEnabled());
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
|
||||
$this->_icons = new Icons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la ficha de usuario
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
$this->_module = self::ACTION_USR_USERS;
|
||||
$this->view->addTemplate('users');
|
||||
|
||||
$this->view->assign('user', UserUtil::getUserData($this->view->itemId));
|
||||
$this->view->assign('isDisabled', (($this->view->user['user_login'] === 'demo' && $this->view->isDemo) || $this->view->actionId === self::ACTION_USR_USERS_VIEW) ? 'disabled' : '');
|
||||
$this->view->assign('groups', DBUtil::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name'));
|
||||
$this->view->assign('profiles', DBUtil::getValuesForSelect('usrProfiles', 'userprofile_id', 'userprofile_name'));
|
||||
$this->view->assign('ro', ($this->view->user['checks']['user_isLdap']) ? 'READONLY' : '');
|
||||
|
||||
$this->getCustomFieldsForItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener la lista de campos personalizados y sus valores
|
||||
*/
|
||||
private function getCustomFieldsForItem()
|
||||
{
|
||||
// Se comprueba que hayan campos con valores para el elemento actual
|
||||
if ($this->view->itemId && CustomFields::checkCustomFieldExists($this->_module, $this->view->itemId)) {
|
||||
$this->view->assign('customFields', CustomFields::getCustomFieldsData($this->_module, $this->view->itemId));
|
||||
} else {
|
||||
$this->view->assign('customFields', CustomFields::getCustomFieldsForModule($this->_module));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la ficha de grupo
|
||||
*/
|
||||
public function getGroup()
|
||||
{
|
||||
$this->_module = self::ACTION_USR_GROUPS;
|
||||
$this->view->addTemplate('groups');
|
||||
|
||||
$this->view->assign('group', Groups::getGroupData($this->view->itemId));
|
||||
$this->view->assign('users', DBUtil::getValuesForSelect('usrData', 'user_id', 'user_name'));
|
||||
$this->view->assign('groupUsers', Groups::getUsersForGroup($this->view->itemId));
|
||||
|
||||
$this->getCustomFieldsForItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la ficha de perfil
|
||||
*/
|
||||
public function getProfile()
|
||||
{
|
||||
$this->view->addTemplate('profiles');
|
||||
|
||||
$profile = ($this->view->itemId) ? ProfileUtil::getProfile($this->view->itemId) : new Profile();
|
||||
|
||||
$this->view->assign('profile', $profile);
|
||||
$this->view->assign('isDisabled', ($this->view->actionId === self::ACTION_USR_PROFILES_VIEW) ? 'disabled' : '');
|
||||
|
||||
if ($this->view->isView === true) {
|
||||
$this->view->assign('usedBy', Profile::getProfileInUsersName($this->view->itemId));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar la vista de cambio de clave de usuario
|
||||
*/
|
||||
public function getUserPass()
|
||||
{
|
||||
$this->setAction(self::ACTION_USR_USERS_EDITPASS);
|
||||
|
||||
// Comprobar si el usuario a modificar es distinto al de la sesión
|
||||
if ($this->view->userId != Session::getUserId() && !$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('userspass');
|
||||
|
||||
$this->view->assign('actionId', self::ACTION_USR_USERS_EDITPASS);
|
||||
|
||||
// Obtener de nuevo el token de seguridad por si se habñia regenerado antes
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la ficha de tokens de API
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
$this->view->addTemplate('tokens');
|
||||
|
||||
$token = ApiTokensUtil::getTokens($this->view->itemId, true);
|
||||
|
||||
$this->view->assign('users', DBUtil::getValuesForSelect('usrData', 'user_id', 'user_name'));
|
||||
$this->view->assign('actions', ApiTokensUtil::getTokenActions());
|
||||
$this->view->assign('token', $token);
|
||||
$this->view->assign('gotData', is_object($token));
|
||||
|
||||
if ($this->view->isView === true) {
|
||||
$msg = sprintf('%s ;;Usuario: %s', _('Token de autorización visualizado'), $token->user_login);
|
||||
Log::writeNewLogAndEmail(_('Autorizaciones'), $msg, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la ficha de enlace público
|
||||
*/
|
||||
public function getPublicLink()
|
||||
{
|
||||
$this->view->addTemplate('publiclinks');
|
||||
|
||||
$this->view->assign('link', PublicLinkUtil::getLinks($this->view->itemId)[0]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
157
inc/SP/Controller/AccItemsMgmt.class.php
Normal file
157
inc/SP/Controller/AccItemsMgmt.class.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2015 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\Controller;
|
||||
|
||||
use SP\Api\ApiTokensUtil;
|
||||
use SP\Config\Config;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Mgmt\PublicLinkUtil;
|
||||
use SP\Mgmt\User\Groups;
|
||||
use SP\Core\Template;
|
||||
use SP\Mgmt\User\ProfileUtil;
|
||||
use SP\Mgmt\User\UserUtil;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
/**
|
||||
* Clase encargada de de preparar la presentación de las vistas de gestión de accesos
|
||||
*
|
||||
* @package Controller
|
||||
*/
|
||||
class AccItemsMgmt extends GridTabController implements ActionsInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $_limitCount;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param $template Template con instancia de plantilla
|
||||
*/
|
||||
public function __construct(Template $template = null)
|
||||
{
|
||||
parent::__construct($template);
|
||||
|
||||
$this->_limitCount = Config::getValue('account_count');
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la pestaña de usuarios
|
||||
*/
|
||||
public function getUsersList()
|
||||
{
|
||||
$this->setAction(self::ACTION_USR_USERS);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$Grid = $this->_grids->getUsersGrid();
|
||||
$Grid->getData()->setData(UserUtil::getUsersMgmSearch($this->_limitCount));
|
||||
$Grid->updatePager();
|
||||
$Grid->getPager()->setOnClickArgs($this->_limitCount);
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la pestaña de grupos
|
||||
*/
|
||||
public function getGroupsList()
|
||||
{
|
||||
$this->setAction(self::ACTION_USR_GROUPS);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$Grid = $this->_grids->getGroupsGrid();
|
||||
$Grid->getData()->setData(Groups::getGroupsMgmtSearch($this->_limitCount));
|
||||
$Grid->updatePager();
|
||||
$Grid->getPager()->setOnClickArgs($this->_limitCount);
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la pestaña de perfiles
|
||||
*/
|
||||
public function getProfilesList()
|
||||
{
|
||||
$this->setAction(self::ACTION_USR_PROFILES);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$Grid = $this->_grids->getProfilesGrid();
|
||||
$Grid->getData()->setData(ProfileUtil::getProfilesMgmtSearch($this->_limitCount));
|
||||
$Grid->updatePager();
|
||||
$Grid->getPager()->setOnClickArgs($this->_limitCount);
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la pestaña de tokens de API
|
||||
*/
|
||||
public function getAPITokensList()
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_APITOKENS);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$Grid = $this->_grids->getTokensGrid();
|
||||
$Grid->getData()->setData(ApiTokensUtil::getTokensMgmtSearch($this->_limitCount));
|
||||
$Grid->updatePager();
|
||||
$Grid->getPager()->setOnClickArgs($this->_limitCount);
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la pestaña de tokens de API
|
||||
*/
|
||||
public function getPublicLinksList()
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_PUBLICLINKS);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$Grid = $this->_grids->getPublicLinksGrid();
|
||||
$Grid->getData()->setData(PublicLinkUtil::getLinksMgmtSearch($this->_limitCount));
|
||||
$Grid->updatePager();
|
||||
$Grid->getPager()->setOnClickArgs($this->_limitCount);
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
}
|
||||
}
|
||||
176
inc/SP/Controller/AccItemsMgmtSearch.class.php
Normal file
176
inc/SP/Controller/AccItemsMgmtSearch.class.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2015 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\Controller;
|
||||
|
||||
use SP\Api\ApiTokensUtil;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Mgmt\PublicLinkUtil;
|
||||
use SP\Mgmt\User\Groups;
|
||||
use SP\Mgmt\User\ProfileUtil;
|
||||
use SP\Mgmt\User\UserUtil;
|
||||
|
||||
/**
|
||||
* Class AccItemsMgmtSearch para la gestión de búsquedas de items de accesos
|
||||
*
|
||||
* @package SP\Controller
|
||||
*/
|
||||
class AccItemsMgmtSearch extends GridItemsSearch implements ActionsInterface
|
||||
{
|
||||
/**
|
||||
* Obtener los usuarios de una búsqueda
|
||||
*
|
||||
* @param string $search La cadena a buscar
|
||||
* @param int $limitStart
|
||||
* @param int $limitCount
|
||||
*/
|
||||
public function getUsers($search, $limitStart, $limitCount)
|
||||
{
|
||||
$this->setAction(self::ACTION_USR_USERS_SEARCH);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$Grid = $this->_grids->getUsersGrid();
|
||||
$Grid->getData()->setData(UserUtil::getUsersMgmSearch($limitCount, $limitStart, $search));
|
||||
$Grid->updatePager();
|
||||
|
||||
$this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
|
||||
|
||||
$this->view->assign('data', $Grid);
|
||||
$this->view->assign('actionId', self::ACTION_USR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los grupos de una búsqueda
|
||||
*
|
||||
* @param string $search La cadena a buscar
|
||||
* @param int $limitStart
|
||||
* @param int $limitCount
|
||||
*/
|
||||
public function getGroups($search, $limitStart, $limitCount)
|
||||
{
|
||||
$this->setAction(self::ACTION_USR_GROUPS_SEARCH);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$Grid = $this->_grids->getGroupsGrid();
|
||||
$Grid->getData()->setData(Groups::getGroupsMgmtSearch($limitCount, $limitStart, $search));
|
||||
$Grid->updatePager();
|
||||
|
||||
$this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
|
||||
|
||||
$this->view->assign('data', $Grid);
|
||||
$this->view->assign('actionId', self::ACTION_USR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los perfiles de una búsqueda
|
||||
*
|
||||
* @param string $search La cadena a buscar
|
||||
* @param int $limitStart
|
||||
* @param int $limitCount
|
||||
*/
|
||||
public function getProfiles($search, $limitStart, $limitCount)
|
||||
{
|
||||
$this->setAction(self::ACTION_USR_PROFILES_SEARCH);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$Grid = $this->_grids->getProfilesGrid();
|
||||
$Grid->getData()->setData(ProfileUtil::getProfilesMgmtSearch($limitCount, $limitStart, $search));
|
||||
$Grid->updatePager();
|
||||
|
||||
$this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
|
||||
|
||||
$this->view->assign('data', $Grid);
|
||||
$this->view->assign('actionId', self::ACTION_USR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los tokens API de una búsqueda
|
||||
*
|
||||
* @param string $search La cadena a buscar
|
||||
* @param int $limitStart
|
||||
* @param int $limitCount
|
||||
*/
|
||||
public function getTokens($search, $limitStart, $limitCount)
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_APITOKENS_SEARCH);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$Grid = $this->_grids->getTokensGrid();
|
||||
$Grid->getData()->setData(ApiTokensUtil::getTokensMgmtSearch($limitCount, $limitStart, $search));
|
||||
$Grid->updatePager();
|
||||
|
||||
$this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
|
||||
|
||||
$this->view->assign('data', $Grid);
|
||||
$this->view->assign('actionId', self::ACTION_USR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los enlaces públicos de una búsqueda
|
||||
*
|
||||
* @param string $search La cadena a buscar
|
||||
* @param int $limitStart
|
||||
* @param int $limitCount
|
||||
*/
|
||||
public function getPublicLinks($search, $limitStart, $limitCount)
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_PUBLICLINKS_SEARCH);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$Grid = $this->_grids->getPublicLinksGrid();
|
||||
$Grid->getData()->setData(PublicLinkUtil::getLinksMgmtSearch($limitCount, $limitStart, $search));
|
||||
$Grid->updatePager();
|
||||
|
||||
$this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
|
||||
|
||||
$this->view->assign('data', $Grid);
|
||||
$this->view->assign('actionId', self::ACTION_USR);
|
||||
}
|
||||
}
|
||||
@@ -32,15 +32,12 @@ use SP\Core\ActionsInterface;
|
||||
use SP\Core\Session;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Account\UserAccounts;
|
||||
use SP\Html\DataGrid\DataGrid;
|
||||
use SP\Html\DataGrid\DataGridData;
|
||||
use SP\Html\DataGrid\DataGridPager;
|
||||
use SP\Html\Html;
|
||||
use SP\Http\Request;
|
||||
use SP\Mgmt\User\Groups;
|
||||
use SP\Storage\DBUtil;
|
||||
use SP\Util\Checks;
|
||||
use SP\Util\Util;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
@@ -49,7 +46,7 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'
|
||||
*
|
||||
* @package Controller
|
||||
*/
|
||||
class Search extends Controller implements ActionsInterface
|
||||
class AccountsSearch extends Controller implements ActionsInterface
|
||||
{
|
||||
/**
|
||||
* @var Icons
|
||||
@@ -44,7 +44,7 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'
|
||||
*
|
||||
* @package Controller
|
||||
*/
|
||||
class ItemMgmt extends Controller implements ActionsInterface
|
||||
class AppItemMgmt extends Controller implements ActionsInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
@@ -35,7 +35,6 @@ use SP\Mgmt\Customer;
|
||||
use SP\Mgmt\CustomFieldDef;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Mgmt\Files;
|
||||
use SP\Util\Checks;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
@@ -44,16 +43,8 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'
|
||||
*
|
||||
* @package Controller
|
||||
*/
|
||||
class ItemsMgmt extends Controller implements ActionsInterface
|
||||
class AppItemsMgmt extends GridTabController implements ActionsInterface
|
||||
{
|
||||
/**
|
||||
* Máximo numero de acciones antes de agrupar
|
||||
*/
|
||||
const MAX_NUM_ACTIONS = 3;
|
||||
/**
|
||||
* @var Grids
|
||||
*/
|
||||
private $_grids;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
@@ -69,9 +60,6 @@ class ItemsMgmt extends Controller implements ActionsInterface
|
||||
parent::__construct($template);
|
||||
|
||||
$this->_limitCount = Config::getValue('account_count');
|
||||
|
||||
$this->view->assign('isDemo', Checks::demoIsEnabled());
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +74,7 @@ class ItemsMgmt extends Controller implements ActionsInterface
|
||||
}
|
||||
|
||||
$Grid = $this->_grids->getCategoriesGrid();
|
||||
$Grid->getData()->setData(Category::getCategoriesSearch($this->_limitCount));
|
||||
$Grid->getData()->setData(Category::getCategoriesMgmtSearch($this->_limitCount));
|
||||
$Grid->updatePager();
|
||||
$Grid->getPager()->setOnClickArgs($this->_limitCount);
|
||||
|
||||
@@ -105,28 +93,13 @@ class ItemsMgmt extends Controller implements ActionsInterface
|
||||
}
|
||||
|
||||
$Grid = $this->_grids->getCustomersGrid();
|
||||
$Grid->getData()->setData(Customer::getCustomersSearch($this->_limitCount));
|
||||
$Grid->getData()->setData(Customer::getCustomersMgmtSearch($this->_limitCount));
|
||||
$Grid->updatePager();
|
||||
$Grid->getPager()->setOnClickArgs($this->_limitCount);
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar las plantillas para las pestañas
|
||||
*/
|
||||
public function useTabs()
|
||||
{
|
||||
$this->_grids = new Grids();
|
||||
$this->_grids->setQueryTimeStart($this->view->queryTimeStart);
|
||||
|
||||
$this->view->addTemplate('datatabs-grid');
|
||||
|
||||
$this->view->assign('tabs', array());
|
||||
$this->view->assign('activeTab', 0);
|
||||
$this->view->assign('maxNumActions', self::MAX_NUM_ACTIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la vista de archivos de una cuenta
|
||||
*/
|
||||
@@ -159,7 +132,7 @@ class ItemsMgmt extends Controller implements ActionsInterface
|
||||
}
|
||||
|
||||
$Grid = $this->_grids->getCustomFieldsGrid();
|
||||
$Grid->getData()->setData(CustomFieldDef::getCustomFieldsSearch($this->_limitCount));
|
||||
$Grid->getData()->setData(CustomFieldDef::getCustomFieldsMgmtSearch($this->_limitCount));
|
||||
$Grid->updatePager();
|
||||
$Grid->getPager()->setOnClickArgs($this->_limitCount);
|
||||
|
||||
@@ -179,7 +152,7 @@ class ItemsMgmt extends Controller implements ActionsInterface
|
||||
}
|
||||
|
||||
$Grid = $this->_grids->getFilesGrid();
|
||||
$Grid->getData()->setData(Files::getFileListSearch($this->_limitCount));
|
||||
$Grid->getData()->setData(Files::getFilesMgmtSearch($this->_limitCount));
|
||||
$Grid->updatePager();
|
||||
$Grid->getPager()->setOnClickArgs($this->_limitCount);
|
||||
|
||||
@@ -198,7 +171,7 @@ class ItemsMgmt extends Controller implements ActionsInterface
|
||||
}
|
||||
|
||||
$Grid = $this->_grids->getAccountsGrid();
|
||||
$Grid->getData()->setData(AccountUtil::getAccountsMgmtDataSearch($this->_limitCount));
|
||||
$Grid->getData()->setData(AccountUtil::getAccountsMgmtSearch($this->_limitCount));
|
||||
$Grid->updatePager();
|
||||
$Grid->getPager()->setOnClickArgs($this->_limitCount);
|
||||
|
||||
@@ -27,41 +27,18 @@ namespace SP\Controller;
|
||||
|
||||
use SP\Account\AccountUtil;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Template;
|
||||
use SP\Html\DataGrid\DataGridPagerBase;
|
||||
use SP\Mgmt\Category;
|
||||
use SP\Mgmt\Customer;
|
||||
use SP\Mgmt\CustomFieldDef;
|
||||
use SP\Mgmt\Files;
|
||||
use SP\Util\Checks;
|
||||
|
||||
/**
|
||||
* Class ItemsMgmt para las buśquedas en los listados de elementos de gestión
|
||||
*
|
||||
* @package SP\Controller
|
||||
*/
|
||||
class ItemsMgmtSearch extends Controller implements ActionsInterface
|
||||
class AppItemsMgmtSearch extends GridItemsSearch implements ActionsInterface
|
||||
{
|
||||
/**
|
||||
* @var Grids
|
||||
*/
|
||||
private $_grids;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param $template Template con instancia de plantilla
|
||||
*/
|
||||
public function __construct(Template $template = null)
|
||||
{
|
||||
parent::__construct($template);
|
||||
|
||||
$this->view->assign('isDemo', Checks::demoIsEnabled());
|
||||
|
||||
$this->_grids = new Grids();
|
||||
$this->_grids->setQueryTimeStart(microtime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener las cuentas de una búsqueda
|
||||
*
|
||||
@@ -80,7 +57,7 @@ class ItemsMgmtSearch extends Controller implements ActionsInterface
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$Grid = $this->_grids->getAccountsGrid();
|
||||
$Grid->getData()->setData(AccountUtil::getAccountsMgmtDataSearch($limitCount, $limitStart, $search));
|
||||
$Grid->getData()->setData(AccountUtil::getAccountsMgmtSearch($limitCount, $limitStart, $search));
|
||||
$Grid->updatePager();
|
||||
|
||||
$this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
|
||||
@@ -107,7 +84,7 @@ class ItemsMgmtSearch extends Controller implements ActionsInterface
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$Grid = $this->_grids->getFilesGrid();
|
||||
$Grid->getData()->setData(Files::getFileListSearch($limitCount, $limitStart, $search));
|
||||
$Grid->getData()->setData(Files::getFilesMgmtSearch($limitCount, $limitStart, $search));
|
||||
$Grid->updatePager();
|
||||
|
||||
$this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
|
||||
@@ -134,7 +111,7 @@ class ItemsMgmtSearch extends Controller implements ActionsInterface
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$Grid = $this->_grids->getCustomFieldsGrid();
|
||||
$Grid->getData()->setData(CustomFieldDef::getCustomFieldsSearch($limitCount, $limitStart, $search));
|
||||
$Grid->getData()->setData(CustomFieldDef::getCustomFieldsMgmtSearch($limitCount, $limitStart, $search));
|
||||
$Grid->updatePager();
|
||||
|
||||
$this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
|
||||
@@ -161,7 +138,7 @@ class ItemsMgmtSearch extends Controller implements ActionsInterface
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$Grid = $this->_grids->getCustomersGrid();
|
||||
$Grid->getData()->setData(Customer::getCustomersSearch($limitCount, $limitStart, $search));
|
||||
$Grid->getData()->setData(Customer::getCustomersMgmtSearch($limitCount, $limitStart, $search));
|
||||
$Grid->updatePager();
|
||||
|
||||
$this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
|
||||
@@ -188,7 +165,7 @@ class ItemsMgmtSearch extends Controller implements ActionsInterface
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$Grid = $this->_grids->getCategoriesGrid();
|
||||
$Grid->getData()->setData(Category::getCategoriesSearch($limitCount, $limitStart, $search));
|
||||
$Grid->getData()->setData(Category::getCategoriesMgmtSearch($limitCount, $limitStart, $search));
|
||||
$Grid->updatePager();
|
||||
|
||||
$this->updatePager($Grid->getPager(), !empty($search), $limitStart, $limitCount);
|
||||
@@ -196,21 +173,4 @@ class ItemsMgmtSearch extends Controller implements ActionsInterface
|
||||
$this->view->assign('data', $Grid);
|
||||
$this->view->assign('actionId', self::ACTION_MGM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar los datos del paginador
|
||||
*
|
||||
* @param DataGridPagerBase $Pager
|
||||
* @param bool $filterOn
|
||||
* @param int $limitStart
|
||||
* @param int $limitCount
|
||||
*/
|
||||
private function updatePager(DataGridPagerBase $Pager, $filterOn, $limitStart, $limitCount)
|
||||
{
|
||||
$Pager->setLimitStart($limitStart);
|
||||
$Pager->setLimitCount($limitCount);
|
||||
$Pager->setOnClickArgs($limitCount);
|
||||
$Pager->setFilterOn($filterOn);
|
||||
}
|
||||
|
||||
}
|
||||
53
inc/SP/Controller/GridItemsSearch.class.php
Normal file
53
inc/SP/Controller/GridItemsSearch.class.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: rdb
|
||||
* Date: 24/11/15
|
||||
* Time: 14:14
|
||||
*/
|
||||
|
||||
namespace SP\Controller;
|
||||
|
||||
|
||||
use SP\Core\Template;
|
||||
use SP\Html\DataGrid\DataGridPagerBase;
|
||||
use SP\Util\Checks;
|
||||
|
||||
abstract class GridItemsSearch extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Grids
|
||||
*/
|
||||
protected $_grids;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param $template Template con instancia de plantilla
|
||||
*/
|
||||
public function __construct(Template $template = null)
|
||||
{
|
||||
parent::__construct($template);
|
||||
|
||||
$this->view->assign('isDemo', Checks::demoIsEnabled());
|
||||
|
||||
$this->_grids = new Grids();
|
||||
$this->_grids->setQueryTimeStart(microtime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar los datos del paginador
|
||||
*
|
||||
* @param DataGridPagerBase $Pager
|
||||
* @param bool $filterOn
|
||||
* @param int $limitStart
|
||||
* @param int $limitCount
|
||||
*/
|
||||
protected function updatePager(DataGridPagerBase $Pager, $filterOn, $limitStart, $limitCount)
|
||||
{
|
||||
$Pager->setLimitStart($limitStart);
|
||||
$Pager->setLimitCount($limitCount);
|
||||
$Pager->setOnClickArgs($limitCount);
|
||||
$Pager->setFilterOn($filterOn);
|
||||
}
|
||||
}
|
||||
71
inc/SP/Controller/GridTabController.class.php
Normal file
71
inc/SP/Controller/GridTabController.class.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2015 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\Controller;
|
||||
|
||||
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Core\Template;
|
||||
use SP\Util\Checks;
|
||||
|
||||
abstract class GridTabController extends Controller
|
||||
{
|
||||
/**
|
||||
* Máximo numero de acciones antes de agrupar
|
||||
*/
|
||||
const MAX_NUM_ACTIONS = 3;
|
||||
/**
|
||||
* @var Grids
|
||||
*/
|
||||
protected $_grids;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param $template Template con instancia de plantilla
|
||||
*/
|
||||
public function __construct(Template $template = null)
|
||||
{
|
||||
parent::__construct($template);
|
||||
|
||||
$this->view->assign('isDemo', Checks::demoIsEnabled());
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar las plantillas para las pestañas
|
||||
*/
|
||||
public function useTabs()
|
||||
{
|
||||
$this->_grids = new Grids();
|
||||
$this->_grids->setQueryTimeStart($this->view->queryTimeStart);
|
||||
|
||||
$this->view->addTemplate('datatabs-grid');
|
||||
|
||||
$this->view->assign('tabs', array());
|
||||
$this->view->assign('activeTab', 0);
|
||||
$this->view->assign('maxNumActions', self::MAX_NUM_ACTIONS);
|
||||
}
|
||||
}
|
||||
@@ -423,6 +423,432 @@ class Grids implements ActionsInterface
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataGridTab
|
||||
*/
|
||||
public function getUsersGrid()
|
||||
{
|
||||
$GridActionSearch = new DataGridActionSearch();
|
||||
$GridActionSearch->setId(self::ACTION_USR_USERS_SEARCH);
|
||||
$GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
|
||||
$GridActionSearch->setName('frmSearchUser');
|
||||
$GridActionSearch->setTitle(_('Buscar Usuario'));
|
||||
$GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
|
||||
$GridActionSearch->setOnSubmitArgs('this');
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::ACTION_USR_USERS_NEW);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setName(_('Nuevo Usuario'));
|
||||
$GridActionNew->setTitle(_('Nuevo Usuario'));
|
||||
$GridActionNew->setIcon($this->_icons->getIconAdd());
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_USR_USERS_NEW);
|
||||
$GridActionNew->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionView = new DataGridAction();
|
||||
$GridActionView->setId(self::ACTION_USR_USERS_VIEW);
|
||||
$GridActionView->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionView->setName(_('Ver Detalles de Usuario'));
|
||||
$GridActionView->setTitle(_('Ver Detalles de Usuario'));
|
||||
$GridActionView->setIcon($this->_icons->getIconView());
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
$GridActionView->setOnClickArgs(self::ACTION_USR_USERS_VIEW);
|
||||
$GridActionView->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(self::ACTION_USR_USERS_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(_('Editar Usuario'));
|
||||
$GridActionEdit->setTitle(_('Editar Usuario'));
|
||||
$GridActionEdit->setIcon($this->_icons->getIconEdit());
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
$GridActionEdit->setOnClickArgs(self::ACTION_USR_USERS_EDIT);
|
||||
$GridActionEdit->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_USR_USERS_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Usuario'));
|
||||
$GridActionDel->setTitle(_('Eliminar Usuario'));
|
||||
$GridActionDel->setIcon($this->_icons->getIconDelete());
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_USR_USERS_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionEditPass = new DataGridAction();
|
||||
$GridActionEditPass->setId(self::ACTION_USR_USERS_EDITPASS);
|
||||
$GridActionEditPass->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEditPass->setName(_('Cambiar Clave de Usuario'));
|
||||
$GridActionEditPass->setTitle(_('Cambiar Clave de Usuario'));
|
||||
$GridActionEditPass->setIcon($this->_icons->getIconEditPass());
|
||||
$GridActionEditPass->setOnClickFunction('sysPassUtil.Common.usrUpdPass');
|
||||
$GridActionEditPass->setOnClickArgs('this');
|
||||
$GridActionEditPass->setOnClickArgs(self::ACTION_USR_USERS_EDITPASS);
|
||||
$GridActionEditPass->setOnClickArgs($this->_sk);
|
||||
$GridActionEditPass->setFilterRowSource('user_isLdap');
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Nombre'));
|
||||
$GridHeaders->addHeader(_('Login'));
|
||||
$GridHeaders->addHeader(_('Perfil'));
|
||||
$GridHeaders->addHeader(_('Grupo'));
|
||||
$GridHeaders->addHeader(_('Propiedades'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('user_id');
|
||||
$GridData->addDataRowSource('user_name');
|
||||
$GridData->addDataRowSource('user_login');
|
||||
$GridData->addDataRowSource('userprofile_name');
|
||||
$GridData->addDataRowSource('usergroup_name');
|
||||
$GridData->addDataRowSourceWithIcon('user_isAdminApp', $this->_icons->getIconAppAdmin());
|
||||
$GridData->addDataRowSourceWithIcon('user_isAdminAcc', $this->_icons->getIconAccAdmin());
|
||||
$GridData->addDataRowSourceWithIcon('user_isLdap', $this->_icons->getIconLdapUser());
|
||||
$GridData->addDataRowSourceWithIcon('user_isDisabled', $this->_icons->getIconDisabled());
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblUsers');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionNew);
|
||||
$Grid->setDataActions($GridActionSearch);
|
||||
$Grid->setDataActions($GridActionView);
|
||||
$Grid->setDataActions($GridActionEdit);
|
||||
$Grid->setDataActions($GridActionEditPass);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridActionSearch));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Usuarios'));
|
||||
$Grid->setTime(round(microtime() - $this->_queryTimeStart, 5));
|
||||
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataGridTab
|
||||
*/
|
||||
public function getGroupsGrid()
|
||||
{
|
||||
$GridActionSearch = new DataGridActionSearch();
|
||||
$GridActionSearch->setId(self::ACTION_USR_GROUPS_SEARCH);
|
||||
$GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
|
||||
$GridActionSearch->setName('frmSearchGroup');
|
||||
$GridActionSearch->setTitle(_('Buscar Grupo'));
|
||||
$GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
|
||||
$GridActionSearch->setOnSubmitArgs('this');
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::ACTION_USR_GROUPS_NEW);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setName(_('Nuevo Grupo'));
|
||||
$GridActionNew->setTitle(_('Nuevo Grupo'));
|
||||
$GridActionNew->setIcon($this->_icons->getIconAdd());
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_USR_GROUPS_NEW);
|
||||
$GridActionNew->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(self::ACTION_USR_GROUPS_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(_('Editar Grupo'));
|
||||
$GridActionEdit->setTitle(_('Editar Grupo'));
|
||||
$GridActionEdit->setIcon($this->_icons->getIconEdit());
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
$GridActionEdit->setOnClickArgs(self::ACTION_USR_GROUPS_EDIT);
|
||||
$GridActionEdit->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_USR_GROUPS_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Grupo'));
|
||||
$GridActionDel->setTitle(_('Eliminar Grupo'));
|
||||
$GridActionDel->setIcon($this->_icons->getIconDelete());
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_USR_GROUPS_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Nombre'));
|
||||
$GridHeaders->addHeader(_('Descripción'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('usergroup_id');
|
||||
$GridData->addDataRowSource('usergroup_name');
|
||||
$GridData->addDataRowSource('usergroup_description');
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblGroups');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionNew);
|
||||
$Grid->setDataActions($GridActionSearch);
|
||||
$Grid->setDataActions($GridActionEdit);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridActionSearch));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Grupos'));
|
||||
$Grid->setTime(round(microtime() - $this->_queryTimeStart, 5));
|
||||
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataGridTab
|
||||
*/
|
||||
public function getProfilesGrid()
|
||||
{
|
||||
$GridActionSearch = new DataGridActionSearch();
|
||||
$GridActionSearch->setId(self::ACTION_USR_PROFILES_SEARCH);
|
||||
$GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
|
||||
$GridActionSearch->setName('frmSearchProfile');
|
||||
$GridActionSearch->setTitle(_('Buscar Perfil'));
|
||||
$GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
|
||||
$GridActionSearch->setOnSubmitArgs('this');
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::ACTION_USR_PROFILES_NEW);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setName(_('Nuevo Perfil'));
|
||||
$GridActionNew->setTitle(_('Nuevo Perfil'));
|
||||
$GridActionNew->setIcon($this->_icons->getIconAdd());
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_USR_PROFILES_NEW);
|
||||
$GridActionNew->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionView = new DataGridAction();
|
||||
$GridActionView->setId(self::ACTION_USR_PROFILES_VIEW);
|
||||
$GridActionView->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionView->setName(_('Ver Detalles de Perfil'));
|
||||
$GridActionView->setTitle(_('Ver Detalles de Perfil'));
|
||||
$GridActionView->setIcon($this->_icons->getIconView());
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
$GridActionView->setOnClickArgs(self::ACTION_USR_PROFILES_VIEW);
|
||||
$GridActionView->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(self::ACTION_USR_PROFILES_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(_('Editar Perfil'));
|
||||
$GridActionEdit->setTitle(_('Editar Perfil'));
|
||||
$GridActionEdit->setIcon($this->_icons->getIconEdit());
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
$GridActionEdit->setOnClickArgs(self::ACTION_USR_PROFILES_EDIT);
|
||||
$GridActionEdit->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_USR_PROFILES_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Perfil'));
|
||||
$GridActionDel->setTitle(_('Eliminar Perfil'));
|
||||
$GridActionDel->setIcon($this->_icons->getIconDelete());
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_USR_PROFILES_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Nombre'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('userprofile_id');
|
||||
$GridData->addDataRowSource('userprofile_name');
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblProfiles');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionNew);
|
||||
$Grid->setDataActions($GridActionSearch);
|
||||
$Grid->setDataActions($GridActionView);
|
||||
$Grid->setDataActions($GridActionEdit);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridActionSearch));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Perfiles'));
|
||||
$Grid->setTime(round(microtime() - $this->_queryTimeStart, 5));
|
||||
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataGridTab
|
||||
*/
|
||||
public function getTokensGrid()
|
||||
{
|
||||
$GridActionSearch = new DataGridActionSearch();
|
||||
$GridActionSearch->setId(self::ACTION_MGM_APITOKENS_SEARCH);
|
||||
$GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
|
||||
$GridActionSearch->setName('frmSearchToken');
|
||||
$GridActionSearch->setTitle(_('Buscar Token'));
|
||||
$GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
|
||||
$GridActionSearch->setOnSubmitArgs('this');
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::ACTION_MGM_APITOKENS_NEW);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setName(_('Nueva Autorización'));
|
||||
$GridActionNew->setTitle(_('Nueva Autorización'));
|
||||
$GridActionNew->setIcon($this->_icons->getIconAdd());
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_MGM_APITOKENS_NEW);
|
||||
$GridActionNew->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionView = new DataGridAction();
|
||||
$GridActionView->setId(self::ACTION_MGM_APITOKENS_VIEW);
|
||||
$GridActionView->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionView->setName(_('Ver token de Autorización'));
|
||||
$GridActionView->setTitle(_('Ver token de Autorización'));
|
||||
$GridActionView->setIcon($this->_icons->getIconView());
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
$GridActionView->setOnClickArgs(self::ACTION_MGM_APITOKENS_VIEW);
|
||||
$GridActionView->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(self::ACTION_MGM_APITOKENS_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(_('Editar Autorización'));
|
||||
$GridActionEdit->setTitle(_('Editar Autorización'));
|
||||
$GridActionEdit->setIcon($this->_icons->getIconEdit());
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
$GridActionEdit->setOnClickArgs(self::ACTION_MGM_APITOKENS_EDIT);
|
||||
$GridActionEdit->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_MGM_APITOKENS_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Autorización'));
|
||||
$GridActionDel->setTitle(_('Eliminar Autorización'));
|
||||
$GridActionDel->setIcon($this->_icons->getIconDelete());
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_MGM_APITOKENS_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Usuario'));
|
||||
$GridHeaders->addHeader(_('Acción'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('authtoken_id');
|
||||
$GridData->addDataRowSource('user_login');
|
||||
$GridData->addDataRowSource('authtoken_actionId');
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblTokens');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionNew);
|
||||
$Grid->setDataActions($GridActionSearch);
|
||||
$Grid->setDataActions($GridActionView);
|
||||
$Grid->setDataActions($GridActionEdit);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridActionSearch));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Autorizaciones API'));
|
||||
$Grid->setTime(round(microtime() - $this->_queryTimeStart, 5));
|
||||
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataGridTab
|
||||
*/
|
||||
public function getPublicLinksGrid()
|
||||
{
|
||||
$GridActionSearch = new DataGridActionSearch();
|
||||
$GridActionSearch->setId(self::ACTION_MGM_PUBLICLINKS_SEARCH);
|
||||
$GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
|
||||
$GridActionSearch->setName('frmSearchLink');
|
||||
$GridActionSearch->setTitle(_('Buscar Enlace'));
|
||||
$GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
|
||||
$GridActionSearch->setOnSubmitArgs('this');
|
||||
|
||||
$GridActionView = new DataGridAction();
|
||||
$GridActionView->setId(self::ACTION_MGM_PUBLICLINKS_VIEW);
|
||||
$GridActionView->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionView->setName(_('Ver Enlace'));
|
||||
$GridActionView->setTitle(_('Ver Enlace'));
|
||||
$GridActionView->setIcon($this->_icons->getIconView());
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
$GridActionView->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_VIEW);
|
||||
$GridActionView->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionRefresh = new DataGridAction();
|
||||
$GridActionRefresh->setId(self::ACTION_MGM_PUBLICLINKS_REFRESH);
|
||||
$GridActionRefresh->setName(_('Renovar Enlace'));
|
||||
$GridActionRefresh->setTitle(_('Renovar Enlace'));
|
||||
$GridActionRefresh->setIcon($this->_icons->getIconRefresh());
|
||||
$GridActionRefresh->setOnClickFunction('sysPassUtil.Common.linksMgmtRefresh');
|
||||
$GridActionRefresh->setOnClickArgs('this');
|
||||
$GridActionRefresh->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_REFRESH);
|
||||
$GridActionRefresh->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_MGM_PUBLICLINKS_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Enlace'));
|
||||
$GridActionDel->setTitle(_('Eliminar Enlace'));
|
||||
$GridActionDel->setIcon($this->_icons->getIconDelete());
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->_sk);
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Cuenta'));
|
||||
$GridHeaders->addHeader(_('Fecha Creación'));
|
||||
$GridHeaders->addHeader(_('Fecha Caducidad'));
|
||||
$GridHeaders->addHeader(_('Usuario'));
|
||||
$GridHeaders->addHeader(_('Notificar'));
|
||||
$GridHeaders->addHeader(_('Visitas'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('publicLink_id');
|
||||
$GridData->addDataRowSource('publicLink_account');
|
||||
$GridData->addDataRowSource('publicLink_dateAdd');
|
||||
$GridData->addDataRowSource('publicLink_dateExpire');
|
||||
$GridData->addDataRowSource('publicLink_user');
|
||||
$GridData->addDataRowSource('publicLink_notify');
|
||||
$GridData->addDataRowSource('publicLink_views');
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblLinks');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionSearch);
|
||||
$Grid->setDataActions($GridActionView);
|
||||
$Grid->setDataActions($GridActionRefresh);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridActionSearch));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Enlaces'));
|
||||
$Grid->setTime(round(microtime() - $this->_queryTimeStart, 5));
|
||||
|
||||
return $Grid;
|
||||
}
|
||||
/**
|
||||
* @param boolean $filter
|
||||
*/
|
||||
|
||||
@@ -66,6 +66,38 @@ class Icons
|
||||
* @var DataGridIcon
|
||||
*/
|
||||
private $_iconNavLast;
|
||||
/**
|
||||
* @var DataGridIcon
|
||||
*/
|
||||
private $_iconEditPass;
|
||||
/**
|
||||
* @var DataGridIcon
|
||||
*/
|
||||
private $_iconAppAdmin;
|
||||
/**
|
||||
* @var DataGridIcon
|
||||
*/
|
||||
private $_iconAccAdmin;
|
||||
/**
|
||||
* @var DataGridIcon
|
||||
*/
|
||||
private $_iconLdapUser;
|
||||
/**
|
||||
* @var DataGridIcon
|
||||
*/
|
||||
private $_iconDisabled;
|
||||
|
||||
/**
|
||||
* @return DataGridIcon
|
||||
*/
|
||||
public function getIconRefresh()
|
||||
{
|
||||
return $this->_iconRefresh;
|
||||
}
|
||||
/**
|
||||
* @var DataGridIcon
|
||||
*/
|
||||
private $_iconRefresh;
|
||||
|
||||
/**
|
||||
* Icons constructor.
|
||||
@@ -84,6 +116,15 @@ class Icons
|
||||
$this->_iconView = new DataGridIcon('visibility', 'imgs/view.png', 'fg-blue80');
|
||||
$this->_iconEdit = new DataGridIcon('mode_edit', 'imgs/edit.png', 'fg-orange80');
|
||||
$this->_iconDelete = new DataGridIcon('delete', 'imgs/delete.png', 'fg-red80');
|
||||
$this->_iconEditPass = new DataGridIcon('lock_outline', 'imgs/pass.png', 'fg-orange80');
|
||||
$this->_iconAppAdmin = new DataGridIcon('star', 'check_blue.png', null, _('Admin Aplicación'));
|
||||
$this->_iconAccAdmin = new DataGridIcon('star_half', 'check_orange.png', null, _('Admin Cuentas'));
|
||||
$this->_iconLdapUser = new DataGridIcon('business', 'ldap.png', null, _('Usuario de LDAP'));
|
||||
$this->_iconDisabled = new DataGridIcon('error', 'disabled.png', null, _('Deshabilitado'));
|
||||
$this->_iconRefresh = new DataGridIcon('refresh', 'imgs/view.png', 'fg-green80');
|
||||
|
||||
|
||||
// Iconos de Navegación
|
||||
$this->_iconNavPrev = new DataGridIcon('chevron_left', 'imgs/arrow_left.png');
|
||||
$this->_iconNavPrev->setTitle(_('Página anterior'));
|
||||
$this->_iconNavNext = new DataGridIcon('chevron_right', 'imgs/arrow_right.png');
|
||||
@@ -94,6 +135,46 @@ class Icons
|
||||
$this->_iconNavLast->setTitle(_('Última página'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataGridIcon
|
||||
*/
|
||||
public function getIconEditPass()
|
||||
{
|
||||
return $this->_iconEditPass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataGridIcon
|
||||
*/
|
||||
public function getIconAppAdmin()
|
||||
{
|
||||
return $this->_iconAppAdmin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataGridIcon
|
||||
*/
|
||||
public function getIconAccAdmin()
|
||||
{
|
||||
return $this->_iconAccAdmin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataGridIcon
|
||||
*/
|
||||
public function getIconLdapUser()
|
||||
{
|
||||
return $this->_iconLdapUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataGridIcon
|
||||
*/
|
||||
public function getIconDisabled()
|
||||
{
|
||||
return $this->_iconDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataGridIcon
|
||||
*/
|
||||
|
||||
@@ -1,647 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2015 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\Controller;
|
||||
|
||||
use SP\Api\ApiTokens;
|
||||
use SP\Config\Config;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Html\DataGrid\DataGridAction;
|
||||
use SP\Html\DataGrid\DataGridActionType;
|
||||
use SP\Html\DataGrid\DataGridData;
|
||||
use SP\Html\DataGrid\DataGridHeader;
|
||||
use SP\Html\DataGrid\DataGridIcon;
|
||||
use SP\Html\DataGrid\DataGridPager;
|
||||
use SP\Html\DataGrid\DataGridTab;
|
||||
use SP\Http\Request;
|
||||
use SP\Mgmt\PublicLinkUtil;
|
||||
use SP\Mgmt\CustomFields;
|
||||
use SP\Mgmt\User\Groups;
|
||||
use SP\Log\Log;
|
||||
use SP\Mgmt\User\Profile;
|
||||
use SP\Core\Session;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Core\Template;
|
||||
use SP\Mgmt\User\UserUtil;
|
||||
use SP\Storage\DBUtil;
|
||||
use SP\Util\Checks;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
/**
|
||||
* Clase encargada de de preparar la presentación de las vistas de gestión de usuarios
|
||||
*
|
||||
* @package Controller
|
||||
*/
|
||||
class UsersMgmt extends Controller implements ActionsInterface
|
||||
{
|
||||
/**
|
||||
* Máximo numero de acciones antes de agrupar
|
||||
*/
|
||||
const MAX_NUM_ACTIONS = 3;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $_module = 0;
|
||||
/**
|
||||
* @var Icons
|
||||
*/
|
||||
private $_icons;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param $template Template con instancia de plantilla
|
||||
*/
|
||||
public function __construct(Template $template = null)
|
||||
{
|
||||
parent::__construct($template);
|
||||
|
||||
$this->view->assign('isDemo', Checks::demoIsEnabled());
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
|
||||
$this->_icons = new Icons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la pestaña de usuarios
|
||||
*/
|
||||
public function getUsersList()
|
||||
{
|
||||
$this->setAction(self::ACTION_USR_USERS);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::ACTION_USR_USERS_NEW);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setName(_('Nuevo Usuario'));
|
||||
$GridActionNew->setTitle(_('Nuevo Usuario'));
|
||||
$GridActionNew->setIcon($this->_icons->getIconAdd());
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_USR_USERS_NEW);
|
||||
$GridActionNew->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionView = new DataGridAction();
|
||||
$GridActionView->setId(self::ACTION_USR_USERS_VIEW);
|
||||
$GridActionView->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionView->setName(_('Ver Detalles de Usuario'));
|
||||
$GridActionView->setTitle(_('Ver Detalles de Usuario'));
|
||||
$GridActionView->setIcon($this->_icons->getIconView());
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
$GridActionView->setOnClickArgs(self::ACTION_USR_USERS_VIEW);
|
||||
$GridActionView->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(self::ACTION_USR_USERS_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(_('Editar Usuario'));
|
||||
$GridActionEdit->setTitle(_('Editar Usuario'));
|
||||
$GridActionEdit->setIcon($this->_icons->getIconEdit());
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
$GridActionEdit->setOnClickArgs(self::ACTION_USR_USERS_EDIT);
|
||||
$GridActionEdit->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_USR_USERS_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Usuario'));
|
||||
$GridActionDel->setTitle(_('Eliminar Usuario'));
|
||||
$GridActionDel->setIcon($this->_icons->getIconDelete());
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_USR_USERS_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionEditPass = new DataGridAction();
|
||||
$GridActionEditPass->setId(self::ACTION_USR_USERS_EDITPASS);
|
||||
$GridActionEditPass->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEditPass->setName(_('Cambiar Clave de Usuario'));
|
||||
$GridActionEditPass->setTitle(_('Cambiar Clave de Usuario'));
|
||||
$GridActionEditPass->setIcon(new DataGridIcon('lock_outline', 'imgs/pass.png', 'fg-orange80'));
|
||||
$GridActionEditPass->setOnClickFunction('sysPassUtil.Common.usrUpdPass');
|
||||
$GridActionEditPass->setOnClickArgs('this');
|
||||
$GridActionEditPass->setOnClickArgs(self::ACTION_USR_USERS_EDITPASS);
|
||||
$GridActionEditPass->setOnClickArgs($this->view->sk);
|
||||
$GridActionEditPass->setFilterRowSource('user_isLdap');
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Nombre'));
|
||||
$GridHeaders->addHeader(_('Login'));
|
||||
$GridHeaders->addHeader(_('Perfil'));
|
||||
$GridHeaders->addHeader(_('Grupo'));
|
||||
$GridHeaders->addHeader(_('Propiedades'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('user_id');
|
||||
$GridData->addDataRowSource('user_name');
|
||||
$GridData->addDataRowSource('user_login');
|
||||
$GridData->addDataRowSource('userprofile_name');
|
||||
$GridData->addDataRowSource('usergroup_name');
|
||||
$GridData->addDataRowSourceWithIcon('user_isAdminApp', new DataGridIcon('star', 'check_blue.png', null, _('Admin Cuentas')));
|
||||
$GridData->addDataRowSourceWithIcon('user_isAdminAcc', new DataGridIcon('star_half', 'check_orange.png', null, _('Admin Cuentas')));
|
||||
$GridData->addDataRowSourceWithIcon('user_isLdap', new DataGridIcon('business', 'ldap.png', null, _('Usuario de LDAP')));
|
||||
$GridData->addDataRowSourceWithIcon('user_isDisabled', new DataGridIcon('error', 'disabled.png', null, _('Deshabilitado')));
|
||||
$GridData->setData(UserUtil::getUsers());
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblUsers');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionNew);
|
||||
$Grid->setDataActions($GridActionView);
|
||||
$Grid->setDataActions($GridActionEdit);
|
||||
$Grid->setDataActions($GridActionEditPass);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Usuarios'));
|
||||
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la pestaña de grupos
|
||||
*/
|
||||
public function getGroupsList()
|
||||
{
|
||||
$this->setAction(self::ACTION_USR_GROUPS);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::ACTION_USR_GROUPS_NEW);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setName(_('Nuevo Grupo'));
|
||||
$GridActionNew->setTitle(_('Nuevo Grupo'));
|
||||
$GridActionNew->setIcon($this->_icons->getIconAdd());
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_USR_GROUPS_NEW);
|
||||
$GridActionNew->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(self::ACTION_USR_GROUPS_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(_('Editar Grupo'));
|
||||
$GridActionEdit->setTitle(_('Editar Grupo'));
|
||||
$GridActionEdit->setIcon($this->_icons->getIconEdit());
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
$GridActionEdit->setOnClickArgs(self::ACTION_USR_GROUPS_EDIT);
|
||||
$GridActionEdit->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_USR_GROUPS_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Grupo'));
|
||||
$GridActionDel->setTitle(_('Eliminar Grupo'));
|
||||
$GridActionDel->setIcon($this->_icons->getIconDelete());
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_USR_GROUPS_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Nombre'));
|
||||
$GridHeaders->addHeader(_('Descripción'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('usergroup_id');
|
||||
$GridData->addDataRowSource('usergroup_name');
|
||||
$GridData->addDataRowSource('usergroup_description');
|
||||
$GridData->setData(Groups::getGroups());
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblGroups');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionNew);
|
||||
$Grid->setDataActions($GridActionEdit);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Grupos'));
|
||||
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la pestaña de perfiles
|
||||
*/
|
||||
public function getProfilesList()
|
||||
{
|
||||
$this->setAction(self::ACTION_USR_PROFILES);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::ACTION_USR_PROFILES_NEW);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setName(_('Nuevo Perfil'));
|
||||
$GridActionNew->setTitle(_('Nuevo Perfil'));
|
||||
$GridActionNew->setIcon($this->_icons->getIconAdd());
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_USR_PROFILES_NEW);
|
||||
$GridActionNew->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionView = new DataGridAction();
|
||||
$GridActionView->setId(self::ACTION_USR_PROFILES_VIEW);
|
||||
$GridActionView->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionView->setName(_('Ver Detalles de Perfil'));
|
||||
$GridActionView->setTitle(_('Ver Detalles de Perfil'));
|
||||
$GridActionView->setIcon($this->_icons->getIconView());
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
$GridActionView->setOnClickArgs(self::ACTION_USR_PROFILES_VIEW);
|
||||
$GridActionView->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(self::ACTION_USR_PROFILES_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(_('Editar Perfil'));
|
||||
$GridActionEdit->setTitle(_('Editar Perfil'));
|
||||
$GridActionEdit->setIcon($this->_icons->getIconEdit());
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
$GridActionEdit->setOnClickArgs(self::ACTION_USR_PROFILES_EDIT);
|
||||
$GridActionEdit->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_USR_PROFILES_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Perfil'));
|
||||
$GridActionDel->setTitle(_('Eliminar Perfil'));
|
||||
$GridActionDel->setIcon($this->_icons->getIconDelete());
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_USR_PROFILES_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Nombre'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('userprofile_id');
|
||||
$GridData->addDataRowSource('userprofile_name');
|
||||
$GridData->setData(Profile::getProfiles());
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblProfiles');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionNew);
|
||||
$Grid->setDataActions($GridActionView);
|
||||
$Grid->setDataActions($GridActionEdit);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Perfiles'));
|
||||
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar las plantillas para las pestañas
|
||||
*/
|
||||
public function useTabs()
|
||||
{
|
||||
$this->view->addTemplate('datatabs-grid');
|
||||
|
||||
$this->view->assign('tabs', array());
|
||||
$this->view->assign('activeTab', 0);
|
||||
$this->view->assign('maxNumActions', self::MAX_NUM_ACTIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la ficha de usuario
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
$this->_module = self::ACTION_USR_USERS;
|
||||
$this->view->addTemplate('users');
|
||||
|
||||
$this->view->assign('user', UserUtil::getUserData($this->view->itemId));
|
||||
$this->view->assign('isDisabled', (($this->view->user['user_login'] === 'demo' && $this->view->isDemo) || $this->view->actionId === self::ACTION_USR_USERS_VIEW) ? 'disabled' : '');
|
||||
$this->view->assign('groups', DBUtil::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name'));
|
||||
$this->view->assign('profiles', DBUtil::getValuesForSelect('usrProfiles', 'userprofile_id', 'userprofile_name'));
|
||||
$this->view->assign('ro', ($this->view->user['checks']['user_isLdap']) ? 'READONLY' : '');
|
||||
|
||||
$this->getCustomFieldsForItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener la lista de campos personalizados y sus valores
|
||||
*/
|
||||
private function getCustomFieldsForItem()
|
||||
{
|
||||
// Se comprueba que hayan campos con valores para el elemento actual
|
||||
if ($this->view->itemId && CustomFields::checkCustomFieldExists($this->_module, $this->view->itemId)) {
|
||||
$this->view->assign('customFields', CustomFields::getCustomFieldsData($this->_module, $this->view->itemId));
|
||||
} else {
|
||||
$this->view->assign('customFields', CustomFields::getCustomFieldsForModule($this->_module));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la ficha de grupo
|
||||
*/
|
||||
public function getGroup()
|
||||
{
|
||||
$this->_module = self::ACTION_USR_GROUPS;
|
||||
$this->view->addTemplate('groups');
|
||||
|
||||
$this->view->assign('group', Groups::getGroupData($this->view->itemId));
|
||||
$this->view->assign('users', DBUtil::getValuesForSelect('usrData', 'user_id', 'user_name'));
|
||||
$this->view->assign('groupUsers', Groups::getUsersForGroup($this->view->itemId));
|
||||
|
||||
$this->getCustomFieldsForItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la ficha de perfil
|
||||
*/
|
||||
public function getProfile()
|
||||
{
|
||||
$this->view->addTemplate('profiles');
|
||||
|
||||
$profile = ($this->view->itemId) ? Profile::getProfile($this->view->itemId) : new Profile();
|
||||
|
||||
$this->view->assign('profile', $profile);
|
||||
$this->view->assign('isDisabled', ($this->view->actionId === self::ACTION_USR_PROFILES_VIEW) ? 'disabled' : '');
|
||||
|
||||
if ($this->view->isView === true) {
|
||||
$this->view->assign('usedBy', Profile::getProfileInUsersName($this->view->itemId));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar la vista de cambio de clave de usuario
|
||||
*/
|
||||
public function getUserPass()
|
||||
{
|
||||
$this->setAction(self::ACTION_USR_USERS_EDITPASS);
|
||||
|
||||
// Comprobar si el usuario a modificar es distinto al de la sesión
|
||||
if ($this->view->userId != Session::getUserId() && !$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('userspass');
|
||||
|
||||
$this->view->assign('actionId', self::ACTION_USR_USERS_EDITPASS);
|
||||
|
||||
// Obtener de nuevo el token de seguridad por si se habñia regenerado antes
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la pestaña de tokens de API
|
||||
*/
|
||||
public function getAPITokensList()
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_APITOKENS);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::ACTION_MGM_APITOKENS_NEW);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setName(_('Nueva Autorización'));
|
||||
$GridActionNew->setTitle(_('Nueva Autorización'));
|
||||
$GridActionNew->setIcon($this->_icons->getIconAdd());
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_MGM_APITOKENS_NEW);
|
||||
$GridActionNew->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionView = new DataGridAction();
|
||||
$GridActionView->setId(self::ACTION_MGM_APITOKENS_VIEW);
|
||||
$GridActionView->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionView->setName(_('Ver token de Autorización'));
|
||||
$GridActionView->setTitle(_('Ver token de Autorización'));
|
||||
$GridActionView->setIcon($this->_icons->getIconView());
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
$GridActionView->setOnClickArgs(self::ACTION_MGM_APITOKENS_VIEW);
|
||||
$GridActionView->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(self::ACTION_MGM_APITOKENS_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(_('Editar Autorización'));
|
||||
$GridActionEdit->setTitle(_('Editar Autorización'));
|
||||
$GridActionEdit->setIcon($this->_icons->getIconEdit());
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
$GridActionEdit->setOnClickArgs(self::ACTION_MGM_APITOKENS_EDIT);
|
||||
$GridActionEdit->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_MGM_APITOKENS_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Autorización'));
|
||||
$GridActionDel->setTitle(_('Eliminar Autorización'));
|
||||
$GridActionDel->setIcon($this->_icons->getIconDelete());
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_MGM_APITOKENS_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Usuario'));
|
||||
$GridHeaders->addHeader(_('Acción'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('authtoken_id');
|
||||
$GridData->addDataRowSource('user_login');
|
||||
$GridData->addDataRowSource('authtoken_actionId');
|
||||
$GridData->setData(ApiTokens::getTokens());
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblTokens');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionNew);
|
||||
$Grid->setDataActions($GridActionView);
|
||||
$Grid->setDataActions($GridActionEdit);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Autorizaciones API'));
|
||||
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la ficha de tokens de API
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
$this->view->addTemplate('tokens');
|
||||
|
||||
$token = ApiTokens::getTokens($this->view->itemId, true);
|
||||
|
||||
$this->view->assign('users', DBUtil::getValuesForSelect('usrData', 'user_id', 'user_name'));
|
||||
$this->view->assign('actions', ApiTokens::getTokenActions());
|
||||
$this->view->assign('token', $token);
|
||||
$this->view->assign('gotData', is_object($token));
|
||||
|
||||
if ($this->view->isView === true) {
|
||||
$msg = sprintf('%s ;;Usuario: %s', _('Token de autorización visualizado'), $token->user_login);
|
||||
Log::writeNewLogAndEmail(_('Autorizaciones'), $msg, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la pestaña de tokens de API
|
||||
*/
|
||||
public function getPublicLinksList()
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_PUBLICLINKS);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$GridActionView = new DataGridAction();
|
||||
$GridActionView->setId(self::ACTION_MGM_PUBLICLINKS_VIEW);
|
||||
$GridActionView->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionView->setName(_('Ver Enlace'));
|
||||
$GridActionView->setTitle(_('Ver Enlace'));
|
||||
$GridActionView->setIcon($this->_icons->getIconView());
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
$GridActionView->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_VIEW);
|
||||
$GridActionView->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionRefresh = new DataGridAction();
|
||||
$GridActionRefresh->setId(self::ACTION_MGM_PUBLICLINKS_REFRESH);
|
||||
$GridActionRefresh->setName(_('Renovar Enlace'));
|
||||
$GridActionRefresh->setTitle(_('Renovar Enlace'));
|
||||
$GridActionRefresh->setIcon(new DataGridIcon('refresh', 'imgs/view.png', 'fg-green80'));
|
||||
$GridActionRefresh->setOnClickFunction('sysPassUtil.Common.linksMgmtRefresh');
|
||||
$GridActionRefresh->setOnClickArgs('this');
|
||||
$GridActionRefresh->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_REFRESH);
|
||||
$GridActionRefresh->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_MGM_PUBLICLINKS_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Enlace'));
|
||||
$GridActionDel->setTitle(_('Eliminar Enlace'));
|
||||
$GridActionDel->setIcon($this->_icons->getIconDelete());
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Cuenta'));
|
||||
$GridHeaders->addHeader(_('Fecha Creación'));
|
||||
$GridHeaders->addHeader(_('Fecha Caducidad'));
|
||||
$GridHeaders->addHeader(_('Usuario'));
|
||||
$GridHeaders->addHeader(_('Notificar'));
|
||||
$GridHeaders->addHeader(_('Visitas'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('publicLink_id');
|
||||
$GridData->addDataRowSource('publicLink_account');
|
||||
$GridData->addDataRowSource('publicLink_dateAdd');
|
||||
$GridData->addDataRowSource('publicLink_dateExpire');
|
||||
$GridData->addDataRowSource('publicLink_user');
|
||||
$GridData->addDataRowSource('publicLink_notify');
|
||||
$GridData->addDataRowSource('publicLink_views');
|
||||
$GridData->setData(PublicLinkUtil::getLinks());
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblLinks');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionView);
|
||||
$Grid->setDataActions($GridActionRefresh);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Enlaces'));
|
||||
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la ficha de enlace público
|
||||
*/
|
||||
public function getPublicLink()
|
||||
{
|
||||
$this->view->addTemplate('publiclinks');
|
||||
|
||||
$this->view->assign('link', PublicLinkUtil::getLinks($this->view->itemId)[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el paginador
|
||||
*
|
||||
* @param int $numRows El número de registros devueltos
|
||||
* @param bool $filter Si está activo el filtrado
|
||||
* @return DataGridPager
|
||||
*/
|
||||
public function getPager($numRows, $filter = false)
|
||||
{
|
||||
$GridPager = new DataGridPager();
|
||||
$GridPager->setFilterOn($filter);
|
||||
$GridPager->setTotalRows($numRows);
|
||||
$GridPager->setLimitStart(Request::analyze('start', 0));
|
||||
$GridPager->setLimitCount(Request::analyze('count', Config::getValue('account_count', 15)));
|
||||
$GridPager->setOnClickFunction('sysPassUtil.Common.searchSort');
|
||||
|
||||
return $GridPager;
|
||||
}
|
||||
}
|
||||
@@ -99,16 +99,19 @@ interface ActionsInterface {
|
||||
const ACTION_USR_USERS_EDIT = 712;
|
||||
const ACTION_USR_USERS_DELETE = 713;
|
||||
const ACTION_USR_USERS_EDITPASS = 714;
|
||||
const ACTION_USR_USERS_SEARCH = 715;
|
||||
const ACTION_USR_GROUPS = 72;
|
||||
const ACTION_USR_GROUPS_VIEW = 720;
|
||||
const ACTION_USR_GROUPS_NEW = 721;
|
||||
const ACTION_USR_GROUPS_EDIT = 722;
|
||||
const ACTION_USR_GROUPS_DELETE = 723;
|
||||
const ACTION_USR_GROUPS_SEARCH = 725;
|
||||
const ACTION_USR_PROFILES = 73;
|
||||
const ACTION_USR_PROFILES_VIEW = 730;
|
||||
const ACTION_USR_PROFILES_NEW = 731;
|
||||
const ACTION_USR_PROFILES_EDIT = 732;
|
||||
const ACTION_USR_PROFILES_DELETE = 733;
|
||||
const ACTION_USR_PROFILES_SEARCH = 735;
|
||||
const ACTION_USR_PREFERENCES = 740;
|
||||
const ACTION_USR_PREFERENCES_GENERAL = 741;
|
||||
const ACTION_USR_PREFERENCES_SECURITY = 742;
|
||||
|
||||
@@ -32,6 +32,7 @@ use SP\Http\Request;
|
||||
use SP\Log\Email;
|
||||
use SP\Log\Log;
|
||||
use SP\Mgmt\User\Profile;
|
||||
use SP\Mgmt\User\ProfileUtil;
|
||||
use SP\Storage\DBUtil;
|
||||
use SP\Util\Checks;
|
||||
use SP\Util\Util;
|
||||
@@ -560,7 +561,7 @@ class Init
|
||||
session_regenerate_id(true);
|
||||
Session::setSidStartTime(time());
|
||||
// Recargar los permisos del perfil de usuario
|
||||
Session::setUserProfile(Profile::getProfile(Session::getUserProfileId()));
|
||||
Session::setUserProfile(ProfileUtil::getProfile(Session::getUserProfileId()));
|
||||
// Regenerar la clave maestra
|
||||
SessionUtil::saveSessionMPass($sessionMPass);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
namespace SP\Core;
|
||||
|
||||
use SP\Mgmt\User\Profile;
|
||||
use SP\Mgmt\User\ProfileUtil;
|
||||
use SP\Mgmt\User\User;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
@@ -55,7 +56,7 @@ class SessionUtil
|
||||
Session::setUserIsAdminApp($User->isUserIsAdminApp());
|
||||
Session::setUserIsAdminAcc($User->isUserIsAdminAcc());
|
||||
Session::setUserIsLdap($User->isUserIsLdap());
|
||||
Session::setUserProfile(Profile::getProfile($User->getUserProfileId()));
|
||||
Session::setUserProfile(ProfileUtil::getProfile($User->getUserProfileId()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -360,7 +360,7 @@ class Category
|
||||
* @param string $search La cadena de búsqueda
|
||||
* @return array con el id de categoria como clave y en nombre como valor
|
||||
*/
|
||||
public static function getCategoriesSearch($limitCount, $limitStart = 0, $search = "")
|
||||
public static function getCategoriesMgmtSearch($limitCount, $limitStart = 0, $search = "")
|
||||
{
|
||||
$query = 'SELECT category_id, category_name,category_description FROM categories';
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class CustomFieldDef extends CustomFieldsBase
|
||||
* @param string $search La cadena de búsqueda
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function getCustomFieldsSearch($limitCount, $limitStart = 0, $search = '')
|
||||
public static function getCustomFieldsMgmtSearch($limitCount, $limitStart = 0, $search = '')
|
||||
{
|
||||
$query = 'SELECT customfielddef_id, customfielddef_module, customfielddef_field '
|
||||
. 'FROM customFieldsDef '
|
||||
|
||||
@@ -377,7 +377,7 @@ class Customer
|
||||
* @param string $search La cadena de búsqueda
|
||||
* @return array con el id de cliente como clave y el nombre como valor
|
||||
*/
|
||||
public static function getCustomersSearch($limitCount, $limitStart = 0, $search = '')
|
||||
public static function getCustomersMgmtSearch($limitCount, $limitStart = 0, $search = '')
|
||||
{
|
||||
$query = 'SELECT customer_id, customer_name, customer_description '
|
||||
. 'FROM customers';
|
||||
|
||||
@@ -289,14 +289,14 @@ class Files
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el listado de archivos
|
||||
* Obtener el listado de archivos de una búsqueda
|
||||
*
|
||||
* @param null $limitCount
|
||||
* @param null $limitStart
|
||||
* @param int $limitCount
|
||||
* @param int $limitStart
|
||||
* @param string $search La cadena de búsqueda
|
||||
* @return array|false Con los archivos de las cuentas.
|
||||
*/
|
||||
public static function getFileListSearch($limitCount, $limitStart = 0, $search = '')
|
||||
public static function getFilesMgmtSearch($limitCount, $limitStart = 0, $search = '')
|
||||
{
|
||||
$query = 'SELECT accfile_id,'
|
||||
. 'accfile_name,'
|
||||
|
||||
@@ -50,7 +50,7 @@ class PublicLinkUtil
|
||||
{
|
||||
$Data = new QueryData();
|
||||
|
||||
if (!is_null($id)){
|
||||
if (!is_null($id)) {
|
||||
$query = 'SELECT publicLink_id, publicLink_hash, publicLink_linkData ' .
|
||||
'FROM publicLinks ' .
|
||||
'WHERE publicLink_id = :id LIMIT 1';
|
||||
@@ -87,7 +87,7 @@ class PublicLinkUtil
|
||||
$link->publicLink_notify = ($PublicLink->isNotify()) ? _('ON') : _('OFF');
|
||||
$link->publicLink_dateAdd = date("Y-m-d H:i", $PublicLink->getDateAdd());
|
||||
$link->publicLink_dateExpire = date("Y-m-d H:i", $PublicLink->getDateExpire());
|
||||
$link->publicLink_views = $PublicLink->getCountViews() . '/' . $PublicLink->getMaxCountViews();
|
||||
$link->publicLink_views = $PublicLink->getCountViews() . '/' . $PublicLink->getMaxCountViews();
|
||||
$link->publicLink_useInfo = $PublicLink->getUseInfo();
|
||||
|
||||
$publicLinks[] = $link;
|
||||
@@ -95,4 +95,66 @@ class PublicLinkUtil
|
||||
|
||||
return $publicLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los enlaces creados para una búsqueda
|
||||
*
|
||||
* @param $limitCount
|
||||
* @param int $limitStart
|
||||
* @param string $search
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function getLinksMgmtSearch($limitCount, $limitStart = 0, $search = '')
|
||||
{
|
||||
$Data = new QueryData();
|
||||
|
||||
$query = 'SELECT publicLink_id, publicLink_hash, publicLink_linkData FROM publicLinks LIMIT ?, ?';
|
||||
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($limitStart);
|
||||
$Data->addParam($limitCount);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$publicLinks = array();
|
||||
$publicLinks['count'] = DB::$lastNumRows;
|
||||
|
||||
foreach ($queryRes as $data) {
|
||||
/**
|
||||
* @var PublicLink $PublicLink
|
||||
*/
|
||||
$PublicLink = unserialize($data->publicLink_linkData);
|
||||
|
||||
if (get_class($PublicLink) === '__PHP_Incomplete_Class') {
|
||||
$PublicLink = Util::castToClass('SP\Mgmt\PublicLink', $PublicLink);
|
||||
}
|
||||
|
||||
$link = new \stdClass();
|
||||
$link->publicLink_id = $data->publicLink_id;
|
||||
$link->publicLink_hash = $data->publicLink_hash;
|
||||
$link->publicLink_account = AccountUtil::getAccountNameById($PublicLink->getItemId());
|
||||
$link->publicLink_user = UserUtil::getUserLoginById($PublicLink->getUserId());
|
||||
$link->publicLink_notify = ($PublicLink->isNotify()) ? _('ON') : _('OFF');
|
||||
$link->publicLink_dateAdd = date("Y-m-d H:i", $PublicLink->getDateAdd());
|
||||
$link->publicLink_dateExpire = date("Y-m-d H:i", $PublicLink->getDateExpire());
|
||||
$link->publicLink_views = $PublicLink->getCountViews() . '/' . $PublicLink->getMaxCountViews();
|
||||
$link->publicLink_useInfo = $PublicLink->getUseInfo();
|
||||
|
||||
if (empty($search)
|
||||
|| stripos($link->publicLink_account, $search) !== false
|
||||
|| stripos($link->publicLink_user, $search) !== false
|
||||
){
|
||||
$publicLinks[] = $link;
|
||||
}
|
||||
}
|
||||
|
||||
return $publicLinks;
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class Groups
|
||||
/**
|
||||
* Obtener los grupos de usuarios.
|
||||
*
|
||||
* @param int $groupId opcional, con el Id del grupo a consultar
|
||||
* @param int $groupId opcional, con el Id del grupo a consultar
|
||||
* @param bool $returnArray opcional, si se debe de devolver un array asociativo
|
||||
* @return false|array con la lista de grupos
|
||||
*/
|
||||
@@ -179,7 +179,7 @@ class Groups
|
||||
/**
|
||||
* Crear asociación de grupos con usuarios.
|
||||
*
|
||||
* @param int $groupId con los grupos del usuario
|
||||
* @param int $groupId con los grupos del usuario
|
||||
* @param array $usersId Los usuarios del grupo
|
||||
* @return bool
|
||||
*/
|
||||
@@ -333,7 +333,7 @@ class Groups
|
||||
/**
|
||||
* Actualizar la asociación de grupos con usuarios.
|
||||
*
|
||||
* @param int $groupId con el Id del usuario
|
||||
* @param int $groupId con el Id del usuario
|
||||
* @param array $usersId con los usuarios del grupo
|
||||
* @return bool
|
||||
*/
|
||||
@@ -349,7 +349,7 @@ class Groups
|
||||
/**
|
||||
* Eliminar la asociación de grupos con usuarios.
|
||||
*
|
||||
* @param int $groupId con el Id del grupo
|
||||
* @param int $groupId con el Id del grupo
|
||||
* @param array $usersId opcional con los usuarios del grupo
|
||||
* @return bool
|
||||
*/
|
||||
@@ -514,8 +514,8 @@ class Groups
|
||||
/**
|
||||
* Actualizar la asociación de grupos con cuentas.
|
||||
*
|
||||
* @param int $accountId con el Id de la cuenta
|
||||
* @param array $groupsId con los grupos de la cuenta
|
||||
* @param int $accountId con el Id de la cuenta
|
||||
* @param array $groupsId con los grupos de la cuenta
|
||||
* @return bool
|
||||
*/
|
||||
public static function updateGroupsForAccount($accountId, $groupsId)
|
||||
@@ -530,8 +530,8 @@ class Groups
|
||||
/**
|
||||
* Eliminar la asociación de grupos con cuentas.
|
||||
*
|
||||
* @param int $accountId con el Id de la cuenta
|
||||
* @param array $groupsId opcional con los grupos de la cuenta
|
||||
* @param int $accountId con el Id de la cuenta
|
||||
* @param array $groupsId opcional con los grupos de la cuenta
|
||||
* @return bool
|
||||
*/
|
||||
public static function deleteGroupsForAccount($accountId, $groupsId = null)
|
||||
@@ -557,8 +557,8 @@ class Groups
|
||||
/**
|
||||
* Crear asociación de grupos con cuentas.
|
||||
*
|
||||
* @param int $accountId con el Id de la cuenta
|
||||
* @param array $groupsId con los grupos de la cuenta
|
||||
* @param int $accountId con el Id de la cuenta
|
||||
* @param array $groupsId con los grupos de la cuenta
|
||||
* @return bool
|
||||
*/
|
||||
public static function addGroupsForAccount($accountId, $groupsId)
|
||||
@@ -621,4 +621,51 @@ class Groups
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los grupos de usuarios de una búsqueda
|
||||
*
|
||||
* @param $limitCount
|
||||
* @param int $limitStart
|
||||
* @param string $search
|
||||
* @return array
|
||||
*/
|
||||
public static function getGroupsMgmtSearch($limitCount, $limitStart = 0, $search = '')
|
||||
{
|
||||
$query = 'SELECT usergroup_id,'
|
||||
. 'usergroup_name,'
|
||||
. 'usergroup_description '
|
||||
. 'FROM usrGroups';
|
||||
|
||||
$Data = new QueryData();
|
||||
|
||||
if (!empty($search)) {
|
||||
$search = '%' . $search . '%';
|
||||
$query .= ' WHERE usergroup_name LIKE ? OR usergroup_description LIKE ?';
|
||||
|
||||
$Data->addParam($search);
|
||||
$Data->addParam($search);
|
||||
}
|
||||
|
||||
$query .= ' ORDER BY usergroup_name';
|
||||
$query .= ' LIMIT ?, ?';
|
||||
|
||||
$Data->addParam($limitStart);
|
||||
$Data->addParam($limitCount);
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,59 +140,6 @@ abstract class ProfileBase
|
||||
*/
|
||||
protected $_mgmCustomFields = false;
|
||||
|
||||
/**
|
||||
* Obtener los datos de un perfil
|
||||
*
|
||||
* @param $id int El id del perfil a obtener
|
||||
* @return array|Profile
|
||||
* @throws SPException
|
||||
*/
|
||||
public static function getProfile($id)
|
||||
{
|
||||
$query = 'SELECT userprofile_profile FROM usrProfiles WHERE userprofile_id = :id LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id, 'id');
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Profile $profile
|
||||
*/
|
||||
$profile = unserialize($queryRes->userprofile_profile);
|
||||
|
||||
if (get_class($profile) === '__PHP_Incomplete_Class') {
|
||||
return Util::castToClass('SP\Mgmt\User\Profile', $profile);
|
||||
}
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los perfiles disponibles
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function getProfiles()
|
||||
{
|
||||
if (Checks::demoIsEnabled()) {
|
||||
$query = 'SELECT userprofile_id, userprofile_name FROM usrProfiles WHERE userprofile_name <> "Admin" AND userprofile_name <> "Demo" ORDER BY userprofile_name';
|
||||
} else {
|
||||
$query = 'SELECT userprofile_id, userprofile_name FROM usrProfiles ORDER BY userprofile_name';
|
||||
}
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
|
||||
145
inc/SP/Mgmt/User/ProfileUtil.class.php
Normal file
145
inc/SP/Mgmt/User/ProfileUtil.class.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2015 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\Mgmt\User;
|
||||
|
||||
use SP\Core\SPException;
|
||||
use SP\Storage\DB;
|
||||
use SP\Storage\QueryData;
|
||||
use SP\Util\Checks;
|
||||
use SP\Util\Util;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
/**
|
||||
* Class ProfileUtil
|
||||
*
|
||||
* @package SP\Mgmt\User
|
||||
*/
|
||||
class ProfileUtil
|
||||
{
|
||||
/**
|
||||
* Obtener los perfiles de una búsqueda
|
||||
*
|
||||
* @param $limitCount
|
||||
* @param int $limitStart
|
||||
* @param string $search
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function getProfilesMgmtSearch($limitCount, $limitStart = 0, $search = '')
|
||||
{
|
||||
$query = 'SELECT userprofile_id, userprofile_name FROM usrProfiles';
|
||||
|
||||
$Data = new QueryData();
|
||||
|
||||
if (!empty($search)) {
|
||||
$search = '%' . $search . '%';
|
||||
$query .= ' WHERE userprofile_name LIKE ?';
|
||||
|
||||
if (Checks::demoIsEnabled()) {
|
||||
$query .= ' userprofile_name <> "Admin" AND userprofile_name <> "Demo"';
|
||||
}
|
||||
|
||||
$Data->addParam($search);
|
||||
} elseif (Checks::demoIsEnabled()) {
|
||||
$query .= ' WHERE userprofile_name <> "Admin" AND userprofile_name <> "Demo"';
|
||||
}
|
||||
|
||||
$query .= ' ORDER BY userprofile_name';
|
||||
$query .= ' LIMIT ?, ?';
|
||||
|
||||
$Data->addParam($limitStart);
|
||||
$Data->addParam($limitCount);
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos de un perfil
|
||||
*
|
||||
* @param $id int El id del perfil a obtener
|
||||
* @return array|Profile
|
||||
* @throws SPException
|
||||
*/
|
||||
public static function getProfile($id)
|
||||
{
|
||||
$query = 'SELECT userprofile_profile FROM usrProfiles WHERE userprofile_id = :id LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id, 'id');
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Profile $profile
|
||||
*/
|
||||
$profile = unserialize($queryRes->userprofile_profile);
|
||||
|
||||
if (get_class($profile) === '__PHP_Incomplete_Class') {
|
||||
return Util::castToClass('SP\Mgmt\User\Profile', $profile);
|
||||
}
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los perfiles disponibles
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function getProfiles()
|
||||
{
|
||||
if (Checks::demoIsEnabled()) {
|
||||
$query = 'SELECT userprofile_id, userprofile_name FROM usrProfiles WHERE userprofile_name <> "Admin" AND userprofile_name <> "Demo" ORDER BY userprofile_name';
|
||||
} else {
|
||||
$query = 'SELECT userprofile_id, userprofile_name FROM usrProfiles ORDER BY userprofile_name';
|
||||
}
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
}
|
||||
}
|
||||
@@ -288,4 +288,66 @@ class UserUtil
|
||||
|
||||
return $queryRes->user_login;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer las variables para la consulta de usuarios.
|
||||
*
|
||||
* @param int $limitCount
|
||||
* @param int $limitStart
|
||||
* @param string $search
|
||||
* @return array|false con la lista de usuarios
|
||||
*/
|
||||
public static function getUsersMgmSearch($limitCount, $limitStart = 0, $search = '')
|
||||
{
|
||||
$Data = new QueryData();
|
||||
|
||||
$query = 'SELECT user_id,'
|
||||
. 'user_name,'
|
||||
. 'user_login,'
|
||||
. 'userprofile_name,'
|
||||
. 'usergroup_name,'
|
||||
. 'BIN(user_isAdminApp) AS user_isAdminApp,'
|
||||
. 'BIN(user_isAdminAcc) AS user_isAdminAcc,'
|
||||
. 'BIN(user_isLdap) AS user_isLdap,'
|
||||
. 'BIN(user_isDisabled) AS user_isDisabled,'
|
||||
. 'BIN(user_isChangePass) AS user_isChangePass '
|
||||
. 'FROM usrData '
|
||||
. 'LEFT JOIN usrProfiles ON user_profileId = userprofile_id '
|
||||
. 'LEFT JOIN usrGroups ON usrData.user_groupId = usergroup_id';
|
||||
|
||||
if (!empty($search)) {
|
||||
$search = '%' . $search . '%';
|
||||
|
||||
$query .= ' WHERE user_name LIKE ? '
|
||||
. 'OR user_login LIKE ?';
|
||||
|
||||
$query .= (!Session::getUserIsAdminApp()) ? ' AND user_isAdminApp = 0' : '';
|
||||
|
||||
$Data->addParam($search);
|
||||
$Data->addParam($search);
|
||||
} else {
|
||||
$query .= (!Session::getUserIsAdminApp()) ? ' WHERE user_isAdminApp = 0' : '';
|
||||
}
|
||||
|
||||
$query .= ' ORDER BY user_name';
|
||||
$query .= ' LIMIT ?, ?';
|
||||
|
||||
$Data->addParam($limitStart);
|
||||
$Data->addParam($limitCount);
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
}
|
||||
@@ -274,10 +274,8 @@ class DB
|
||||
if (!is_array($queryData->getParams())) {
|
||||
$queryRes = $db->query($query);
|
||||
$num = intval($queryRes->fetchColumn());
|
||||
} else {
|
||||
if ($queryRes = $this->prepareQueryData($queryData, true)) {
|
||||
$num = intval($queryRes->fetchColumn());
|
||||
}
|
||||
} elseif ($queryRes = $this->prepareQueryData($queryData, true)) {
|
||||
$num = intval($queryRes->fetchColumn());
|
||||
}
|
||||
|
||||
$queryRes->closeCursor();
|
||||
|
||||
Reference in New Issue
Block a user