mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-05 16:14:11 +01:00
* [DEV] Improved account search handling
This commit is contained in:
@@ -69,6 +69,12 @@ switch ($actionId) {
|
||||
$Controller = new AccItemController($Tpl);
|
||||
$Controller->getUser();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_USERS_EDITPASS:
|
||||
$Tpl->assign('header', _('Cambio de Clave'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
$Controller = new AccItemController($Tpl);
|
||||
$Controller->getUserPass();
|
||||
break;
|
||||
case ActionsInterface::ACTION_USR_USERS_NEW:
|
||||
$Tpl->assign('header', _('Nuevo Usuario'));
|
||||
$Tpl->assign('onCloseAction', ActionsInterface::ACTION_USR);
|
||||
|
||||
@@ -222,8 +222,8 @@ if ($UserPass->getClearUserMPass()) {
|
||||
SessionUtil::loadUserSession($User->getItemData());
|
||||
|
||||
$Log->addDetails(_('Usuario'), $User->getItemData()->getUserLogin());
|
||||
$Log->addDetails(_('Perfil'), Profile::getItem()->getById($User->getItemData()->getUserProfileId())->getItemData()->getUserprofileName());
|
||||
$Log->addDetails(_('Grupo'), Group::getItem()->getById($User->getItemData()->getUserGroupId())->getItemData()->getUsergroupName());
|
||||
$Log->addDetails(_('Perfil'), Profile::getItem()->getById($User->getItemData()->getUserProfileId())->getUserprofileName());
|
||||
$Log->addDetails(_('Grupo'), Group::getItem()->getById($User->getItemData()->getUserGroupId())->getUsergroupName());
|
||||
$Log->writeLog();
|
||||
} else {
|
||||
$Log->setLogLevel(Log::ERROR);
|
||||
@@ -234,7 +234,7 @@ if ($UserPass->getClearUserMPass()) {
|
||||
Json::returnJson($Json);
|
||||
}
|
||||
|
||||
$UserPreferencesData = UserPreferences::getItem()->getById($User->getItemData()->getUserId())->getItemData();
|
||||
$UserPreferencesData = UserPreferences::getItem()->getById($User->getItemData()->getUserId());
|
||||
Language::setLanguage(true);
|
||||
DiFactory::getTheme()->initTheme(true);
|
||||
Session::setUserPreferences($UserPreferencesData);
|
||||
|
||||
@@ -151,7 +151,7 @@ if ($actionId === ActionsInterface::ACTION_ACC_FILES_UPLOAD) {
|
||||
Response::printJson(_('No es un ID de archivo válido'));
|
||||
}
|
||||
|
||||
$FileData = File::getItem()->getById($fileId)->getItemData();
|
||||
$FileData = File::getItem()->getById($fileId);
|
||||
|
||||
if (!$FileData) {
|
||||
Response::printJson(_('El archivo no existe'));
|
||||
|
||||
@@ -112,7 +112,7 @@ if ($actionId === ActionsInterface::ACTION_USR_PREFERENCES_GENERAL) {
|
||||
}
|
||||
|
||||
try {
|
||||
$UserPreferencesData = UserPreferences::getItem()->getById($itemId)->getItemData();
|
||||
$UserPreferencesData = UserPreferences::getItem()->getById($itemId);
|
||||
$UserPreferencesData->setUse2Fa(Util::boolval($twoFaEnabled));
|
||||
UserPreferences::getItem($UserPreferencesData)->update();
|
||||
|
||||
|
||||
@@ -1,52 +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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
use SP\Controller\AccItemController;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\Template;
|
||||
use SP\Http\Request;
|
||||
use SP\Util\Util;
|
||||
|
||||
define('APP_ROOT', '..');
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
if (!Init::isLoggedIn()) {
|
||||
Util::logout();
|
||||
}
|
||||
|
||||
$userId = Request::analyze('userId', false);
|
||||
|
||||
if (!$userId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$Tpl = new Template();
|
||||
$Tpl->assign('userId', $userId);
|
||||
$Controller = new AccItemController($Tpl);
|
||||
$Controller->getUserPass();
|
||||
$Controller->view();
|
||||
@@ -353,6 +353,7 @@ class AccountSearch
|
||||
$queryLimit = '';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName('SP\DataModel\AccountSearchData');
|
||||
|
||||
if ($this->txtSearch) {
|
||||
// Analizar la cadena de búsqueda por etiquetas especiales
|
||||
@@ -380,7 +381,6 @@ class AccountSearch
|
||||
|
||||
$arrFilterCommon[] = 'account_notes LIKE ?';
|
||||
$Data->addParam($txtSearch);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,9 +397,6 @@ class AccountSearch
|
||||
if ($this->searchFavorites === true) {
|
||||
$arrayQueryJoin[] = 'INNER JOIN accFavorites ON (accfavorite_accountId = account_id AND accfavorite_userId = ?)';
|
||||
$Data->addParam(Session::getUserId());
|
||||
|
||||
// $arrFilterSelect[] = 'accfavorite_userId = ?';
|
||||
// $Data->addParam(Session::getUserId());
|
||||
}
|
||||
|
||||
if (count($arrFilterCommon) > 0) {
|
||||
@@ -411,36 +408,15 @@ class AccountSearch
|
||||
}
|
||||
|
||||
if (!$isAdmin && !$this->globalSearch) {
|
||||
/* $subQueryGroups = '(SELECT user_groupId FROM usrData WHERE user_id = ? UNION ALL SELECT usertogroup_groupId FROM usrToGroups WHERE usertogroup_userId = ?)';
|
||||
|
||||
// Buscar el grupo principal de la cuenta en los grupos del usuario
|
||||
$arrFilterUser[] = 'account_userGroupId IN ' . $subQueryGroups;
|
||||
$Data->addParam(Session::getUserId());
|
||||
$Data->addParam(Session::getUserId());
|
||||
|
||||
// Buscar los grupos secundarios de la cuenta en los grupos del usuario
|
||||
$arrFilterUser[] = 'accgroup_groupId IN ' . $subQueryGroups;
|
||||
$Data->addParam(Session::getUserId());
|
||||
$Data->addParam(Session::getUserId());
|
||||
|
||||
// Comprobar el usuario principal de la cuenta con el usuario actual
|
||||
$arrFilterUser[] = 'account_userId = ?';
|
||||
$Data->addParam(Session::getUserId());
|
||||
|
||||
// Comprobar los usuarios secundarios de la cuenta con el usuario actual
|
||||
$arrFilterUser[] = 'accuser_userId = ?';
|
||||
$Data->addParam(Session::getUserId());
|
||||
|
||||
$arrQueryWhere[] = '(' . implode(' OR ', $arrFilterUser) . ')';*/
|
||||
|
||||
$arrFilterUser[] = 'account_userId = ?';
|
||||
$Data->addParam(Session::getUserId());
|
||||
$arrFilterUser[] = 'account_userGroupId = ?';
|
||||
$Data->addParam(Session::getUserGroupId());
|
||||
$arrFilterUser[] = 'account_id IN (SELECT accuser_accountId FROM accUsers WHERE accuser_userId = ?)';
|
||||
$arrFilterUser[] = 'account_id IN (SELECT accuser_accountId AS accountId FROM accUsers WHERE accuser_accountId = account_id AND accuser_userId = ? UNION ALL SELECT accgroup_accountId AS accountId FROM accGroups WHERE accgroup_accountId = account_id AND accgroup_groupId = ?)';
|
||||
$Data->addParam(Session::getUserId());
|
||||
$arrFilterUser[] = 'account_userGroupId IN (SELECT usertogroup_groupId FROM usrToGroups WHERE usertogroup_userId = ?)';
|
||||
$Data->addParam(Session::getUserGroupId());
|
||||
$arrFilterUser[] = 'account_userGroupId IN (SELECT usertogroup_groupId FROM usrToGroups WHERE usertogroup_groupId = account_userGroupId AND usertogroup_userId = ?)';
|
||||
$Data->addParam(Session::getUserId());
|
||||
|
||||
$arrQueryWhere[] = '(' . implode(' OR ', $arrFilterUser) . ')';
|
||||
}
|
||||
@@ -452,12 +428,12 @@ class AccountSearch
|
||||
$Data->addParam($this->limitCount);
|
||||
}
|
||||
|
||||
$queryWhere = '';
|
||||
|
||||
if (count($arrQueryWhere) === 1) {
|
||||
$queryWhere = implode($arrQueryWhere);
|
||||
} elseif (count($arrQueryWhere) > 1) {
|
||||
$queryWhere = implode(' AND ', $arrQueryWhere);
|
||||
} else {
|
||||
$queryWhere = '';
|
||||
}
|
||||
|
||||
$queryJoin = implode('', $arrayQueryJoin);
|
||||
@@ -468,16 +444,14 @@ class AccountSearch
|
||||
$Data->setOrder($this->getOrderString());
|
||||
$Data->setLimit($queryLimit);
|
||||
|
||||
// $Data->setQuery($query);
|
||||
$Data->setMapClassName('SP\DataModel\AccountSearchData');
|
||||
|
||||
// Obtener el número total de cuentas visibles por el usuario
|
||||
DB::setFullRowCount();
|
||||
|
||||
// Obtener los resultados siempre en array de objetos
|
||||
DB::setReturnArray();
|
||||
|
||||
Log::writeNewLog(__FUNCTION__, $Data->getQuery(), Log::DEBUG);
|
||||
// Log::writeNewLog(__FUNCTION__, $Data->getQuery(), Log::DEBUG);
|
||||
// Log::writeNewLog(__FUNCTION__, print_r($Data->getParams(), true), Log::DEBUG);
|
||||
|
||||
// Consulta de la búsqueda de cuentas
|
||||
$queryRes = DB::getResults($Data);
|
||||
@@ -487,7 +461,7 @@ class AccountSearch
|
||||
}
|
||||
|
||||
// Obtenemos el número de registros totales de la consulta sin contar el LIMIT
|
||||
self::$queryNumRows = DB::$lastNumRows;
|
||||
self::$queryNumRows = $Data->getQueryNumRows();
|
||||
|
||||
// Establecer el filtro de búsqueda en la sesión como un objeto
|
||||
Session::setSearchFilters($this);
|
||||
|
||||
@@ -200,7 +200,7 @@ class AccountUtil
|
||||
return array();
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ class ApiTokens
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error interno'));
|
||||
}
|
||||
|
||||
if (DB::$lastNumRows === 1) {
|
||||
if ($Data->getQueryNumRows() === 1) {
|
||||
throw new SPException(SPException::SP_WARNING, _('La autorización ya existe'));
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ class ApiTokens
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error interno'));
|
||||
}
|
||||
|
||||
if (DB::$lastNumRows === 0) {
|
||||
if ($Data->getQueryNumRows() === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ class ApiTokensUtil
|
||||
$token->authtoken_actionId = Acl::getActionName($token->authtoken_actionId);
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ class ApiTokensUtil
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error interno'));
|
||||
}
|
||||
|
||||
if (DB::$lastNumRows === 0) {
|
||||
if ($Data->getQueryNumRows() === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ class Auth
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return (DB::$lastNumRows === 1);
|
||||
return ($Data->getQueryNumRows() === 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,7 @@ class AccItemController extends ControllerBase implements ActionsInterface
|
||||
$this->module = self::ACTION_USR_USERS;
|
||||
$this->view->addTemplate('users');
|
||||
|
||||
$this->view->assign('user', $this->view->itemId ? User::getItem()->getById($this->view->itemId)->getItemData() : new UserData());
|
||||
$this->view->assign('user', $this->view->itemId ? User::getItem()->getById($this->view->itemId) : new UserData());
|
||||
$this->view->assign('isDisabled', ((User::getItem()->getItemData()->getUserLogin() === 'demo' && $this->view->isDemo) || $this->view->actionId === self::ACTION_USR_USERS_VIEW) ? 'disabled' : '');
|
||||
$this->view->assign('groups', Group::getItem()->getItemsForSelect());
|
||||
$this->view->assign('profiles', Profile::getItem()->getItemsForSelect());
|
||||
@@ -111,7 +111,7 @@ class AccItemController extends ControllerBase implements ActionsInterface
|
||||
$this->module = self::ACTION_USR_GROUPS;
|
||||
$this->view->addTemplate('groups');
|
||||
|
||||
$this->view->assign('group', Group::getItem()->getById($this->view->itemId)->getItemData());
|
||||
$this->view->assign('group', Group::getItem()->getById($this->view->itemId));
|
||||
$this->view->assign('users', User::getItem()->getItemsForSelect());
|
||||
$this->view->assign('groupUsers', GroupUsers::getItem()->getById($this->view->itemId));
|
||||
|
||||
@@ -126,7 +126,7 @@ class AccItemController extends ControllerBase implements ActionsInterface
|
||||
$this->module = self::ACTION_USR_PROFILES;
|
||||
$this->view->addTemplate('profiles');
|
||||
|
||||
$Profile = $this->view->itemId ? Profile::getItem()->getById($this->view->itemId)->getItemData() : new ProfileData();
|
||||
$Profile = $this->view->itemId ? Profile::getItem()->getById($this->view->itemId) : new ProfileData();
|
||||
|
||||
$this->view->assign('profile', $Profile);
|
||||
$this->view->assign('isDisabled', ($this->view->actionId === self::ACTION_USR_PROFILES_VIEW) ? 'disabled' : '');
|
||||
@@ -159,13 +159,12 @@ class AccItemController extends ControllerBase implements ActionsInterface
|
||||
$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()) {
|
||||
if ($this->view->itemId !== Session::getUserId() && !$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->assign('user', User::getItem()->getById($this->view->itemId));
|
||||
$this->view->addTemplate('userspass');
|
||||
|
||||
$this->view->assign('actionId', self::ACTION_USR_USERS_EDITPASS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,6 +198,6 @@ class AccItemController extends ControllerBase implements ActionsInterface
|
||||
$this->module = self::ACTION_MGM_PUBLICLINKS;
|
||||
$this->view->addTemplate('publiclinks');
|
||||
|
||||
$this->view->assign('link', PublicLink::getItem()->getById($this->view->itemId)->getItemData());
|
||||
$this->view->assign('link', PublicLink::getItem()->getById($this->view->itemId));
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class AppItemController extends ControllerBase implements ActionsInterface
|
||||
$this->_module = self::ACTION_MGM_CUSTOMERS;
|
||||
$this->view->addTemplate('customers');
|
||||
|
||||
$this->view->assign('customer', ($this->view->itemId) ? Customer::getItem()->getById($this->view->itemId)->getItemData() : new CustomerData());
|
||||
$this->view->assign('customer', ($this->view->itemId) ? Customer::getItem()->getById($this->view->itemId) : new CustomerData());
|
||||
$this->getCustomFieldsForItem();
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class AppItemController extends ControllerBase implements ActionsInterface
|
||||
$this->_module = self::ACTION_MGM_CATEGORIES;
|
||||
$this->view->addTemplate('categories');
|
||||
|
||||
$this->view->assign('category', ($this->view->itemId) ? Category::getItem()->getById($this->view->itemId)->getItemData() : new CategoryData());
|
||||
$this->view->assign('category', ($this->view->itemId) ? Category::getItem()->getById($this->view->itemId) : new CategoryData());
|
||||
$this->getCustomFieldsForItem();
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class AppItemController extends ControllerBase implements ActionsInterface
|
||||
{
|
||||
$this->view->addTemplate('customfields');
|
||||
|
||||
$customField = ($this->view->itemId) ? CustomFieldDef::getItem()->getById($this->view->itemId)->getItemData() : new CustomFieldDefData();
|
||||
$customField = ($this->view->itemId) ? CustomFieldDef::getItem()->getById($this->view->itemId) : new CustomFieldDefData();
|
||||
|
||||
$this->view->assign('customField', $customField);
|
||||
$this->view->assign('field', $customField);
|
||||
@@ -147,6 +147,6 @@ class AppItemController extends ControllerBase implements ActionsInterface
|
||||
$this->_module = self::ACTION_MGM_TAGS;
|
||||
$this->view->addTemplate('tags');
|
||||
|
||||
$this->view->assign('tag', ($this->view->itemId) ? Tag::getItem()->getById($this->view->itemId)->getItemData() : new TagData());
|
||||
$this->view->assign('tag', ($this->view->itemId) ? Tag::getItem()->getById($this->view->itemId) : new TagData());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ class Grids implements ActionsInterface
|
||||
$GridActionEditPass->setName(_('Cambiar Clave de Usuario'));
|
||||
$GridActionEditPass->setTitle(_('Cambiar Clave de Usuario'));
|
||||
$GridActionEditPass->setIcon($this->icons->getIconEditPass());
|
||||
$GridActionEditPass->setOnClickFunction('user/password');
|
||||
$GridActionEditPass->setOnClickFunction('appMgmt/show');
|
||||
$GridActionEditPass->setFilterRowSource('user_isLdap');
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
|
||||
@@ -73,7 +73,7 @@ class UserPreferencesController extends ControllerBase implements ActionsInterfa
|
||||
$this->view->assign('tabs', array());
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
$this->userId = Session::getUserId();
|
||||
$this->userPrefs = UserPreferences::getItem()->getById($this->userId)->getItemData();
|
||||
$this->userPrefs = UserPreferences::getItem()->getById($this->userId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -640,7 +640,7 @@ class Init
|
||||
session_regenerate_id(true);
|
||||
Session::setSidStartTime(time());
|
||||
// Recargar los permisos del perfil de usuario
|
||||
Session::setUserProfile(Profile::getItem()->getById(Session::getUserProfileId())->getItemData());
|
||||
Session::setUserProfile(Profile::getItem()->getById(Session::getUserProfileId()));
|
||||
// Regenerar la clave maestra
|
||||
SessionUtil::saveSessionMPass($sessionMPass);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class Language
|
||||
*/
|
||||
private function getUserLang()
|
||||
{
|
||||
return (Session::getUserId() > 0) ? UserPreferences::getItem()->getById(Session::getUserId())->getItemData()->getLang() : '';
|
||||
return (Session::getUserId() > 0) ? UserPreferences::getItem()->getById(Session::getUserId())->getLang() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,7 +57,7 @@ class SessionUtil
|
||||
Session::setUserIsAdminApp($UserData->isUserIsAdminApp());
|
||||
Session::setUserIsAdminAcc($UserData->isUserIsAdminAcc());
|
||||
Session::setUserIsLdap($UserData->isUserIsLdap());
|
||||
Session::setUserProfile(Profile::getItem()->getById($UserData->getUserProfileId())->getItemData());
|
||||
Session::setUserProfile(Profile::getItem()->getById($UserData->getUserProfileId()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -102,7 +102,7 @@ class Theme implements ThemeInterface
|
||||
*/
|
||||
protected function getUserTheme()
|
||||
{
|
||||
return (Session::getUserId() > 0) ? UserPreferences::getItem()->getById(Session::getUserId())->getItemData()->getTheme() : '';
|
||||
return (Session::getUserId() > 0) ? UserPreferences::getItem()->getById(Session::getUserId())->getTheme() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -262,7 +262,7 @@ class Migrate
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return (DB::$lastNumRows === 0);
|
||||
return ($Data->getQueryNumRows() === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -82,7 +82,7 @@ class Log extends ActionLog
|
||||
return false;
|
||||
}
|
||||
|
||||
self::$numRows = DB::$lastNumRows;
|
||||
self::$numRows = $Data->getQueryNumRows();
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getCategoryName());
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
);
|
||||
}
|
||||
|
||||
$oldCategory = $this->getById($this->itemData->getCategoryId())->getItemData();
|
||||
$oldCategory = $this->getById($this->itemData->getCategoryId());
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'DELETE FROM categories WHERE category_id = ? LIMIT 1';
|
||||
@@ -145,12 +145,12 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return DB::$lastNumRows > 0;
|
||||
return $Data->getQueryNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return $this
|
||||
* @return CategoryData
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
@@ -162,9 +162,7 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
$Data->addParam($id);
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
|
||||
$this->itemData = DB::getResults($Data);
|
||||
|
||||
return $this;
|
||||
return DB::getResults($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +175,7 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
throw new SPException(SPException::SP_WARNING, _('Nombre de categoría duplicado'));
|
||||
}
|
||||
|
||||
$oldCategory = $this->getById($this->itemData->getCategoryId())->getItemData();
|
||||
$oldCategory = $this->getById($this->itemData->getCategoryId());
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'UPDATE categories
|
||||
@@ -218,7 +216,7 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
$Data->addParam($this->itemData->getCategoryName());
|
||||
$Data->addParam($this->itemData->getCategoryId());
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows > 0);
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,7 +79,7 @@ class CategorySearch extends CategoryBase implements ItemSearchInterface
|
||||
return array();
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class CustomField extends CustomFieldBase implements ItemInterface
|
||||
parent::__construct($itemData);
|
||||
|
||||
if (!is_null($customFieldDefId)) {
|
||||
$field = CustomFieldDef::getItem()->getById($customFieldDefId)->getItemData();
|
||||
$field = CustomFieldDef::getItem()->getById($customFieldDefId);
|
||||
|
||||
$itemData->setDefinitionId($customFieldDefId);
|
||||
$itemData->setModule($field->getModule());
|
||||
@@ -121,7 +121,7 @@ class CustomField extends CustomFieldBase implements ItemInterface
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return (DB::$lastNumRows >= 1);
|
||||
return ($Data->getQueryNumRows() >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -120,7 +120,7 @@ class CustomFieldDef extends CustomFieldBase implements ItemInterface
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$curField = $this->getById($this->itemData->getId())->getItemData();
|
||||
$curField = $this->getById($this->itemData->getId());
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'UPDATE customFieldsDef SET
|
||||
@@ -147,7 +147,7 @@ class CustomFieldDef extends CustomFieldBase implements ItemInterface
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return $this
|
||||
* @return CustomFieldDefData
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function getById($id)
|
||||
@@ -185,7 +185,7 @@ class CustomFieldDef extends CustomFieldBase implements ItemInterface
|
||||
|
||||
$this->itemData = $fieldDef;
|
||||
|
||||
return $this;
|
||||
return $fieldDef;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,7 +106,7 @@ class CustomFieldDefSearch extends CustomFieldBase implements ItemSearchInterfac
|
||||
}
|
||||
}
|
||||
|
||||
$customFields['count'] = DB::$lastNumRows;
|
||||
$customFields['count'] = $Data->getQueryNumRows();
|
||||
|
||||
return $customFields;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->mkCustomerHash());
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
);
|
||||
}
|
||||
|
||||
$oldCustomer = $this->getById($id)->getItemData();
|
||||
$oldCustomer = $this->getById($id);
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'DELETE FROM customers WHERE customer_id = ? LIMIT 1';
|
||||
@@ -168,12 +168,12 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return DB::$lastNumRows > 0;
|
||||
return $Data->getQueryNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return $this
|
||||
* @return CustomerData
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
@@ -185,9 +185,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
$this->itemData = DB::getResults($Data);
|
||||
|
||||
return $this;
|
||||
return DB::getResults($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +198,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
throw new SPException(SPException::SP_WARNING, _('Cliente duplicado'));
|
||||
}
|
||||
|
||||
$oldCustomer = $this->getById($this->itemData->getCustomerId())->getItemData();
|
||||
$oldCustomer = $this->getById($this->itemData->getCustomerId());
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'UPDATE customers
|
||||
@@ -243,7 +241,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
$Data->addParam($this->mkCustomerHash());
|
||||
$Data->addParam($this->itemData->getCustomerId());
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -80,7 +80,7 @@ class CustomerSearch extends CustomerBase implements ItemSearchInterface
|
||||
return array();
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ class File extends FileBase implements ItemInterface, ItemSelectInterface
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return $this
|
||||
* @return FileData
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
@@ -198,10 +198,7 @@ class File extends FileBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
|
||||
$this->itemData = DB::getResults($Data);
|
||||
|
||||
return $this;
|
||||
return DB::getResults($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,7 +89,7 @@ class FileSearch extends FileBase implements ItemSearchInterface
|
||||
return array();
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class FileUtil
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return DB::$lastNumRows;
|
||||
return $Data->getQueryNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -102,7 +102,7 @@ class Group extends GroupBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getUsergroupName());
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ class Group extends GroupBase implements ItemInterface, ItemSelectInterface
|
||||
throw new SPException(SPException::SP_WARNING, _('Grupo en uso'));
|
||||
}
|
||||
|
||||
$GroupData = $this->getById($id)->getItemData();
|
||||
$GroupData = $this->getById($id);
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'DELETE FROM usrGroups WHERE usergroup_id = ? LIMIT 1';
|
||||
@@ -173,12 +173,12 @@ class Group extends GroupBase implements ItemInterface, ItemSelectInterface
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return (DB::$lastNumRows > 1);
|
||||
return ($Data->getQueryNumRows() > 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return $this
|
||||
* @return GroupData
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
@@ -190,9 +190,7 @@ class Group extends GroupBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
$this->itemData = DB::getResults($Data);
|
||||
|
||||
return $this;
|
||||
return DB::getResults($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +203,7 @@ class Group extends GroupBase implements ItemInterface, ItemSelectInterface
|
||||
throw new SPException(SPException::SP_INFO, _('Nombre de grupo duplicado'));
|
||||
}
|
||||
|
||||
$GroupData = $this->getById($this->itemData->getUsergroupId())->getItemData();
|
||||
$GroupData = $this->getById($this->itemData->getUsergroupId());
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'UPDATE usrGroups SET usergroup_name = ?, usergroup_description = ? WHERE usergroup_id = ? LIMIT 1';
|
||||
@@ -253,7 +251,7 @@ class Group extends GroupBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->addParam($this->itemData->getUsergroupName());
|
||||
$Data->addParam($this->itemData->getUsergroupId());
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -148,7 +148,7 @@ class GroupAccounts extends GroupAccountsBase implements ItemInterface
|
||||
|
||||
DB::getResults($Data);
|
||||
|
||||
return (DB::$lastNumRows > 1);
|
||||
return ($Data->getQueryNumRows() > 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -80,7 +80,7 @@ class GroupSearch extends GroupBase implements ItemSearchInterface
|
||||
return array();
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ class GroupUsers extends GroupUsersBase implements ItemInterface, ItemSelectInte
|
||||
|
||||
DB::getResults($Data);
|
||||
|
||||
return (DB::$lastNumRows > 1);
|
||||
return ($Data->getQueryNumRows() > 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,7 +56,7 @@ class Profile extends ProfileBase implements ItemInterface, ItemSelectInterface
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->checkDuplicatedOnAdd()){
|
||||
if ($this->checkDuplicatedOnAdd()) {
|
||||
throw new SPException(SPException::SP_INFO, _('Nombre de perfil duplicado'));
|
||||
}
|
||||
|
||||
@@ -85,6 +85,25 @@ class Profile extends ProfileBase implements ItemInterface, ItemSelectInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkDuplicatedOnAdd()
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT userprofile_name
|
||||
FROM usrProfiles
|
||||
WHERE UPPER(userprofile_name) = ?';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->addParam($this->itemData->getUserprofileName());
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return ($Data->getQueryNumRows() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return $this
|
||||
@@ -96,7 +115,7 @@ class Profile extends ProfileBase implements ItemInterface, ItemSelectInterface
|
||||
throw new SPException(SPException::SP_INFO, _('Perfil en uso'));
|
||||
}
|
||||
|
||||
$oldProfile = $this->getById($id)->getItemData();
|
||||
$oldProfile = $this->getById($id);
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'DELETE FROM usrProfiles WHERE userprofile_id = ? LIMIT 1';
|
||||
@@ -118,17 +137,70 @@ class Profile extends ProfileBase implements ItemInterface, ItemSelectInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return bool
|
||||
*/
|
||||
public function checkInUse($id)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT user_profileId FROM usrData WHERE user_profileId = ?';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return ($Data->getQueryNumRows() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return ProfileData
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT userprofile_id,
|
||||
userprofile_name,
|
||||
userprofile_profile
|
||||
FROM usrProfiles
|
||||
WHERE userprofile_id = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
/**
|
||||
* @var ProfileBaseData $ProfileData
|
||||
* @var ProfileData $Profile
|
||||
*/
|
||||
$ProfileData = DB::getResults($Data);
|
||||
$Profile = unserialize($ProfileData->getUserprofileProfile());
|
||||
|
||||
if (get_class($Profile) === '__PHP_Incomplete_Class') {
|
||||
$Profile = Util::castToClass($this->getDataModel(), $Profile);
|
||||
}
|
||||
|
||||
$Profile->setUserprofileId($ProfileData->getUserprofileId());
|
||||
$Profile->setUserprofileName($ProfileData->getUserprofileName());
|
||||
|
||||
return $Profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws SPException
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
if ($this->checkDuplicatedOnUpdate()){
|
||||
if ($this->checkDuplicatedOnUpdate()) {
|
||||
throw new SPException(SPException::SP_INFO, _('Nombre de perfil duplicado'));
|
||||
}
|
||||
|
||||
$oldProfileName = $this->getById($this->itemData->getUserprofileId())->getItemData();
|
||||
$oldProfileName = $this->getById($this->itemData->getUserprofileId());
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'UPDATE usrProfiles SET
|
||||
@@ -156,40 +228,24 @@ class Profile extends ProfileBase implements ItemInterface, ItemSelectInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return $this
|
||||
* @return bool
|
||||
*/
|
||||
public function getById($id)
|
||||
public function checkDuplicatedOnUpdate()
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT userprofile_id,
|
||||
userprofile_name,
|
||||
userprofile_profile
|
||||
'SELECT userprofile_name
|
||||
FROM usrProfiles
|
||||
WHERE userprofile_id = ? LIMIT 1';
|
||||
WHERE UPPER(userprofile_name) = ?
|
||||
AND userprofile_id <> ?';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->addParam($this->itemData->getUserprofileName());
|
||||
$Data->addParam($this->itemData->getUserprofileId());
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
/**
|
||||
* @var ProfileBaseData $ProfileData
|
||||
* @var ProfileData $Profile
|
||||
*/
|
||||
$ProfileData = DB::getResults($Data);
|
||||
$Profile = unserialize($ProfileData->getUserprofileProfile());
|
||||
DB::getQuery($Data);
|
||||
|
||||
if (get_class($Profile) === '__PHP_Incomplete_Class') {
|
||||
$Profile = Util::castToClass($this->getDataModel(), $Profile);
|
||||
}
|
||||
|
||||
$Profile->setUserprofileId($ProfileData->getUserprofileId());
|
||||
$Profile->setUserprofileName($ProfileData->getUserprofileName());
|
||||
|
||||
$this->itemData = $Profile;
|
||||
|
||||
return $this;
|
||||
return ($Data->getQueryNumRows() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,62 +275,4 @@ class Profile extends ProfileBase implements ItemInterface, ItemSelectInterface
|
||||
|
||||
return DB::getResults($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return bool
|
||||
*/
|
||||
public function checkInUse($id)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT user_profileId FROM usrData WHERE user_profileId = ?';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return (DB::$lastNumRows > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkDuplicatedOnUpdate()
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT userprofile_name
|
||||
FROM usrProfiles
|
||||
WHERE UPPER(userprofile_name) = ?
|
||||
AND userprofile_id <> ?';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->addParam($this->itemData->getUserprofileName());
|
||||
$Data->addParam($this->itemData->getUserprofileId());
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return (DB::$lastNumRows > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkDuplicatedOnAdd()
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT userprofile_name
|
||||
FROM usrProfiles
|
||||
WHERE UPPER(userprofile_name) = ?';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->addParam($this->itemData->getUserprofileName());
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return (DB::$lastNumRows > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class ProfileSearch extends ProfileBase implements ItemSearchInterface
|
||||
return array();
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
|
||||
DB::getResults($Data);
|
||||
|
||||
return (DB::$lastNumRows === 1);
|
||||
return ($Data->getQueryNumRows() === 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,7 +69,7 @@ class PublicLinkSearch extends PublicLinkBase implements ItemSearchInterface
|
||||
}
|
||||
|
||||
$publicLinks = [];
|
||||
$publicLinks['count'] = DB::$lastNumRows;
|
||||
$publicLinks['count'] = $Data->getQueryNumRows();
|
||||
|
||||
foreach ($queryRes as $PublicLinkListData) {
|
||||
/**
|
||||
|
||||
@@ -80,7 +80,7 @@ class Tag extends TagBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getTagHash());
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows > 0 );
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() > 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,12 +142,12 @@ class Tag extends TagBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->addParam($this->itemData->getTagHash());
|
||||
$Data->addParam($this->itemData->getTagId());
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows > 0);
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return $this
|
||||
* @return TagData
|
||||
* @throws SPException
|
||||
*/
|
||||
public function getById($id)
|
||||
@@ -166,9 +166,7 @@ class Tag extends TagBase implements ItemInterface, ItemSelectInterface
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al obtener etiqueta'));
|
||||
}
|
||||
|
||||
$this->itemData = $queryRes;
|
||||
|
||||
return $this;
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,7 +72,7 @@ class TagSearch extends TagBase implements ItemSearchInterface
|
||||
return array();
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ class User extends UserBase implements ItemInterface, ItemSelectInterface
|
||||
$this->itemData->setUserId(DB::$lastId);
|
||||
|
||||
$Log = new Log(_('Eliminar Usuario'));
|
||||
$Log->addDetails(Html::strongText(_('Login')), $oldUserData->getItemData()->getUserLogin());
|
||||
$Log->addDetails(Html::strongText(_('Nombre')), $oldUserData->getItemData()->getUserName());
|
||||
$Log->addDetails(Html::strongText(_('Login')), $oldUserData->getUserLogin());
|
||||
$Log->addDetails(Html::strongText(_('Nombre')), $oldUserData->getUserName());
|
||||
$Log->writeLog();
|
||||
|
||||
Email::sendEmail($Log);
|
||||
@@ -147,7 +147,7 @@ class User extends UserBase implements ItemInterface, ItemSelectInterface
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return $this
|
||||
* @return UserData
|
||||
* @throws SPException
|
||||
*/
|
||||
public function getById($id)
|
||||
@@ -187,9 +187,7 @@ class User extends UserBase implements ItemInterface, ItemSelectInterface
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al obtener los datos del usuario'));
|
||||
}
|
||||
|
||||
$this->itemData = $queryRes;
|
||||
|
||||
return $this;
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +268,7 @@ class User extends UserBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->addParam($this->itemData->getUserEmail());
|
||||
$Data->addParam($this->itemData->getUserId());
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows > 0);
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -334,7 +332,7 @@ class User extends UserBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->addParam($this->itemData->getUserLogin());
|
||||
$Data->addParam($this->itemData->getUserEmail());
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows > 0);
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -365,7 +363,7 @@ class User extends UserBase implements ItemInterface, ItemSelectInterface
|
||||
}
|
||||
|
||||
$Log = new Log(_('Modificar Clave Usuario'));
|
||||
$Log->addDetails(Html::strongText(_('Login')), $UserData->getItemData()->getUserLogin());
|
||||
$Log->addDetails(Html::strongText(_('Login')), $UserData->getUserLogin());
|
||||
$Log->writeLog();
|
||||
|
||||
Email::sendEmail($Log);
|
||||
|
||||
@@ -58,7 +58,7 @@ class UserLdap extends UserBase implements ItemInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($userLogin);
|
||||
|
||||
return (DB::getQuery($Data) === true && DB::$lastNumRows === 1);
|
||||
return (DB::getQuery($Data) === true && $Data->getQueryNumRows() === 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -125,7 +125,7 @@ class UserPass extends UserBase
|
||||
public function updateUserPass($userId, $userPass)
|
||||
{
|
||||
$passdata = self::makeUserPassHash($userPass);
|
||||
$this->setItemData(User::getItem()->getById($userId)->getItemData());
|
||||
$this->setItemData(User::getItem()->getById($userId));
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'UPDATE usrData SET
|
||||
|
||||
@@ -52,6 +52,29 @@ class UserPassRecover extends UserPassRecoverBase implements ItemInterface
|
||||
const USER_LOGIN_EXIST = 1;
|
||||
const USER_MAIL_EXIST = 2;
|
||||
|
||||
/**
|
||||
* Comprobar el límite de recuperaciones de clave.
|
||||
*
|
||||
* @param UserData $UserData con el login del usuario
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkPassRecoverLimit(UserData $UserData)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT userpassr_userId
|
||||
FROM usrPassRecover
|
||||
WHERE userpassr_userId = ?
|
||||
AND userpassr_used = 0
|
||||
AND userpassr_date >= ?';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($UserData->getUserId());
|
||||
$Data->addParam(time() - self::MAX_PASS_RECOVER_TIME);
|
||||
|
||||
return (DB::getQuery($Data) === false || $Data->getQueryNumRows() >= self::MAX_PASS_RECOVER_LIMIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar el hash de recuperación de clave.
|
||||
*
|
||||
@@ -80,7 +103,7 @@ class UserPassRecover extends UserPassRecoverBase implements ItemInterface
|
||||
|
||||
if ($queryRes === false) {
|
||||
throw new SPException(SPException::SP_ERROR, _('Error en comprobación de hash'));
|
||||
} elseif (DB::$lastNumRows === 0){
|
||||
} elseif ($Data->getQueryNumRows() === 0) {
|
||||
throw new SPException(SPException::SP_INFO, _('Hash inválido o expirado'));
|
||||
}
|
||||
|
||||
@@ -92,26 +115,23 @@ class UserPassRecover extends UserPassRecoverBase implements ItemInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar el límite de recuperaciones de clave.
|
||||
*
|
||||
* @param UserData $UserData con el login del usuario
|
||||
* @return bool
|
||||
* @return $this
|
||||
* @throws SPException
|
||||
*/
|
||||
public static function checkPassRecoverLimit(UserData $UserData)
|
||||
public function update()
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT userpassr_userId
|
||||
FROM usrPassRecover
|
||||
WHERE userpassr_userId = ?
|
||||
AND userpassr_used = 0
|
||||
AND userpassr_date >= ?';
|
||||
'UPDATE usrPassRecover SET userpassr_used = 1 WHERE userpassr_hash = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($UserData->getUserId());
|
||||
$Data->addParam(time() - self::MAX_PASS_RECOVER_TIME);
|
||||
$Data->addParam($this->itemData->getUserpassrHash());
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows >= self::MAX_PASS_RECOVER_LIMIT);
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_ERROR, _('Error interno'));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,26 +168,6 @@ class UserPassRecover extends UserPassRecoverBase implements ItemInterface
|
||||
// TODO: Implement delete() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws SPException
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'UPDATE usrPassRecover SET userpassr_used = 1 WHERE userpassr_hash = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getUserpassrHash());
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_ERROR, _('Error interno'));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return mixed
|
||||
|
||||
@@ -84,7 +84,7 @@ class UserPreferences extends UserPreferencesBase implements ItemInterface
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return $this
|
||||
* @return UserPreferencesData
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
@@ -99,8 +99,8 @@ class UserPreferences extends UserPreferencesBase implements ItemInterface
|
||||
/** @var UserData $queryRes */
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false || is_null($queryRes->getUserPreferences())) {
|
||||
return $this;
|
||||
if ($queryRes === false || null === $queryRes->getUserPreferences()) {
|
||||
return $this->getItemData();
|
||||
}
|
||||
|
||||
$UserPreferencesData = unserialize($queryRes->getUserPreferences());
|
||||
@@ -109,9 +109,7 @@ class UserPreferences extends UserPreferencesBase implements ItemInterface
|
||||
$UserPreferencesData = Util::castToClass($this->getDataModel(), $UserPreferencesData);
|
||||
}
|
||||
|
||||
$this->itemData = $UserPreferencesData;
|
||||
|
||||
return $this;
|
||||
return $UserPreferencesData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,7 +93,7 @@ class UserSearch extends UserBase implements ItemSearchInterface
|
||||
return array();
|
||||
}
|
||||
|
||||
$queryRes['count'] = DB::$lastNumRows;
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class UserUtil
|
||||
$Data->addParam($UserData->getUserLogin());
|
||||
$Data->addParam($UserData->getUserEmail());
|
||||
|
||||
return (DB::getQuery($Data) === true && DB::$lastNumRows === 1);
|
||||
return (DB::getQuery($Data) === true && $Data->getQueryNumRows() === 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,11 +49,7 @@ class DB
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public static $lastNumRows = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public static $lastId = null;
|
||||
public static $lastId;
|
||||
/**
|
||||
* @var bool Resultado como array
|
||||
*/
|
||||
@@ -77,7 +73,7 @@ class DB
|
||||
/**
|
||||
* @var array Resultados de la consulta
|
||||
*/
|
||||
private $lastResult = null;
|
||||
private $lastResult;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
@@ -111,7 +107,8 @@ class DB
|
||||
try {
|
||||
$db = new DB();
|
||||
$doQuery = $db->doQuery($queryData, self::$returnRawData);
|
||||
self::$lastNumRows = (self::$fullRowCount === false) ? $db->numRows : $db->getFullRowCount($queryData);
|
||||
$numRows = (self::$fullRowCount === false) ? $db->numRows : $db->getFullRowCount($queryData);
|
||||
$queryData->setQueryNumRows($numRows);
|
||||
} catch (SPException $e) {
|
||||
self::logDBException($queryData->getQuery(), $e->getMessage(), $e->getCode(), __FUNCTION__);
|
||||
return false;
|
||||
@@ -194,18 +191,12 @@ class DB
|
||||
*/
|
||||
private function prepareQueryData(QueryData $queryData, $isCount = false)
|
||||
{
|
||||
// if ($isCount === true) {
|
||||
// No incluimos en el array de parámetros de posición los valores
|
||||
// utilizados para LIMIT
|
||||
// preg_match_all('/(\?|:)/', $queryData->getQuery(), $count);
|
||||
|
||||
// Indice a partir del cual no se incluyen valores
|
||||
// $paramMaxIndex = (count($count[1]) > 0) ? count($count[1]) : 0;
|
||||
// }
|
||||
|
||||
$query = $isCount === false ? $queryData->getQuery() : $queryData->getQueryCount();
|
||||
|
||||
$paramMaxIndex = count($queryData->getParams()) - 3;
|
||||
if ($isCount === true) {
|
||||
$query = $queryData->getQueryCount();
|
||||
$paramMaxIndex = count($queryData->getParams()) - 3;
|
||||
} else {
|
||||
$query = $queryData->getQuery();
|
||||
}
|
||||
|
||||
try {
|
||||
$db = DiFactory::getDBStorage()->getConnection();
|
||||
@@ -221,7 +212,7 @@ class DB
|
||||
|
||||
if ($isCount === true
|
||||
&& $queryData->getLimit() !== ''
|
||||
&& $paramIndex >= $paramMaxIndex
|
||||
&& $paramIndex > $paramMaxIndex
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
@@ -285,9 +276,6 @@ class DB
|
||||
$num = (int)$queryRes->fetchColumn();
|
||||
$queryRes->closeCursor();
|
||||
|
||||
error_log($queryData->getQueryCount());
|
||||
error_log($num);
|
||||
|
||||
return $num;
|
||||
} catch (SPException $e) {
|
||||
error_log('Exception: ' . $e->getMessage());
|
||||
@@ -320,7 +308,7 @@ class DB
|
||||
/**
|
||||
* Realizar una consulta y devolver el resultado sin datos
|
||||
*
|
||||
* @param QueryData $queryData Los datos para realizar la consulta
|
||||
* @param QueryData $queryData Los datos para realizar la consulta
|
||||
* @param $getRawData bool Si se deben de obtener los datos como PDOStatement
|
||||
* @return bool
|
||||
*/
|
||||
@@ -333,7 +321,7 @@ class DB
|
||||
try {
|
||||
$db = new DB();
|
||||
$db->doQuery($queryData, $getRawData);
|
||||
DB::$lastNumRows = $db->numRows;
|
||||
$queryData->setQueryNumRows($db->numRows);
|
||||
} catch (SPException $e) {
|
||||
self::logDBException($queryData->getQuery(), $e->getMessage(), $e->getCode(), __FUNCTION__);
|
||||
self::$txtError = $e->getMessage();
|
||||
|
||||
@@ -78,6 +78,10 @@ class QueryData
|
||||
* @var string
|
||||
*/
|
||||
protected $queryCount = '';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $queryNumRows = 0;
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
@@ -270,9 +274,25 @@ class QueryData
|
||||
public function getQueryCount()
|
||||
{
|
||||
if ($this->queryCount === '') {
|
||||
return 'SELECT COUNT(*) ' . $this->from . ' ' . $this->where;
|
||||
return 'SELECT COUNT(*) ' . $this->getFrom() . ' ' . $this->getWhere();
|
||||
}
|
||||
|
||||
return $this->queryCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getQueryNumRows()
|
||||
{
|
||||
return $this->queryNumRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $queryNumRows
|
||||
*/
|
||||
public function setQueryNumRows($queryNumRows)
|
||||
{
|
||||
$this->queryNumRows = $queryNumRows;
|
||||
}
|
||||
}
|
||||
@@ -219,4 +219,4 @@ ADD CONSTRAINT `fk_usrToGroups_groups_id`
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
CREATE ALGORITHM=UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFINER VIEW `account_search_v` AS select distinct `accounts`.`account_id` AS `account_id`,`accounts`.`account_customerId` AS `account_customerId`,`accounts`.`account_name` AS `account_name`,`accounts`.`account_login` AS `account_login`,`accounts`.`account_url` AS `account_url`,`accounts`.`account_notes` AS `account_notes`,`accounts`.`account_userId` AS `account_userId`,`accounts`.`account_userGroupId` AS `account_userGroupId`,conv(`accounts`.`account_otherUserEdit`,10,2) AS `account_otherUserEdit`,conv(`accounts`.`account_otherGroupEdit`,10,2) AS `account_otherGroupEdit`,`ug`.`usergroup_name` AS `usergroup_name`,`categories`.`category_name` AS `category_name`,`customers`.`customer_name` AS `customer_name`,(select count(0) from `accFiles` where (`accFiles`.`accfile_accountId` = `accounts`.`account_id`)) AS `num_files` from ((((((((`accounts` left join `categories` on((`accounts`.`account_categoryId` = `categories`.`category_id`))) left join `usrGroups` `ug` on((`accounts`.`account_userGroupId` = `ug`.`usergroup_id`))) left join `customers` on((`customers`.`customer_id` = `accounts`.`account_customerId`))) left join `accUsers` on((`accUsers`.`accuser_accountId` = `accounts`.`account_id`))) left join `accGroups` on((`accGroups`.`accgroup_accountId` = `accounts`.`account_id`))) left join `accFavorites` on((`accFavorites`.`accfavorite_accountId` = `accounts`.`account_id`))) left join `accTags` on((`accTags`.`acctag_accountId` = `accounts`.`account_id`))) left join `tags` on((`tags`.`tag_id` = `accTags`.`acctag_tagId`)));
|
||||
CREATE ALGORITHM=UNDEFINED DEFINER=CURRENT_USER SQL SECURITY DEFINER VIEW `account_search_v` AS select distinct `accounts`.`account_id` AS `account_id`,`accounts`.`account_customerId` AS `account_customerId`,`accounts`.`account_categoryId` AS `account_categoryId`,`accounts`.`account_name` AS `account_name`,`accounts`.`account_login` AS `account_login`,`accounts`.`account_url` AS `account_url`,`accounts`.`account_notes` AS `account_notes`,`accounts`.`account_userId` AS `account_userId`,`accounts`.`account_userGroupId` AS `account_userGroupId`,conv(`accounts`.`account_otherUserEdit`,10,2) AS `account_otherUserEdit`,conv(`accounts`.`account_otherGroupEdit`,10,2) AS `account_otherGroupEdit`,`ug`.`usergroup_name` AS `usergroup_name`,`categories`.`category_name` AS `category_name`,`customers`.`customer_name` AS `customer_name`,(select count(0) from `accFiles` where (`accFiles`.`accfile_accountId` = `accounts`.`account_id`)) AS `num_files` from (((`accounts` left join `categories` on((`accounts`.`account_categoryId` = `categories`.`category_id`))) left join `usrGroups` `ug` on((`accounts`.`account_userGroupId` = `ug`.`usergroup_id`))) left join `customers` on((`customers`.`customer_id` = `accounts`.`account_customerId`)));
|
||||
|
||||
@@ -1,14 +1,42 @@
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo _('Cambio de Clave'); ?></h2>
|
||||
<?php
|
||||
/** @var $icons \Theme\Icons */
|
||||
/** @var $user \SP\DataModel\UserData */
|
||||
?>
|
||||
|
||||
<form method="post" name="updUsrPass" id="frmUpdUsrPass" class="form-action" data-onsubmit="user/password">
|
||||
<div id="fancyContainer" align="center">
|
||||
<h2><?php echo $header; ?></h2>
|
||||
|
||||
<form method="post" name="updUsrPass" id="frmUpdUsrPass" class="form-action" data-onsubmit="appMgmt/save">
|
||||
<table class="fancydata">
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Nombre') ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield">
|
||||
<input id="name" name="name" type="text"
|
||||
class="mdl-textfield__input mdl-color-text--indigo-400"
|
||||
value="<?php echo $user->getUserName(); ?>" readonly disabled />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Login'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield">
|
||||
<input id="login" name="login" type="text"
|
||||
class="mdl-textfield__input mdl-color-text--indigo-400"
|
||||
value="<?php echo $user->getUserLogin(); ?>"
|
||||
readonly disabled />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Clave'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="fancypass" name="pass" type="password" required class="mdl-textfield__input mdl-color-text--indigo-400 passwordfield__input"
|
||||
<input id="fancypass" name="pass" type="password" required
|
||||
class="mdl-textfield__input mdl-color-text--indigo-400 passwordfield__input"
|
||||
maxlength="50">
|
||||
<label class="mdl-textfield__label" for="userpass"><?php echo _('Clave'); ?></label>
|
||||
</div>
|
||||
@@ -19,7 +47,8 @@
|
||||
<td class="descField"><?php echo _('Clave (repetir)'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="fancypassR" name="passR" type="password" required class="mdl-textfield__input mdl-color-text--indigo-400"
|
||||
<input id="fancypassR" name="passR" type="password" required
|
||||
class="mdl-textfield__input mdl-color-text--indigo-400"
|
||||
maxlength="50">
|
||||
<label class="mdl-textfield__label"
|
||||
for="userpassR"><?php echo _('Clave (repetir)'); ?></label>
|
||||
@@ -27,17 +56,16 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="itemId" value="<?php echo $userId; ?>"/>
|
||||
<input type="hidden" name="itemId" value="<?php echo $user->getId(); ?>"/>
|
||||
<input type="hidden" name="actionId" value="<?php echo $actionId; ?>"/>
|
||||
<input type="hidden" name="sk" value="<?php echo $sk; ?>">
|
||||
</form>
|
||||
|
||||
<div id="resCheck">
|
||||
<span id="resFancyAccion"></span>
|
||||
</div>
|
||||
<div id="resCheck"><span id="resFancyAccion"></span></div>
|
||||
<div class="action-in-box">
|
||||
<button form="frmUpdUsrPass" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored <?php echo $icons->getIconSave()->getClassButton(); ?>"
|
||||
title="<?php echo $icons->getIconSave()->getTitle(); ?>">
|
||||
<button form="frmUpdUsrPass"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored <?php echo $icons->getIconSave()->getClassButton(); ?>"
|
||||
title="<?php echo $icons->getIconSave()->getTitle(); ?>">
|
||||
<i class="material-icons"><?php echo $icons->getIconSave()->getIcon(); ?></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
<div id="session">
|
||||
<i id="btnLogout" class="material-icons" title="<?php echo _('Salir'); ?>">exit_to_app</i>
|
||||
<?php if ($showPassIcon): ?>
|
||||
<i id="btnUserPass" class="material-icons" title="<?php echo _('Cambiar clave de usuario'); ?>"
|
||||
<i id="btnUserPass" class="btn-action material-icons" title="<?php echo _('Cambiar clave de usuario'); ?>"
|
||||
data-onclick="appMgmt/show"
|
||||
data-action-id="<?php echo \SP\Core\ActionsInterface::ACTION_USR_USERS_EDITPASS; ?>"
|
||||
data-item-id="<?php echo $userId; ?>"
|
||||
data-sk="<?php echo $sk; ?>">security</i>
|
||||
|
||||
@@ -177,7 +177,7 @@ sysPass.Actions = function (Common) {
|
||||
opts.url = ajaxUrl.user.password;
|
||||
opts.data = {
|
||||
actionId: $obj.data("action-id"),
|
||||
userId: $obj.data("item-id"),
|
||||
itemId: $obj.data("item-id"),
|
||||
sk: $obj.data("sk"),
|
||||
isAjax: 1
|
||||
};
|
||||
|
||||
2
js/app-actions.min.js
vendored
2
js/app-actions.min.js
vendored
@@ -26,7 +26,7 @@ isAjax:1};b=c.appRequests().getRequestOpts();b.url=e.checks;b.data=a;c.appReques
|
||||
0===a.status&&$("#dokuWikiResCheck").html(a.data)})}},config:{save:function(a){d.info("config:save");var b=c.appRequests().getRequestOpts();b.url=e.config.save;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&f({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},backup:function(a){d.info("config:backup");var b=c.appRequests().getRequestOpts();b.url=e.config["export"];b.data=a.serialize();c.appRequests().getActionCall(b,
|
||||
function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&f({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},"export":function(a){d.info("config:export");var b=c.appRequests().getRequestOpts();b.url=e.config["export"];b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&f({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},"import":function(a){d.info("config:import");
|
||||
var b=c.appRequests().getRequestOpts();b.url=e.config["import"];b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&"undefined"!==typeof a.data("nextaction-id")&&f({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})}},main:n,user:{savePreferences:function(a){d.info("user:savePreferences");var b=c.appRequests().getRequestOpts();b.url=e.user.savePreferences;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);setTimeout(function(){window.location.replace("index.php")},
|
||||
2E3)})},saveSecurity:function(a){d.info("user:saveSecurity");var b=c.appRequests().getRequestOpts();b.url=e.user.savePreferences;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},password:function(a){d.info("user:password");var b=c.appRequests().getRequestOpts();b.type="html";b.method="get";b.url=e.user.password;b.data={actionId:a.data("action-id"),userId:a.data("item-id"),sk:a.data("sk"),isAjax:1};c.appRequests().getActionCall(b,function(b){0===b.length?n.logout():
|
||||
2E3)})},saveSecurity:function(a){d.info("user:saveSecurity");var b=c.appRequests().getRequestOpts();b.url=e.user.savePreferences;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},password:function(a){d.info("user:password");var b=c.appRequests().getRequestOpts();b.type="html";b.method="get";b.url=e.user.password;b.data={actionId:a.data("action-id"),itemId:a.data("item-id"),sk:a.data("sk"),isAjax:1};c.appRequests().getActionCall(b,function(b){0===b.length?n.logout():
|
||||
l(a,b)})},passreset:function(a){d.info("user:passreset");var b=c.appRequests().getRequestOpts();b.url=e.user.passreset;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},link:{save:function(a){d.info("link:save");var b=c.appRequests().getRequestOpts();b.url=e.link;b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};alertify.okBtn(c.config().LANG[40]).cancelBtn(c.config().LANG[41]).confirm(c.config().LANG[48],function(a){a.preventDefault();
|
||||
b.data.notify=1;c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},function(a){a.preventDefault();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})})},refresh:function(a){d.info("link:refresh");a={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),activeTab:a.data("activetab")};var b=c.appRequests().getRequestOpts();b.url=e.link;b.data=a;c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},eventlog:{nav:function(a){if("undefined"===typeof a.data("start"))return!1;
|
||||
var b=c.appRequests().getRequestOpts();b.url=e.eventlog;b.type="html";b.data={start:a.data("start"),current:a.data("current")};c.appRequests().getActionCall(b,function(a){$("#content").html(a);c.scrollUp()})},clear:function(a){var b='<div id="alert"><p id="alert-text">'+c.config().LANG[20]+"</p></div>";alertify.okBtn(c.config().LANG[43]).cancelBtn(c.config().LANG[44]).confirm(b,function(b){b.preventDefault();b=c.appRequests().getRequestOpts();b.url=e.eventlog;b.data={clear:1,sk:c.sk.get(),isAjax:1};
|
||||
|
||||
@@ -142,9 +142,21 @@ sysPass.Triggers = function (Common) {
|
||||
|
||||
$("#" + $this.data("help")).dialog("open");
|
||||
}).on("reset", ".form-action", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
log.info("reset");
|
||||
|
||||
$(this).find("input[name='start'], input[name='skey'], input[name='sorder']").val(0);
|
||||
var $this = $(this);
|
||||
|
||||
$this.find("input:text, input:password, input:file, textarea").val("").parent("div").removeClass("is-dirty");
|
||||
$this.find("input:radio, input:checkbox").removeAttr("checked").removeAttr("selected");
|
||||
$this.find("input[name='start'], input[name='skey'], input[name='sorder']").val(0);
|
||||
|
||||
$this.find("select").each(function () {
|
||||
$(this)[0].selectize.clear();
|
||||
});
|
||||
|
||||
$this.submit();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -178,16 +190,12 @@ sysPass.Triggers = function (Common) {
|
||||
$frmSearch.submit();
|
||||
});
|
||||
|
||||
$frmSearch.find("button.btn-clear").on("click", function () {
|
||||
$frmSearch[0].reset();
|
||||
|
||||
$frmSearch.find("select").each(function () {
|
||||
$(this)[0].selectize.clear();
|
||||
});
|
||||
$frmSearch.find("button.btn-clear").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
$frmSearch.find("input[name=\"searchfav\"]").val(0);
|
||||
|
||||
$frmSearch.submit();
|
||||
$frmSearch[0].reset();
|
||||
});
|
||||
|
||||
$frmSearch.find("input:text:visible:first").focus();
|
||||
@@ -225,10 +233,6 @@ sysPass.Triggers = function (Common) {
|
||||
$("#btnPrefs").click(function (e) {
|
||||
Common.appActions().doAction({actionId: $(this).data("action-id")});
|
||||
});
|
||||
|
||||
$("#btnUserPass").click(function (e) {
|
||||
Common.appActions().user.password($(this));
|
||||
});
|
||||
},
|
||||
common: function (container) {
|
||||
log.info("views:common");
|
||||
@@ -257,8 +261,10 @@ sysPass.Triggers = function (Common) {
|
||||
$(".datagrid-action-search>form").each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
$this.find("button.btn-clear").on("click", function () {
|
||||
$this.trigger("reset").submit();
|
||||
$this.find("button.btn-clear").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
$this.trigger("reset");
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
13
js/app-triggers.min.js
vendored
13
js/app-triggers.min.js
vendored
@@ -4,9 +4,10 @@ $jscomp.polyfill("Array.prototype.find",function(b){return b?b:function(b,e){ret
|
||||
sysPass.Triggers=function(b){var c=b.log,e=function(a){var d={valueField:"id",labelField:"name",searchField:["name"]};a.find(".select-box").each(function(a){a=$(this);d.plugins=a.hasClass("select-box-deselect")?{clear_selection:{title:b.config().LANG[51]}}:{};if(a.data("onchange")){var c=a.data("onchange").split("/"),e=a.data("action-id");d.onChange=function(a){var b={"action-id":e,"item-id":a};if(0<a)if(2===c.length)sysPassApp.actions()[c[0]][c[1]](b);else sysPassApp.actions()[c[0]](b)}}a.selectize(d)});
|
||||
a.find("#allowed_exts").selectize({create:function(a){return{value:a.toUpperCase(),text:a.toUpperCase()}},createFilter:/^[a-z0-9]{1,4}$/i,plugins:["remove_button"]});a.find("#wikifilter").selectize({create:!0,createFilter:/^[a-z0-9._-]+$/i,plugins:["remove_button"]})},f=function(){c.info("bodyHooks");$("body").on("click",".btn-action[data-onclick],.btn-action-pager[data-onclick]",function(){var a=$(this),d=a.data("onclick").split("/"),c=b.appActions();if(2===d.length)c[d[0]][d[1]](a);else c[d[0]](a)}).on("click",
|
||||
".btn-back",function(){var a=b.appRequests();if(0<a.history.length()){c.info("back");var d=a.history.del();a.getActionCall(d,d.callback)}}).on("submit",".form-action",function(a){a.preventDefault();a=$(this);var d=a.data("onsubmit").split("/"),c=b.appActions(),e=a.attr("data-hash"),f=SparkMD5.hash(a.serialize(),!1);if(e===f)b.msg.ok(b.config().LANG[55]);else if(a.find("input[name='sk']").val(b.sk.get()),2===d.length)c[d[0]][d[1]](a);else c[d[0]](a)}).on("click",".btn-help",function(){var a=$(this);
|
||||
$("#"+a.data("help")).dialog("open")}).on("reset",".form-action",function(a){c.info("reset");$(this).find("input[name='start'], input[name='skey'], input[name='sorder']").val(0)})};return{views:{main:function(){c.info("views:main");f();$(".btn-menu").click(function(){"1"===$(this).attr("data-history-reset")&&b.appRequests().history.reset();b.appActions().doAction({actionId:$(this).data("action-id")})});b.appActions().doAction({actionId:1})},search:function(){c.info("views:search");var a=$("#frmSearch");
|
||||
a.find("select, #rpp").on("change",function(){a.submit()});a.find("button.btn-clear").on("click",function(){a[0].reset();a.find("select").each(function(){$(this)[0].selectize.clear()});a.find('input[name="searchfav"]').val(0);a.submit()});a.find("input:text:visible:first").focus();$("#chkgsearch").click(function(){var b=1==$(this).prop("checked")?1:0;a.find("input[name='gsearch']").val(b);a.submit()});"function"===typeof b.appTheme().viewsTriggers.search&&b.appTheme().viewsTriggers.search()},login:function(){c.info("views:login");
|
||||
f();$("#boxLogout").fadeOut(1500,function(){location.href=b.config().APP_ROOT+"/index.php"})},footer:function(){c.info("views:footer");$("#btnLogout").click(function(a){b.appActions().main.logout()});$("#btnPrefs").click(function(a){b.appActions().doAction({actionId:$(this).data("action-id")})});$("#btnUserPass").click(function(a){b.appActions().user.password($(this))})},common:function(a){c.info("views:common");a=$(a);e(a);a.find(".help-box").dialog({autoOpen:!1,title:b.config().LANG[54],width:screen.width/
|
||||
2.5});"function"===typeof b.appTheme().viewsTriggers.common&&b.appTheme().viewsTriggers.common(a)},datatabs:function(a){c.info("views:datatabs");$("#tabs").tabs({active:a});$(".datagrid-action-search>form").each(function(){var a=$(this);a.find("button.btn-clear").on("click",function(){a.trigger("reset").submit()})})},config:function(){c.info("views:config");var a=$("#drop-import-files");if(0<a.length){var d=b.fileUpload(a);d.url=b.appActions().ajaxUrl.config["import"];d.beforeSendAction=function(){d.requestData({sk:b.sk.get(),
|
||||
csvDelimiter:$("#csvDelimiter").val(),importPwd:$("#importPwd").val(),import_defaultuser:$("#import_defaultuser").val(),import_defaultgroup:$("#import_defaultgroup").val()})}}a=$(".form-action");0<a.length&&a.each(function(){var a=$(this);"undefined"!==typeof a.attr("data-hash")&&a.attr("data-hash",SparkMD5.hash(a.serialize(),!1))})},account:function(){c.info("views:account");var a=$("#list-account-files");0<a.length&&b.appActions().account.getfiles(a);var d=$("#drop-account-files");0<d.length&&(d=
|
||||
b.fileUpload(d),d.url=b.appActions().ajaxUrl.account.getFiles,d.requestDoneAction=function(){b.appActions().account.getfiles(a)});d=$(".form-action");0<d.length&&d.attr("data-hash",SparkMD5.hash(d.serialize(),!1))},install:function(){c.info("views:install");f();var a=$("#frmInstall");b.appTheme().passwordDetect(a)}},selectDetect:e,updateSk:function(){$("#content").find("[data-sk]").each(function(){c.info("updateSk");$(this).data("sk",b.sk.get())})}}};
|
||||
$("#"+a.data("help")).dialog("open")}).on("reset",".form-action",function(a){a.preventDefault();c.info("reset");a=$(this);a.find("input:text, input:password, input:file, textarea").val("").parent("div").removeClass("is-dirty");a.find("input:radio, input:checkbox").removeAttr("checked").removeAttr("selected");a.find("input[name='start'], input[name='skey'], input[name='sorder']").val(0);a.find("select").each(function(){$(this)[0].selectize.clear()});a.submit()})};return{views:{main:function(){c.info("views:main");
|
||||
f();$(".btn-menu").click(function(){"1"===$(this).attr("data-history-reset")&&b.appRequests().history.reset();b.appActions().doAction({actionId:$(this).data("action-id")})});b.appActions().doAction({actionId:1})},search:function(){c.info("views:search");var a=$("#frmSearch");a.find("select, #rpp").on("change",function(){a.submit()});a.find("button.btn-clear").on("click",function(b){b.preventDefault();a.find('input[name="searchfav"]').val(0);a[0].reset()});a.find("input:text:visible:first").focus();
|
||||
$("#chkgsearch").click(function(){var b=1==$(this).prop("checked")?1:0;a.find("input[name='gsearch']").val(b);a.submit()});"function"===typeof b.appTheme().viewsTriggers.search&&b.appTheme().viewsTriggers.search()},login:function(){c.info("views:login");f();$("#boxLogout").fadeOut(1500,function(){location.href=b.config().APP_ROOT+"/index.php"})},footer:function(){c.info("views:footer");$("#btnLogout").click(function(a){b.appActions().main.logout()});$("#btnPrefs").click(function(a){b.appActions().doAction({actionId:$(this).data("action-id")})})},
|
||||
common:function(a){c.info("views:common");a=$(a);e(a);a.find(".help-box").dialog({autoOpen:!1,title:b.config().LANG[54],width:screen.width/2.5});"function"===typeof b.appTheme().viewsTriggers.common&&b.appTheme().viewsTriggers.common(a)},datatabs:function(a){c.info("views:datatabs");$("#tabs").tabs({active:a});$(".datagrid-action-search>form").each(function(){var a=$(this);a.find("button.btn-clear").on("click",function(b){b.preventDefault();a.trigger("reset")})})},config:function(){c.info("views:config");
|
||||
var a=$("#drop-import-files");if(0<a.length){var d=b.fileUpload(a);d.url=b.appActions().ajaxUrl.config["import"];d.beforeSendAction=function(){d.requestData({sk:b.sk.get(),csvDelimiter:$("#csvDelimiter").val(),importPwd:$("#importPwd").val(),import_defaultuser:$("#import_defaultuser").val(),import_defaultgroup:$("#import_defaultgroup").val()})}}a=$(".form-action");0<a.length&&a.each(function(){var a=$(this);"undefined"!==typeof a.attr("data-hash")&&a.attr("data-hash",SparkMD5.hash(a.serialize(),!1))})},
|
||||
account:function(){c.info("views:account");var a=$("#list-account-files");0<a.length&&b.appActions().account.getfiles(a);var d=$("#drop-account-files");0<d.length&&(d=b.fileUpload(d),d.url=b.appActions().ajaxUrl.account.getFiles,d.requestDoneAction=function(){b.appActions().account.getfiles(a)});d=$(".form-action");0<d.length&&d.attr("data-hash",SparkMD5.hash(d.serialize(),!1))},install:function(){c.info("views:install");f();var a=$("#frmInstall");b.appTheme().passwordDetect(a)}},selectDetect:e,updateSk:function(){$("#content").find("[data-sk]").each(function(){c.info("updateSk");
|
||||
$(this).data("sk",b.sk.get())})}}};
|
||||
|
||||
Reference in New Issue
Block a user