mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-11 02:46:56 +01:00
Merge remote-tracking branch 'origin/devel' into devel
Conflicts: inc/themes/material-blue/search.inc
This commit is contained in:
@@ -69,6 +69,7 @@ $accountGroupEditEnabled = Request::analyze('geditenabled', 0, false, 1);
|
||||
$accountUserEditEnabled = Request::analyze('ueditenabled', 0, false, 1);
|
||||
$accountMainGroupId = Request::analyze('mainGroupId', 0);
|
||||
$accountChangesHash = Request::analyze('hash');
|
||||
$customFieldsHash = Request::analyze('hashcf');
|
||||
$customFields = Request::analyze('customfield');
|
||||
|
||||
// Datos del Usuario
|
||||
@@ -138,6 +139,18 @@ if ($actionId == ActionsInterface::ACTION_ACC_NEW
|
||||
}
|
||||
|
||||
$Account = new Account;
|
||||
$Account->setAccountId($accountId);
|
||||
$Account->setAccountName($accountName);
|
||||
$Account->setAccountCategoryId($categoryId);
|
||||
$Account->setAccountCustomerId($customerId);
|
||||
$Account->setAccountLogin($accountLogin);
|
||||
$Account->setAccountUrl($accountUrl);
|
||||
$Account->setAccountNotes($accountNotes);
|
||||
$Account->setAccountUserEditId($currentUserId);
|
||||
$Account->setAccountUsersId($accountOtherUsers);
|
||||
$Account->setAccountUserGroupsId($accountOtherGroups);
|
||||
$Account->setAccountOtherUserEdit($accountUserEditEnabled);
|
||||
$Account->setAccountOtherGroupEdit($accountGroupEditEnabled);
|
||||
|
||||
switch ($actionId) {
|
||||
case ActionsInterface::ACTION_ACC_NEW:
|
||||
@@ -154,20 +167,10 @@ switch ($actionId) {
|
||||
}
|
||||
}
|
||||
|
||||
$Account->setAccountName($accountName);
|
||||
$Account->setAccountCategoryId($categoryId);
|
||||
$Account->setAccountCustomerId($customerId);
|
||||
$Account->setAccountLogin($accountLogin);
|
||||
$Account->setAccountUrl($accountUrl);
|
||||
$Account->setAccountPass($accountEncPass['data']);
|
||||
$Account->setAccountIV($accountEncPass['iv']);
|
||||
$Account->setAccountNotes($accountNotes);
|
||||
$Account->setAccountUserId($currentUserId);
|
||||
$Account->setAccountUserGroupId($accountMainGroupId);
|
||||
$Account->setAccountUsersId($accountOtherUsers);
|
||||
$Account->setAccountUserGroupsId($accountOtherGroups);
|
||||
$Account->setAccountOtherUserEdit($accountUserEditEnabled);
|
||||
$Account->setAccountOtherGroupEdit($accountGroupEditEnabled);
|
||||
|
||||
// Crear cuenta
|
||||
if ($Account->createAccount()) {
|
||||
@@ -196,36 +199,22 @@ switch ($actionId) {
|
||||
}
|
||||
}
|
||||
|
||||
$Account->setAccountId($accountId);
|
||||
$Account->setAccountName($accountName);
|
||||
$Account->setAccountCategoryId($categoryId);
|
||||
$Account->setAccountCustomerId($customerId);
|
||||
$Account->setAccountLogin($accountLogin);
|
||||
$Account->setAccountUrl($accountUrl);
|
||||
$Account->setAccountNotes($accountNotes);
|
||||
$Account->setAccountUserEditId($currentUserId);
|
||||
$Account->setAccountUsersId($accountOtherUsers);
|
||||
$Account->setAccountUserGroupsId($accountOtherGroups);
|
||||
$Account->setAccountOtherUserEdit($accountUserEditEnabled);
|
||||
$Account->setAccountOtherGroupEdit($accountGroupEditEnabled);
|
||||
|
||||
// Cambiar el grupo principal si el usuario es Admin
|
||||
if (Session::getUserIsAdminApp() || Session::getUserIsAdminAcc()) {
|
||||
$Account->setAccountUserGroupId($accountMainGroupId);
|
||||
}
|
||||
|
||||
// Comprobar si han habido cambios
|
||||
if ($accountChangesHash == $Account->calcChangesHash()) {
|
||||
if ($accountChangesHash == $Account->calcChangesHash()
|
||||
&& \SP\Mgmt\CustomFieldsUtil::checkHash($customFields, $customFieldsHash)
|
||||
) {
|
||||
Response::printJSON(_('Sin cambios'), 0);
|
||||
}
|
||||
|
||||
// Actualizar cuenta
|
||||
if ($Account->updateAccount()) {
|
||||
if (is_array($customFields)) {
|
||||
foreach ($customFields as $id => $value) {
|
||||
$CustomFields = new CustomFields($id, $accountId, $value);
|
||||
$CustomFields->updateCustomField();
|
||||
}
|
||||
\SP\Mgmt\CustomFieldsUtil::updateCustonFields($customFields, $accountId);
|
||||
}
|
||||
|
||||
Response::printJSON(_('Cuenta actualizada'), 0);
|
||||
@@ -246,10 +235,8 @@ switch ($actionId) {
|
||||
Response::printJSON(_('Error al eliminar la cuenta'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_ACC_EDIT_PASS:
|
||||
$Account->setAccountId($accountId);
|
||||
$Account->setAccountPass($accountEncPass['data']);
|
||||
$Account->setAccountIV($accountEncPass['iv']);
|
||||
$Account->setAccountUserEditId($currentUserId);
|
||||
|
||||
// Actualizar clave de cuenta
|
||||
if ($Account->updateAccountPass()) {
|
||||
|
||||
@@ -590,6 +590,18 @@ if ($actionId === ActionsInterface::ACTION_USR_USERS_NEW
|
||||
}
|
||||
|
||||
Response::printJSON(_('Error al eliminar el archivo'));
|
||||
} elseif ($actionId === ActionsInterface::ACTION_MGM_ACCOUNTS_DELETE) {
|
||||
$Account = new \SP\Account\Account();
|
||||
$Account->setAccountId($itemId);
|
||||
|
||||
// Eliminar cuenta
|
||||
if ($Account->deleteAccount()
|
||||
&& CustomFields::deleteCustomFieldForItem($itemId, ActionsInterface::ACTION_ACC_NEW)
|
||||
) {
|
||||
Response::printJSON(_('Cuenta eliminada'), 0, $doActionOnClose);
|
||||
}
|
||||
|
||||
Response::printJSON(_('Error al eliminar la cuenta'));
|
||||
} else {
|
||||
Response::printJSON(_('Acción Inválida'));
|
||||
}
|
||||
83
ajax/ajax_appMgmtSearch.php
Normal file
83
ajax/ajax_appMgmtSearch.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?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\ItemsMgmtSearch;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Core\Template;
|
||||
use SP\Http\Request;
|
||||
use SP\Http\Response;
|
||||
|
||||
define('APP_ROOT', '..');
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('POST');
|
||||
|
||||
if (!Init::isLoggedIn()) {
|
||||
Response::printJSON(_('La sesión no se ha iniciado o ha caducado'), 10);
|
||||
}
|
||||
|
||||
$sk = Request::analyze('sk', false);
|
||||
|
||||
if (!$sk || !SessionUtil::checkSessionKey($sk)) {
|
||||
Response::printJSON(_('CONSULTA INVÁLIDA'));
|
||||
}
|
||||
|
||||
$actionId = Request::analyze('actionId', 0);
|
||||
$search = Request::analyze('search');
|
||||
|
||||
$Tpl = new Template();
|
||||
$Tpl->assign('index', Request::analyze('activeTab', 0));
|
||||
|
||||
$Controller = new ItemsMgmtSearch($Tpl);
|
||||
|
||||
switch ($actionId) {
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_CATEGORIES_SEARCH:
|
||||
$Controller->getCategories($search);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_CUSTOMERS_SEARCH:
|
||||
$Controller->getCustomers($search);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_CUSTOMFIELDS_SEARCH:
|
||||
$Controller->getCustomFields($search);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_FILES_SEARCH:
|
||||
$Controller->getFiles($search);
|
||||
break;
|
||||
case \SP\Core\ActionsInterface::ACTION_MGM_ACCOUNTS_SEARCH:
|
||||
$Controller->getAccounts($search);
|
||||
break;
|
||||
default:
|
||||
Response::printJSON(_('Acción Inválida'));
|
||||
break;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'sk' => SessionUtil::getSessionKey(),
|
||||
'html' => $Controller->render()
|
||||
);
|
||||
|
||||
Response::printJSON($data, 0);
|
||||
@@ -146,6 +146,7 @@ switch ($actionId) {
|
||||
$Controller->getCustomers();
|
||||
$Controller->getCustomFields();
|
||||
$Controller->getFiles();
|
||||
$Controller->getAccounts();
|
||||
break;
|
||||
case ActionsInterface::ACTION_CFG:
|
||||
case ActionsInterface::ACTION_CFG_GENERAL:
|
||||
|
||||
@@ -27,6 +27,7 @@ use SP\Controller\SearchC;
|
||||
use SP\Core\Init;
|
||||
use SP\Http\Request;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Http\Response;
|
||||
use SP\Util\Util;
|
||||
|
||||
define('APP_ROOT', '..');
|
||||
@@ -42,9 +43,15 @@ if (!Init::isLoggedIn()) {
|
||||
$sk = \SP\Http\Request::analyze('sk', false);
|
||||
|
||||
if (!$sk || !SessionUtil::checkSessionKey($sk)) {
|
||||
die('<div class="error round">' . _('CONSULTA INVÁLIDA') . '</div>');
|
||||
Response::printJSON(_('CONSULTA INVÁLIDA'));
|
||||
}
|
||||
|
||||
$Controller = new SearchC();
|
||||
$Controller->getSearch();
|
||||
$Controller->view();
|
||||
|
||||
$data = array(
|
||||
'sk' => SessionUtil::getSessionKey(),
|
||||
'html' => $Controller->render()
|
||||
);
|
||||
|
||||
Response::printJSON($data, 0);
|
||||
@@ -133,7 +133,7 @@ class AccountSearch
|
||||
*/
|
||||
public function setTxtSearch($txtSearch)
|
||||
{
|
||||
$this->_txtSearch = $txtSearch;
|
||||
$this->_txtSearch = (string) $txtSearch;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -154,4 +154,67 @@ class AccountUtil
|
||||
|
||||
return ($queryRes !== false) ? $queryRes->account_name : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos de todas las cuentas y el cliente
|
||||
*
|
||||
* @return array
|
||||
* @throws SPException
|
||||
*/
|
||||
public static function getAccountsCustomerData()
|
||||
{
|
||||
$Data = new QueryData();
|
||||
$query = 'SELECT account_id,'
|
||||
. 'account_name,'
|
||||
. 'customer_name '
|
||||
. 'FROM accounts '
|
||||
. 'LEFT JOIN customers ON account_customerId = customer_id ';
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos de todas las cuentas y el cliente mediante una búsqueda
|
||||
*
|
||||
* @param string $search La cadena a buscar
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function getAccountsCustomerDataSearch($search)
|
||||
{
|
||||
$Data = new QueryData();
|
||||
|
||||
$search = '%' . $search . '%';
|
||||
|
||||
$query = 'SELECT account_id,'
|
||||
. 'account_name,'
|
||||
. 'customer_name '
|
||||
. 'FROM accounts '
|
||||
. 'LEFT JOIN customers ON account_customerId = customer_id '
|
||||
. 'WHERE account_name LIKE ? '
|
||||
. 'OR customer_name LIKE ?';
|
||||
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($search);
|
||||
$Data->addParam($search);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
}
|
||||
@@ -162,6 +162,8 @@ class AccountC extends Controller implements ActionsInterface
|
||||
*/
|
||||
private function setCommonData()
|
||||
{
|
||||
$this->getCustomFieldsForItem();
|
||||
|
||||
if ($this->isGotData()) {
|
||||
$this->view->assign('accountIsHistory', $this->getAccount()->getAccountIsHistory());
|
||||
$this->view->assign('accountOtherUsers', $this->getAccount()->getAccountUsersId());
|
||||
@@ -186,7 +188,8 @@ class AccountC extends Controller implements ActionsInterface
|
||||
$this->view->assign('customers', DBUtil::getValuesForSelect('customers', 'customer_id', 'customer_name'));
|
||||
$this->view->assign('otherUsers', DBUtil::getValuesForSelect('usrData', 'user_id', 'user_name'));
|
||||
$this->view->assign('otherGroups', DBUtil::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name'));
|
||||
$this->getCustomFieldsForItem();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,11 +25,17 @@
|
||||
|
||||
namespace SP\Controller;
|
||||
|
||||
use SP\Account\AccountUtil;
|
||||
use SP\Config\Config;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Template;
|
||||
use SP\Html\DataGrid\DataGridAction;
|
||||
use SP\Html\DataGrid\DataGridActionSearch;
|
||||
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\Category;
|
||||
@@ -79,9 +85,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param $template \SP\Core\Template con instancia de plantilla
|
||||
* @param $template Template con instancia de plantilla
|
||||
*/
|
||||
public function __construct(\SP\Core\Template $template = null)
|
||||
public function __construct(Template $template = null)
|
||||
{
|
||||
parent::__construct($template);
|
||||
|
||||
@@ -103,13 +109,31 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
}
|
||||
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
$this->view->append('tabs', $this->getCategoriesGrid());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $search
|
||||
* @return DataGridTab
|
||||
*/
|
||||
public function getCategoriesGrid($search = '')
|
||||
{
|
||||
$GridActionSearch = new DataGridActionSearch();
|
||||
$GridActionSearch->setId(self::ACTION_MGM_CATEGORIES_SEARCH);
|
||||
$GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
|
||||
$GridActionSearch->setName('frmSearchCustomer');
|
||||
$GridActionSearch->setTitle(_('Buscar Categoría'));
|
||||
$GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
|
||||
$GridActionSearch->setOnSubmitArgs('this');
|
||||
$GridActionSearch->setOnSubmitArgs($this->view->sk);
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::ACTION_MGM_CATEGORIES_NEW);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setName(_('Nueva Categoría'));
|
||||
$GridActionNew->setTitle(_('Nueva Categoría'));
|
||||
$GridActionNew->setIcon($this->_iconAdd);
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setIsNew(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_MGM_CATEGORIES_NEW);
|
||||
@@ -117,7 +141,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(self::ACTION_MGM_CATEGORIES_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(_('Editar Categoría'));
|
||||
$GridActionEdit->setTitle(_('Editar Categoría'));
|
||||
$GridActionEdit->setIcon($this->_iconEdit);
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
@@ -126,9 +152,10 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_MGM_CATEGORIES_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Categoría'));
|
||||
$GridActionDel->setTitle(_('Eliminar Categoría'));
|
||||
$GridActionDel->setIcon($this->_iconDelete);
|
||||
$GridActionDel->setIsDelete(true);
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_MGM_CATEGORIES_DELETE);
|
||||
@@ -142,19 +169,28 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
$GridData->setDataRowSourceId('category_id');
|
||||
$GridData->addDataRowSource('category_name');
|
||||
$GridData->addDataRowSource('category_description');
|
||||
$GridData->setData(Category::getCategories());
|
||||
|
||||
if(empty($search)) {
|
||||
$GridData->setData(Category::getCategories());
|
||||
} else {
|
||||
$GridData->setData(Category::getCategoriesSearch($search));
|
||||
}
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblCategories');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionNew);
|
||||
$Grid->setDataActions($GridActionEdit);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setDataActions($GridActionSearch);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Categorías'));
|
||||
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,13 +205,31 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
}
|
||||
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
$this->view->append('tabs', $this->getCustomersGrid());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $search
|
||||
* @return DataGridTab
|
||||
*/
|
||||
public function getCustomersGrid($search = '')
|
||||
{
|
||||
$GridActionSearch = new DataGridActionSearch();
|
||||
$GridActionSearch->setId(self::ACTION_MGM_CUSTOMERS_SEARCH);
|
||||
$GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
|
||||
$GridActionSearch->setName('frmSearchCustomer');
|
||||
$GridActionSearch->setTitle(_('Buscar Cliente'));
|
||||
$GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
|
||||
$GridActionSearch->setOnSubmitArgs('this');
|
||||
$GridActionSearch->setOnSubmitArgs($this->view->sk);
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::ACTION_MGM_CUSTOMERS_NEW);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setName(_('Nuevo Cliente'));
|
||||
$GridActionNew->setTitle(_('Nuevo Cliente'));
|
||||
$GridActionNew->setIcon($this->_iconAdd);
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setIsNew(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_MGM_CUSTOMERS_NEW);
|
||||
@@ -183,7 +237,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(self::ACTION_MGM_CUSTOMERS_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(_('Editar Cliente'));
|
||||
$GridActionEdit->setTitle(_('Editar Cliente'));
|
||||
$GridActionEdit->setIcon($this->_iconEdit);
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
@@ -192,9 +248,10 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_MGM_CUSTOMERS_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Cliente'));
|
||||
$GridActionDel->setTitle(_('Eliminar Cliente'));
|
||||
$GridActionDel->setIcon($this->_iconDelete);
|
||||
$GridActionDel->setIsDelete(true);
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_MGM_CUSTOMERS_DELETE);
|
||||
@@ -208,19 +265,28 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
$GridData->setDataRowSourceId('customer_id');
|
||||
$GridData->addDataRowSource('customer_name');
|
||||
$GridData->addDataRowSource('customer_description');
|
||||
$GridData->setData(Customer::getCustomers());
|
||||
|
||||
if (empty($search)) {
|
||||
$GridData->setData(Customer::getCustomers());
|
||||
} else {
|
||||
$GridData->setData(Customer::getCustomersSearch($search));
|
||||
}
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblCustomers');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionNew);
|
||||
$Grid->setDataActions($GridActionEdit);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setDataActions($GridActionSearch);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Clientes'));
|
||||
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,13 +370,31 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
}
|
||||
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
$this->view->append('tabs', $this->getCustomFieldsGrid());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $search
|
||||
* @return DataGridTab
|
||||
*/
|
||||
public function getCustomFieldsGrid($search = '')
|
||||
{
|
||||
$GridActionSearch = new DataGridActionSearch();
|
||||
$GridActionSearch->setId(self::ACTION_MGM_CUSTOMFIELDS_SEARCH);
|
||||
$GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
|
||||
$GridActionSearch->setName('frmSearchCustomField');
|
||||
$GridActionSearch->setTitle(_('Buscar Campo'));
|
||||
$GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
|
||||
$GridActionSearch->setOnSubmitArgs('this');
|
||||
$GridActionSearch->setOnSubmitArgs($this->view->sk);
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::ACTION_MGM_CUSTOMFIELDS_NEW);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setName(_('Nuevo Campo'));
|
||||
$GridActionNew->setTitle(_('Nuevo Campo'));
|
||||
$GridActionNew->setIcon($this->_iconAdd);
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setIsNew(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_MGM_CUSTOMFIELDS_NEW);
|
||||
@@ -318,7 +402,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(self::ACTION_MGM_CUSTOMFIELDS_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(_('Editar Campo'));
|
||||
$GridActionEdit->setTitle(_('Editar Campo'));
|
||||
$GridActionEdit->setIcon($this->_iconEdit);
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
@@ -327,9 +413,10 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_MGM_CUSTOMFIELDS_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Campo'));
|
||||
$GridActionDel->setTitle(_('Eliminar Campo'));
|
||||
$GridActionDel->setIcon($this->_iconDelete);
|
||||
$GridActionDel->setIsDelete(true);
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_MGM_CUSTOMFIELDS_DELETE);
|
||||
@@ -345,19 +432,28 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
$GridData->addDataRowSource('module');
|
||||
$GridData->addDataRowSource('name');
|
||||
$GridData->addDataRowSource('typeName');
|
||||
$GridData->setData(CustomFieldDef::getCustomFields());
|
||||
|
||||
if(empty($search)) {
|
||||
$GridData->setData(CustomFieldDef::getCustomFields());
|
||||
} else {
|
||||
$GridData->setData(CustomFieldDef::getCustomFieldsSearch($search));
|
||||
}
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblCustomFields');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionNew);
|
||||
$Grid->setDataActions($GridActionEdit);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setDataActions($GridActionSearch);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Campos Personalizados'));
|
||||
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,9 +501,27 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
}
|
||||
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
$this->view->append('tabs', $this->getFilesGrid());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $search
|
||||
* @return DataGridTab
|
||||
*/
|
||||
public function getFilesGrid($search = '')
|
||||
{
|
||||
$GridActionSearch = new DataGridActionSearch();
|
||||
$GridActionSearch->setId(self::ACTION_MGM_FILES_SEARCH);
|
||||
$GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
|
||||
$GridActionSearch->setName('frmSearchFile');
|
||||
$GridActionSearch->setTitle(_('Buscar Archivo'));
|
||||
$GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
|
||||
$GridActionSearch->setOnSubmitArgs('this');
|
||||
$GridActionSearch->setOnSubmitArgs($this->view->sk);
|
||||
|
||||
$GridActionView = new DataGridAction();
|
||||
$GridActionView->setId(self::ACTION_MGM_FILES_VIEW);
|
||||
$GridActionView->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionView->setName(_('Ver Archivo'));
|
||||
$GridActionView->setIcon($this->_iconView);
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.viewFile');
|
||||
@@ -417,9 +531,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_MGM_FILES_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Archivo'));
|
||||
$GridActionDel->setIcon($this->_iconDelete);
|
||||
$GridActionDel->setIsDelete(true);
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_MGM_FILES_DELETE);
|
||||
@@ -439,17 +553,116 @@ class AccountsMgmtC extends Controller implements ActionsInterface
|
||||
$GridData->addDataRowSource('accfile_name');
|
||||
$GridData->addDataRowSource('accfile_type');
|
||||
$GridData->addDataRowSource('accfile_size');
|
||||
$GridData->setData(Files::getFileList());
|
||||
|
||||
if (empty($search)) {
|
||||
$GridData->setData(Files::getFileList());
|
||||
} else {
|
||||
$GridData->setData(Files::getFileListSearch($search));
|
||||
}
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblFiles');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionView);
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setDataActions($GridActionSearch);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Archivos'));
|
||||
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
|
||||
|
||||
$this->view->append('tabs', $Grid);
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la pestaña de cuentas
|
||||
*/
|
||||
public function getAccounts()
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_ACCOUNTS);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
$this->view->append('tabs', $this->getAccountsGrid());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $search La cadena de búsqueda
|
||||
* @return DataGridTab
|
||||
*/
|
||||
public function getAccountsGrid($search = '')
|
||||
{
|
||||
$GridActionSearch = new DataGridActionSearch();
|
||||
$GridActionSearch->setId(self::ACTION_MGM_ACCOUNTS_SEARCH);
|
||||
$GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
|
||||
$GridActionSearch->setName('frmSearchAccount');
|
||||
$GridActionSearch->setTitle(_('Buscar Cuenta'));
|
||||
$GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
|
||||
$GridActionSearch->setOnSubmitArgs('this');
|
||||
$GridActionSearch->setOnSubmitArgs($this->view->sk);
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(self::ACTION_MGM_ACCOUNTS_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(_('Eliminar Cuenta'));
|
||||
$GridActionDel->setTitle(_('Eliminar Cuenta'));
|
||||
$GridActionDel->setIcon($this->_iconDelete);
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_MGM_ACCOUNTS_DELETE);
|
||||
$GridActionDel->setOnClickArgs($this->view->sk);
|
||||
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(_('Nombre'));
|
||||
$GridHeaders->addHeader(_('Cliente'));
|
||||
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('account_id');
|
||||
$GridData->addDataRowSource('account_name');
|
||||
$GridData->addDataRowSource('customer_name');
|
||||
|
||||
if (empty($search)) {
|
||||
$GridData->setData(AccountUtil::getAccountsCustomerData());
|
||||
} else {
|
||||
$GridData->setData(AccountUtil::getAccountsCustomerDataSearch($search));
|
||||
}
|
||||
|
||||
$Grid = new DataGridTab();
|
||||
$Grid->setId('tblAccounts');
|
||||
$Grid->setDataRowTemplate('datagrid-rows');
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full');
|
||||
$Grid->setDataActions($GridActionDel);
|
||||
$Grid->setDataActions($GridActionSearch);
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(_('Gestión de Cuentas'));
|
||||
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
|
||||
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,13 +104,21 @@ abstract class Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderizar los datos de la plantilla
|
||||
* Renderizar los datos de la plantilla y mostrarlos
|
||||
*/
|
||||
public function view()
|
||||
{
|
||||
echo $this->view->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderizar los datos de la plantilla y devolverlos
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la vista de depuración
|
||||
*/
|
||||
|
||||
163
inc/SP/Controller/ItemsMgmtSearch.class.php
Normal file
163
inc/SP/Controller/ItemsMgmtSearch.class.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?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\ActionsInterface;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Core\Template;
|
||||
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
|
||||
{
|
||||
/**
|
||||
* 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());
|
||||
$this->view->assign('queryTimeStart', microtime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener las cuentas de una búsqueda
|
||||
*
|
||||
* @param string $search La cadena a buscar
|
||||
* @throws \SP\Core\SPException
|
||||
*/
|
||||
public function getAccounts($search)
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_ACCOUNTS_SEARCH);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$AccountMgmt = new AccountsMgmtC($this->view);
|
||||
|
||||
$this->view->assign('data', $AccountMgmt->getAccountsGrid($search));
|
||||
$this->view->assign('actionId', self::ACTION_MGM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los archivos de una búsqueda
|
||||
*
|
||||
* @param string $search La cadena a buscar
|
||||
* @throws \SP\Core\SPException
|
||||
*/
|
||||
public function getFiles($search)
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_FILES_SEARCH);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$AccountMgmt = new AccountsMgmtC($this->view);
|
||||
|
||||
$this->view->assign('data', $AccountMgmt->getFilesGrid($search));
|
||||
$this->view->assign('actionId', self::ACTION_MGM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los campos personalizados de una búsqueda
|
||||
*
|
||||
* @param string $search La cadena a buscar
|
||||
* @throws \SP\Core\SPException
|
||||
*/
|
||||
public function getCustomFields($search)
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_CUSTOMFIELDS_SEARCH);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$AccountMgmt = new AccountsMgmtC($this->view);
|
||||
|
||||
$this->view->assign('data', $AccountMgmt->getCustomFieldsGrid($search));
|
||||
$this->view->assign('actionId', self::ACTION_MGM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los clientes de una búsqueda
|
||||
*
|
||||
* @param string $search La cadena a buscar
|
||||
* @throws \SP\Core\SPException
|
||||
*/
|
||||
public function getCustomers($search)
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_CUSTOMERS_SEARCH);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$AccountMgmt = new AccountsMgmtC($this->view);
|
||||
|
||||
$this->view->assign('data', $AccountMgmt->getCustomersGrid($search));
|
||||
$this->view->assign('actionId', self::ACTION_MGM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener las categorías de una búsqueda
|
||||
*
|
||||
* @param string $search La cadena a buscar
|
||||
* @throws \SP\Core\SPException
|
||||
*/
|
||||
public function getCategories($search)
|
||||
{
|
||||
$this->setAction(self::ACTION_MGM_CATEGORIES_SEARCH);
|
||||
|
||||
if (!$this->checkAccess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('datagrid-rows');
|
||||
|
||||
$AccountMgmt = new AccountsMgmtC($this->view);
|
||||
|
||||
$this->view->assign('data', $AccountMgmt->getCategoriesGrid($search));
|
||||
$this->view->assign('actionId', self::ACTION_MGM);
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ class SearchC extends Controller implements ActionsInterface
|
||||
}
|
||||
|
||||
// Obtener el filtro de búsqueda desde la sesión
|
||||
$filters = \SP\Core\Session::getSearchFilters();
|
||||
$filters = Session::getSearchFilters();
|
||||
|
||||
// Valores POST
|
||||
$this->view->assign('searchKey', Request::analyze('skey', $filters->getSortKey()));
|
||||
@@ -182,7 +182,7 @@ class SearchC extends Controller implements ActionsInterface
|
||||
|
||||
$limitLast = ((AccountSearch::$queryNumRows % $this->view->limitCount) == 0) ? AccountSearch::$queryNumRows - $this->view->limitCount : floor(AccountSearch::$queryNumRows / $this->view->limitCount) * $this->view->limitCount;
|
||||
|
||||
$this->view->assign('pagerOnnClick', array(
|
||||
$this->view->assign('pagerOnClick', array(
|
||||
'first' => 'sysPassUtil.Common.searchSort(' . $this->view->searchKey . ', 0,1)',
|
||||
'last' => 'sysPassUtil.Common.searchSort(' . $this->view->searchKey . ',' . $limitLast . ',1)',
|
||||
'prev' => 'sysPassUtil.Common.searchSort(' . $this->view->searchKey . ',' . ($this->view->limitStart - $this->view->limitCount) . ',1)',
|
||||
|
||||
@@ -26,12 +26,16 @@
|
||||
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;
|
||||
@@ -117,10 +121,11 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconAdd);
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setIsNew(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_USR_USERS_NEW);
|
||||
@@ -128,7 +133,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconView);
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
@@ -137,7 +144,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconEdit);
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
@@ -146,9 +155,10 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconDelete);
|
||||
$GridActionDel->setIsDelete(true);
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_USR_USERS_DELETE);
|
||||
@@ -156,7 +166,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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');
|
||||
@@ -185,12 +197,15 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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));
|
||||
@@ -211,10 +226,11 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconAdd);
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setIsNew(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_USR_GROUPS_NEW);
|
||||
@@ -222,7 +238,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconEdit);
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
@@ -231,9 +249,10 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconDelete);
|
||||
$GridActionDel->setIsDelete(true);
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_USR_GROUPS_DELETE);
|
||||
@@ -251,10 +270,13 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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));
|
||||
@@ -275,10 +297,11 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconAdd);
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setIsNew(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_USR_PROFILES_NEW);
|
||||
@@ -286,7 +309,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconView);
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
@@ -295,7 +320,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconEdit);
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
@@ -304,9 +331,10 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconDelete);
|
||||
$GridActionDel->setIsDelete(true);
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_USR_PROFILES_DELETE);
|
||||
@@ -322,11 +350,14 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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));
|
||||
@@ -441,10 +472,11 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconAdd);
|
||||
$GridActionNew->setSkip(true);
|
||||
$GridActionNew->setIsNew(true);
|
||||
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionNew->setOnClickArgs('this');
|
||||
$GridActionNew->setOnClickArgs(self::ACTION_MGM_APITOKENS_NEW);
|
||||
@@ -452,7 +484,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconView);
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
@@ -461,7 +495,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconEdit);
|
||||
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionEdit->setOnClickArgs('this');
|
||||
@@ -470,9 +506,10 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconDelete);
|
||||
$GridActionDel->setIsDelete(true);
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_MGM_APITOKENS_DELETE);
|
||||
@@ -490,11 +527,14 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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));
|
||||
@@ -535,7 +575,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconView);
|
||||
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
|
||||
$GridActionView->setOnClickArgs('this');
|
||||
@@ -545,6 +587,7 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
$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');
|
||||
@@ -553,9 +596,10 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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->_iconDelete);
|
||||
$GridActionDel->setIsDelete(true);
|
||||
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
|
||||
$GridActionDel->setOnClickArgs('this');
|
||||
$GridActionDel->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_DELETE);
|
||||
@@ -581,10 +625,13 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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));
|
||||
@@ -601,4 +648,23 @@ class UsersMgmtC extends Controller implements ActionsInterface
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -59,29 +59,39 @@ interface ActionsInterface {
|
||||
const ACTION_MGM_CATEGORIES_NEW = 611;
|
||||
const ACTION_MGM_CATEGORIES_EDIT = 612;
|
||||
const ACTION_MGM_CATEGORIES_DELETE = 613;
|
||||
const ACTION_MGM_CATEGORIES_SEARCH = 615;
|
||||
const ACTION_MGM_CUSTOMERS = 62;
|
||||
const ACTION_MGM_CUSTOMERS_VIEW = 620;
|
||||
const ACTION_MGM_CUSTOMERS_NEW = 621;
|
||||
const ACTION_MGM_CUSTOMERS_EDIT = 622;
|
||||
const ACTION_MGM_CUSTOMERS_DELETE = 623;
|
||||
const ACTION_MGM_CUSTOMERS_SEARCH = 625;
|
||||
const ACTION_MGM_APITOKENS = 63;
|
||||
const ACTION_MGM_APITOKENS_NEW = 630;
|
||||
const ACTION_MGM_APITOKENS_VIEW = 631;
|
||||
const ACTION_MGM_APITOKENS_EDIT = 632;
|
||||
const ACTION_MGM_APITOKENS_DELETE = 633;
|
||||
const ACTION_MGM_APITOKENS_SEARCH = 635;
|
||||
const ACTION_MGM_CUSTOMFIELDS = 64;
|
||||
const ACTION_MGM_CUSTOMFIELDS_NEW = 640;
|
||||
const ACTION_MGM_CUSTOMFIELDS_VIEW = 641;
|
||||
const ACTION_MGM_CUSTOMFIELDS_EDIT = 642;
|
||||
const ACTION_MGM_CUSTOMFIELDS_DELETE = 643;
|
||||
const ACTION_MGM_CUSTOMFIELDS_SEARCH = 645;
|
||||
const ACTION_MGM_PUBLICLINKS = 65;
|
||||
const ACTION_MGM_PUBLICLINKS_NEW = 650;
|
||||
const ACTION_MGM_PUBLICLINKS_VIEW = 651;
|
||||
const ACTION_MGM_PUBLICLINKS_DELETE = 653;
|
||||
const ACTION_MGM_PUBLICLINKS_REFRESH = 654;
|
||||
const ACTION_MGM_PUBLICLINKS_SEARCH = 655;
|
||||
const ACTION_MGM_FILES = 66;
|
||||
const ACTION_MGM_FILES_VIEW = 661;
|
||||
const ACTION_MGM_FILES_DELETE = 663;
|
||||
const ACTION_MGM_FILES_SEARCH = 665;
|
||||
const ACTION_MGM_ACCOUNTS = 67;
|
||||
const ACTION_MGM_ACCOUNTS_VIEW = 671;
|
||||
const ACTION_MGM_ACCOUNTS_DELETE = 673;
|
||||
const ACTION_MGM_ACCOUNTS_SEARCH = 675;
|
||||
const ACTION_USR = 70;
|
||||
const ACTION_USR_USERS = 71;
|
||||
const ACTION_USR_USERS_VIEW= 710;
|
||||
|
||||
@@ -56,7 +56,9 @@ class Template
|
||||
*/
|
||||
public function __construct($file = null, array $vars = array())
|
||||
{
|
||||
$this->addTemplate($file);
|
||||
if (!is_null($file)) {
|
||||
$this->addTemplate($file);
|
||||
}
|
||||
|
||||
if (!empty($vars)) {
|
||||
$this->setVars($vars);
|
||||
@@ -71,19 +73,37 @@ class Template
|
||||
*/
|
||||
public function addTemplate($file)
|
||||
{
|
||||
if (!is_null($file) && $this->checkTemplate($file)) {
|
||||
return true;
|
||||
try {
|
||||
$template = $this->checkTemplate($file);
|
||||
$this->setTemplate($template);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Añadir una nueva plantilla dentro de una plantilla
|
||||
*
|
||||
* @param string $file Con el nombre del archivo de plantilla
|
||||
* @return bool
|
||||
*/
|
||||
public function includeTemplate($file)
|
||||
{
|
||||
try {
|
||||
$template = $this->checkTemplate($file);
|
||||
return $template;
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si un archivo de plantilla existe y se puede leer
|
||||
*
|
||||
* @param string $file Con el nombre del archivo
|
||||
* @return bool
|
||||
* @throws InvalidArgumentException
|
||||
* @return string La ruta al archivo de la plantilla
|
||||
*/
|
||||
private function checkTemplate($file)
|
||||
{
|
||||
@@ -94,8 +114,7 @@ class Template
|
||||
throw new InvalidArgumentException(sprintf(_('No es posible obtener la plantilla "%s" : %s'), $file, $template));
|
||||
}
|
||||
|
||||
$this->setTemplate($template);
|
||||
return true;
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,24 +67,12 @@ abstract class DataGridActionBase implements DataGridActionInterface
|
||||
* @var DataGridIcon
|
||||
*/
|
||||
private $_icon = null;
|
||||
/**
|
||||
* Si es una acción de eliminar elementos
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_isDelete = false;
|
||||
/**
|
||||
* Si se debe de omitir para los elementos del listado
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_isSkip = false;
|
||||
/**
|
||||
* Si es una acción para crear elementos
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_isNew = false;
|
||||
/**
|
||||
* La columna de origen de datos que condiciona esta acción
|
||||
*
|
||||
@@ -97,6 +85,12 @@ abstract class DataGridActionBase implements DataGridActionInterface
|
||||
* @var bool
|
||||
*/
|
||||
private $_isHelper;
|
||||
/**
|
||||
* El tipo de acción
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_type = 0;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
@@ -208,38 +202,6 @@ abstract class DataGridActionBase implements DataGridActionInterface
|
||||
return $this->_isSkip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $delete bool
|
||||
*/
|
||||
public function setIsDelete($delete)
|
||||
{
|
||||
$this->_isDelete = $delete;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDelete()
|
||||
{
|
||||
return $this->_isDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $new
|
||||
*/
|
||||
public function setIsNew($new)
|
||||
{
|
||||
$this->_isNew = $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNew()
|
||||
{
|
||||
return $this->_isNew;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $helper
|
||||
*/
|
||||
@@ -271,4 +233,20 @@ abstract class DataGridActionBase implements DataGridActionInterface
|
||||
{
|
||||
return $this->_filterRowSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $type El tipo de acción definido en DataGridActionType
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->_type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int El tipo de acción
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->_type;
|
||||
}
|
||||
}
|
||||
@@ -97,26 +97,6 @@ interface DataGridActionInterface
|
||||
*/
|
||||
public function isSkip();
|
||||
|
||||
/**
|
||||
* @param $delete bool
|
||||
*/
|
||||
public function setIsDelete($delete);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDelete();
|
||||
|
||||
/**
|
||||
* @param $new bool
|
||||
*/
|
||||
public function setIsNew($new);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNew();
|
||||
|
||||
/**
|
||||
* @param bool $helper
|
||||
*/
|
||||
@@ -136,4 +116,14 @@ interface DataGridActionInterface
|
||||
* @return string
|
||||
*/
|
||||
public function getFilterRowSource();
|
||||
|
||||
/**
|
||||
* @param int $type El tipo de acción definido en DataGridActionType
|
||||
*/
|
||||
public function setType($type);
|
||||
|
||||
/**
|
||||
* @return int El tipo de acción
|
||||
*/
|
||||
public function getType();
|
||||
}
|
||||
|
||||
84
inc/SP/Html/DataGrid/DataGridActionSearch.class.php
Normal file
84
inc/SP/Html/DataGrid/DataGridActionSearch.class.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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\Html\DataGrid;
|
||||
|
||||
/**
|
||||
* Class DataGridActionSearch para definir una acción de búsqueda de datos
|
||||
*
|
||||
* @package SP\Html\DataGrid
|
||||
*/
|
||||
class DataGridActionSearch extends DataGridActionBase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_onSubmitFunction = '';
|
||||
|
||||
/**
|
||||
* Los argumentos de la función OnSubmit
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_onSubmitArgs = array();
|
||||
|
||||
/**
|
||||
* DataGridActionSearch constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->setSkip(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOnSubmit()
|
||||
{
|
||||
$args = array();
|
||||
|
||||
foreach ($this->_onSubmitArgs as $arg) {
|
||||
$args[] = (!is_numeric($arg) && $arg !== 'this') ? '\'' . $arg . '\'' : $arg;
|
||||
}
|
||||
|
||||
return 'return ' . $this->_onSubmitFunction . '(' . implode(',', $args) . ');';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $onSubmitFunction
|
||||
*/
|
||||
public function setOnSubmitFunction($onSubmitFunction)
|
||||
{
|
||||
$this->_onSubmitFunction = $onSubmitFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $args
|
||||
*/
|
||||
public function setOnSubmitArgs($args)
|
||||
{
|
||||
$this->_onSubmitArgs[] = $args;
|
||||
}
|
||||
}
|
||||
40
inc/SP/Html/DataGrid/DataGridActionType.class.php
Normal file
40
inc/SP/Html/DataGrid/DataGridActionType.class.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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\Html\DataGrid;
|
||||
|
||||
/**
|
||||
* Class DataGridActionType para definir los tipos de acciones
|
||||
*
|
||||
* @package SP\Html\DataGrid
|
||||
*/
|
||||
class DataGridActionType
|
||||
{
|
||||
const NEW_ITEM = 1;
|
||||
const VIEW_ITEM = 2;
|
||||
const EDIT_ITEM = 3;
|
||||
const DELETE_ITEM = 4;
|
||||
const SEARCH_ITEM = 5;
|
||||
}
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
namespace SP\Html\DataGrid;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Themes;
|
||||
use SplObjectStorage;
|
||||
|
||||
/**
|
||||
@@ -53,6 +55,12 @@ abstract class DataGridBase implements DataGridInterface
|
||||
* @var DataGridData
|
||||
*/
|
||||
private $_data;
|
||||
/**
|
||||
* El paginador
|
||||
*
|
||||
* @var DataGridPagerBase
|
||||
*/
|
||||
private $_pager;
|
||||
/**
|
||||
* Las acciones asociadas a los elementos de la matriz
|
||||
*
|
||||
@@ -65,6 +73,30 @@ abstract class DataGridBase implements DataGridInterface
|
||||
* @var int
|
||||
*/
|
||||
private $_onCloseAction = 0;
|
||||
/**
|
||||
* La pantilla a utilizar para presentar la cabecera
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_headerTemplate;
|
||||
/**
|
||||
* La pantilla a utilizar para presentar las acciones
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_actionsTemplate;
|
||||
/**
|
||||
* La pantilla a utilizar para presentar el paginador
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_pagerTemplate;
|
||||
/**
|
||||
* La pantilla a utilizar para presentar los datos
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_rowsTemplate;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
@@ -131,9 +163,9 @@ abstract class DataGridBase implements DataGridInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataGridAction $action
|
||||
* @param DataGridActionBase $action
|
||||
*/
|
||||
public function setDataActions(DataGridAction $action)
|
||||
public function setDataActions(DataGridActionBase $action)
|
||||
{
|
||||
if (is_null($this->_actions)) {
|
||||
$this->_actions = new SplObjectStorage();
|
||||
@@ -151,10 +183,126 @@ abstract class DataGridBase implements DataGridInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return $this
|
||||
*/
|
||||
public function getGrid()
|
||||
{
|
||||
// TODO: Implement getGrid() method.
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer la plantilla utilizada para la cabecera
|
||||
*
|
||||
* @param string $template El nombre de la plantilla a utilizar
|
||||
*/
|
||||
public function setDataHeaderTemplate($template)
|
||||
{
|
||||
$this->_headerTemplate = $this->checkTemplate($template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si existe una plantilla y devolver la ruta completa
|
||||
*
|
||||
* @param $template
|
||||
* @return string
|
||||
*/
|
||||
protected function checkTemplate($template)
|
||||
{
|
||||
$file = VIEW_PATH . DIRECTORY_SEPARATOR . Themes::$theme . DIRECTORY_SEPARATOR . $template . '.inc';
|
||||
|
||||
if (!is_readable($file)) {
|
||||
throw new InvalidArgumentException(sprintf(_('No es posible obtener la plantilla "%s" : %s'), $template, $file));
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver la plantilla utilizada para la cabecera
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataHeaderTemplate()
|
||||
{
|
||||
return $this->_headerTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer la plantilla utilizada para las acciones
|
||||
*
|
||||
* @param string $template El nombre de la plantilla a utilizar
|
||||
*/
|
||||
public function setDataActionsTemplate($template)
|
||||
{
|
||||
$this->_actionsTemplate = $this->checkTemplate($template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver la plantilla utilizada para las acciones
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataActionsTemplate()
|
||||
{
|
||||
return $this->_actionsTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer la plantilla utilizada para el paginador
|
||||
*
|
||||
* @param string $template El nombre de la plantilla a utilizar
|
||||
*/
|
||||
public function setDataPagerTemplate($template)
|
||||
{
|
||||
$this->_pagerTemplate = $this->checkTemplate($template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver la plantilla utilizada para el paginador
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataPagerTemplate()
|
||||
{
|
||||
return $this->_pagerTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $template El nombre de la plantilla a utilizar
|
||||
* @return mixed
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function setDataRowTemplate($template)
|
||||
{
|
||||
$this->_rowsTemplate = $this->checkTemplate($template);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDataRowTemplate()
|
||||
{
|
||||
return $this->_rowsTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer el paginador
|
||||
*
|
||||
* @param DataGridPagerBase $pager
|
||||
*/
|
||||
public function setPager(DataGridPagerBase $pager)
|
||||
{
|
||||
$this->_pager = $pager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el paginador
|
||||
*
|
||||
* @return DataGridPagerBase
|
||||
*/
|
||||
public function getPager()
|
||||
{
|
||||
return $this->_pager;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,6 +56,10 @@ abstract class DataGridDataBase implements DataGridDataInterface
|
||||
* @var array
|
||||
*/
|
||||
private $_sourcesWithIcon = array();
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $_dataCount = 0;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
@@ -110,6 +114,7 @@ abstract class DataGridDataBase implements DataGridDataInterface
|
||||
*/
|
||||
public function setData(array $data)
|
||||
{
|
||||
$this->_dataCount = count($data);
|
||||
$this->_data = $data;
|
||||
}
|
||||
|
||||
@@ -121,4 +126,14 @@ abstract class DataGridDataBase implements DataGridDataInterface
|
||||
{
|
||||
$this->_sourcesWithIcon[] = array($source, $icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el número de elementos obtenidos
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDataCount()
|
||||
{
|
||||
return $this->_dataCount;
|
||||
}
|
||||
}
|
||||
@@ -33,44 +33,66 @@ namespace SP\Html\DataGrid;
|
||||
interface DataGridDataInterface
|
||||
{
|
||||
/**
|
||||
* Establecer los orígenes de datos de la consulta
|
||||
*
|
||||
* @param $source string
|
||||
*/
|
||||
public function addDataRowSource($source);
|
||||
|
||||
/**
|
||||
* Devolver los orígenes de datos de la consulta
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDataRowSources();
|
||||
|
||||
/**
|
||||
* Establecer el origen de datos utilizado como Id de los elementos
|
||||
*
|
||||
* @param $id string
|
||||
*/
|
||||
public function setDataRowSourceId($id);
|
||||
|
||||
/**
|
||||
* Devolver el origen de datos utilizado como Id de los elementos
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataRowSourceId();
|
||||
|
||||
/**
|
||||
* Establecer los datos de la consulta
|
||||
*
|
||||
* @param $data array
|
||||
*/
|
||||
public function setData(array $data);
|
||||
|
||||
/**
|
||||
* Devolver los datos de la consulta
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData();
|
||||
|
||||
/**
|
||||
* Establecer los orígenes de datos que se muestran con iconos
|
||||
*
|
||||
* @param $source string
|
||||
* @param $icon DatagridIcon
|
||||
* @return
|
||||
*/
|
||||
public function addDataRowSourceWithIcon($source, $icon);
|
||||
|
||||
/**
|
||||
* Devolver los orígenes de datos que se muestran con iconos
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDataRowSourcesWithIcon();
|
||||
|
||||
/**
|
||||
* Devolver el número de elementos obtenidos
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDataCount();
|
||||
}
|
||||
@@ -65,12 +65,12 @@ interface DataGridInterface
|
||||
public function getData();
|
||||
|
||||
/**
|
||||
* @param DataGridAction $action
|
||||
* @param DataGridActionBase $action
|
||||
*/
|
||||
public function setDataActions(DataGridAction $action);
|
||||
public function setDataActions(DataGridActionBase $action);
|
||||
|
||||
/**
|
||||
* @return DataGridAction
|
||||
* @return DataGridActionBase
|
||||
*/
|
||||
public function getDataActions();
|
||||
|
||||
@@ -79,8 +79,78 @@ interface DataGridInterface
|
||||
*/
|
||||
public function getGrid();
|
||||
|
||||
/**
|
||||
* Establecer el paginador
|
||||
*
|
||||
* @param DataGridPagerBase $pager
|
||||
*/
|
||||
public function setPager(DataGridPagerBase $pager);
|
||||
|
||||
/**
|
||||
* Devolver el paginador
|
||||
*
|
||||
* @return DataGridPagerBase
|
||||
*/
|
||||
public function getPager();
|
||||
|
||||
/**
|
||||
* @param ActionsInterface $action
|
||||
*/
|
||||
public function setOnCloseAction(ActionsInterface $action);
|
||||
|
||||
/**
|
||||
* Establecer la plantilla utilizada para la cabecera
|
||||
*
|
||||
* @param string $template El nombre de la plantilla a utilizar
|
||||
*/
|
||||
public function setDataHeaderTemplate($template);
|
||||
|
||||
/**
|
||||
* Devolver la plantilla utilizada para la cabecera
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataHeaderTemplate();
|
||||
|
||||
/**
|
||||
* Establecer la plantilla utilizada para las acciones
|
||||
*
|
||||
* @param string $template El nombre de la plantilla a utilizar
|
||||
*/
|
||||
public function setDataActionsTemplate($template);
|
||||
|
||||
/**
|
||||
* Devolver la plantilla utilizada para las acciones
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataActionsTemplate();
|
||||
|
||||
/**
|
||||
* Establecer la plantilla utilizada para el paginador
|
||||
*
|
||||
* @param string $template El nombre de la plantilla a utilizar
|
||||
*/
|
||||
public function setDataPagerTemplate($template);
|
||||
|
||||
/**
|
||||
* Devolver la plantilla utilizada para el paginador
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataPagerTemplate();
|
||||
|
||||
/**
|
||||
* Establcer la plantilla utilizada para los datos de la consulta
|
||||
*
|
||||
* @param string $template El nombre de la plantilla a utilizar
|
||||
*/
|
||||
public function setDataRowTemplate($template);
|
||||
|
||||
/**
|
||||
* Devolver la plantilla utilizada para los datos de la consulta
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataRowTemplate();
|
||||
}
|
||||
36
inc/SP/Html/DataGrid/DataGridPager.class.php
Normal file
36
inc/SP/Html/DataGrid/DataGridPager.class.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\Html\DataGrid;
|
||||
|
||||
/**
|
||||
* Class DataGridPager
|
||||
*
|
||||
* @package SP\Html\DataGrid
|
||||
*/
|
||||
class DataGridPager extends DataGridPagerBase
|
||||
{
|
||||
|
||||
}
|
||||
263
inc/SP/Html/DataGrid/DataGridPagerBase.class.php
Normal file
263
inc/SP/Html/DataGrid/DataGridPagerBase.class.php
Normal file
@@ -0,0 +1,263 @@
|
||||
<?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\Html\DataGrid;
|
||||
|
||||
/**
|
||||
* Class DataGridPagerBase para implementar los métodos del paginador
|
||||
*
|
||||
* @package SP\Html\DataGrid
|
||||
*/
|
||||
abstract class DataGridPagerBase implements DataGridPagerInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $_searchKey = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $_limitStart = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $_limitCount = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $_totalRows = 0;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $_filterOn = false;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_onClickFunction = '';
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_onClickArgs = array();
|
||||
|
||||
|
||||
/**
|
||||
* Establecer el campo de la búsqueda
|
||||
*
|
||||
* @param int $searchKey
|
||||
*/
|
||||
public function setSearchKey($searchKey)
|
||||
{
|
||||
$this->_searchKey = $searchKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el campo de la búsqueda
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSearchKey()
|
||||
{
|
||||
return $this->_searchKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer el registro de inicio de la página
|
||||
*
|
||||
* @param int $limitStart
|
||||
*/
|
||||
public function setLimitStart($limitStart)
|
||||
{
|
||||
$this->_limitStart = $limitStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el registro de inicio de la página
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLimitStart()
|
||||
{
|
||||
return $this->_limitStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer el número de registros en una página
|
||||
*
|
||||
* @param int $limitCount
|
||||
*/
|
||||
public function setLimitCount($limitCount)
|
||||
{
|
||||
$this->_limitCount = $limitCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el número de registros en una página
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLimitCount()
|
||||
{
|
||||
return $this->_limitCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el número de página inicial
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFirstPage()
|
||||
{
|
||||
return ceil(($this->_limitStart + 1) / $this->_limitCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el número de página final
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLastPage()
|
||||
{
|
||||
return ceil($this->_totalRows / $this->_limitCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer el número total de registros obtenidos
|
||||
*
|
||||
* @param int $totalRows
|
||||
*/
|
||||
public function setTotalRows($totalRows)
|
||||
{
|
||||
$this->_totalRows = $totalRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el número total de registros obtenidos
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalRows()
|
||||
{
|
||||
return $this->_totalRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer si está activado el filtro
|
||||
*
|
||||
* @param bool $filterOn
|
||||
*/
|
||||
public function setFilterOn($filterOn)
|
||||
{
|
||||
$this->_filterOn = $filterOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver si está activado el filtro
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getFilterOn()
|
||||
{
|
||||
return $this->_filterOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer la función javascript para paginar
|
||||
*
|
||||
* @param string $function
|
||||
*/
|
||||
public function setOnClickFunction($function)
|
||||
{
|
||||
$this->_onClickFunction = $function;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver la función javascript para paginar
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOnClick()
|
||||
{
|
||||
$args = array();
|
||||
|
||||
foreach ($this->_onClickArgs as $arg) {
|
||||
$args[] = (!is_numeric($arg) && $arg !== 'this') ? '\'' . $arg . '\'' : $arg;
|
||||
}
|
||||
|
||||
return $this->_onClickFunction . '(' . implode(',', $args) . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer los argumentos de la función OnClick
|
||||
*
|
||||
* @param string $args
|
||||
*/
|
||||
public function setOnClickArgs($args)
|
||||
{
|
||||
$this->_onClickArgs[] = $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver la funcion para ir a la primera página
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOnClickFirst()
|
||||
{
|
||||
return $this->_onClickFunction . '(' . $this->_searchKey .', 0, 1)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver la funcion para ir a la última página
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOnClickLast()
|
||||
{
|
||||
$limitLast = (($this->_totalRows % $this->_limitCount) == 0) ? $this->_totalRows - $this->_limitCount : floor($this->_totalRows / $this->_limitCount) * $this->_limitCount;
|
||||
|
||||
return $this->_onClickFunction . '(' . $this->_searchKey . ',' . $limitLast . ',1)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver la funcion para ir a la siguiente página
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOnClickNext()
|
||||
{
|
||||
return $this->_onClickFunction . '(' . $this->_searchKey . ',' . ($this->_limitStart + $this->_limitCount) . ',1)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver la funcion para ir a la página anterior
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOnClickPrev()
|
||||
{
|
||||
return $this->_onClickFunction .'(' . $this->_searchKey . ',' . ($this->_limitStart - $this->_limitCount) . ',1)';
|
||||
}
|
||||
|
||||
}
|
||||
154
inc/SP/Html/DataGrid/DataGridPagerInterface.class.php
Normal file
154
inc/SP/Html/DataGrid/DataGridPagerInterface.class.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?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\Html\DataGrid;
|
||||
|
||||
/**
|
||||
* Interface DataGridPagerInterface para la definición del paginador
|
||||
*
|
||||
* @package SP\Html\DataGrid
|
||||
*/
|
||||
interface DataGridPagerInterface
|
||||
{
|
||||
/**
|
||||
* Establecer el campo de la búsqueda
|
||||
*
|
||||
* @param int $searchKey
|
||||
*/
|
||||
public function setSearchKey($searchKey);
|
||||
|
||||
/**
|
||||
* Devolver el campo de la búsqueda
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSearchKey();
|
||||
|
||||
/**
|
||||
* Establecer el registro de inicio de la página
|
||||
*
|
||||
* @param int $limitStart
|
||||
*/
|
||||
public function setLimitStart($limitStart);
|
||||
|
||||
/**
|
||||
* Devolver el registro de inicio de la página
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLimitStart();
|
||||
|
||||
/**
|
||||
* Establecer el número de registros en una página
|
||||
*
|
||||
* @param int $limitCount
|
||||
*/
|
||||
public function setLimitCount($limitCount);
|
||||
|
||||
/**
|
||||
* Devolver el número de registros en una página
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLimitCount();
|
||||
|
||||
/**
|
||||
* Establecer el número total de registros obtenidos
|
||||
*
|
||||
* @param int $totalRows
|
||||
*/
|
||||
public function setTotalRows($totalRows);
|
||||
|
||||
/**
|
||||
* Devolver el número total de registros obtenidos
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalRows();
|
||||
|
||||
/**
|
||||
* Establecer si está activado el filtro
|
||||
*
|
||||
* @param bool $filterOn
|
||||
*/
|
||||
public function setFilterOn($filterOn);
|
||||
|
||||
/**
|
||||
* Devolver si está activado el filtro
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getFilterOn();
|
||||
|
||||
/**
|
||||
* Establecer la función javascript para paginar
|
||||
*
|
||||
* @param string $function
|
||||
*/
|
||||
public function setOnClickFunction($function);
|
||||
|
||||
/**
|
||||
* Devolver la función javascript para paginar
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOnClick();
|
||||
|
||||
/**
|
||||
* Establecer los argumentos de la función OnClick
|
||||
*
|
||||
* @param string $args
|
||||
*/
|
||||
public function setOnClickArgs($args);
|
||||
|
||||
/**
|
||||
* Devolver la funcion para ir a la primera página
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOnClickFirst();
|
||||
|
||||
/**
|
||||
* Devolver la funcion para ir a la última página
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOnClickLast();
|
||||
|
||||
/**
|
||||
* Devolver la funcion para ir a la siguiente página
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOnClickNext();
|
||||
|
||||
/**
|
||||
* Devolver la funcion para ir a la página anterior
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOnClickPrev();
|
||||
|
||||
}
|
||||
@@ -40,8 +40,8 @@ class Html
|
||||
*/
|
||||
public static function sanitize(&$data)
|
||||
{
|
||||
if (!$data) {
|
||||
return false;
|
||||
if (empty($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
if (is_array($data)) {
|
||||
|
||||
@@ -36,20 +36,61 @@ use SP\Core\Init;
|
||||
*/
|
||||
class Request
|
||||
{
|
||||
/**
|
||||
* Comprobar el método utilizado para enviar un formulario.
|
||||
*
|
||||
* @param string $method con el método utilizado.
|
||||
*/
|
||||
public static function checkReferer($method)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] !== strtoupper($method)
|
||||
|| !isset($_SERVER['HTTP_REFERER'])
|
||||
|| !preg_match('#' . Init::$WEBROOT . '/.*$#', $_SERVER['HTTP_REFERER'])
|
||||
) {
|
||||
Init::initError(_('No es posible acceder directamente a este archivo'));
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar un valor encriptado y devolverlo desencriptado
|
||||
*
|
||||
* @param $param
|
||||
* @return string
|
||||
*/
|
||||
public static function analyzeEncrypted($param)
|
||||
{
|
||||
$encryptedData = self::analyze($param, '', false, false, false);
|
||||
|
||||
if ($encryptedData === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
try {
|
||||
// Desencriptar con la clave RSA
|
||||
$CryptPKI = new CryptPKI();
|
||||
$clearData = $CryptPKI->decryptRSA(base64_decode($encryptedData));
|
||||
} catch (\Exception $e) {
|
||||
return $encryptedData;
|
||||
}
|
||||
|
||||
return $clearData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los valores de variables $_GET y $_POST
|
||||
* y devolverlos limpios con el tipo correcto o esperado.
|
||||
*
|
||||
* @param string $param con el parámetro a consultar
|
||||
* @param mixed $default valor por defecto a devolver
|
||||
* @param bool $check comprobar si el parámetro está presente
|
||||
* @param mixed $force valor devuelto si el parámeto está definido
|
||||
* @param bool $sanitize escapar/eliminar carácteres especiales
|
||||
* @param string $param con el parámetro a consultar
|
||||
* @param mixed $default valor por defecto a devolver
|
||||
* @param bool $check comprobar si el parámetro está presente
|
||||
* @param mixed $force valor devuelto si el parámeto está definido
|
||||
* @param bool $sanitize escapar/eliminar carácteres especiales
|
||||
* @return mixed si está presente el parámeto en la petición devuelve bool. Si lo está, devuelve el valor.
|
||||
*/
|
||||
public static function analyze($param, $default = '', $check = false, $force = false, $sanitize = true)
|
||||
{
|
||||
switch($_SERVER['REQUEST_METHOD']){
|
||||
switch ($_SERVER['REQUEST_METHOD']) {
|
||||
case 'GET':
|
||||
if (!isset($_GET[$param])) {
|
||||
return ($force) ? !$force : $default;
|
||||
@@ -83,62 +124,33 @@ class Request
|
||||
*/
|
||||
private static function parse($value, $default, $sanitize)
|
||||
{
|
||||
if (is_array($value)){
|
||||
foreach($value as &$data){
|
||||
if (is_array($value)) {
|
||||
foreach ($value as &$data) {
|
||||
self::parse($data, $default, $sanitize);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
if ((is_numeric($value) && !is_string($default)) || is_numeric($default)) {
|
||||
if ((is_numeric($value) || is_numeric($default))
|
||||
&& !is_string($default)
|
||||
) {
|
||||
return intval($value);
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
return ($sanitize === true) ? Html::sanitize($value) : $value;
|
||||
return ($sanitize === true) ? Html::sanitize($value) : (string)$value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar el método utilizado para enviar un formulario.
|
||||
* Comprobar si se realiza una recarga de la página
|
||||
*
|
||||
* @param string $method con el método utilizado.
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkReferer($method)
|
||||
public static function checkReload()
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] !== strtoupper($method)
|
||||
|| !isset($_SERVER['HTTP_REFERER'])
|
||||
|| !preg_match('#' . Init::$WEBROOT . '/.*$#', $_SERVER['HTTP_REFERER'])
|
||||
) {
|
||||
Init::initError(_('No es posible acceder directamente a este archivo'));
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizar un valor encriptado y devolverlo desencriptado
|
||||
*
|
||||
* @param $param
|
||||
* @return string
|
||||
*/
|
||||
public static function analyzeEncrypted($param)
|
||||
{
|
||||
$encryptedData = self::analyze($param, '', false, false, false);
|
||||
|
||||
if ($encryptedData === ''){
|
||||
return '';
|
||||
}
|
||||
|
||||
try {
|
||||
// Desencriptar con la clave RSA
|
||||
$CryptPKI = new CryptPKI();
|
||||
$clearData = $CryptPKI->decryptRSA(base64_decode($encryptedData));
|
||||
} catch (\Exception $e) {
|
||||
return $encryptedData;
|
||||
}
|
||||
|
||||
return $clearData;
|
||||
return (self::getRequestHeaders('Cache-Control') == 'max-age=0');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,16 +186,6 @@ class Request
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si se realiza una recarga de la página
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkReload()
|
||||
{
|
||||
return (self::getRequestHeaders('Cache-Control') == 'max-age=0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si existen parámetros pasados por POST para enviarlos por GET
|
||||
*/
|
||||
|
||||
@@ -44,85 +44,6 @@ class Category
|
||||
public static $categoryDescription;
|
||||
public static $categoryLastId;
|
||||
|
||||
/**
|
||||
* Obtener el id de una categoría por el nombre.
|
||||
*
|
||||
* @param string $categoryName con el nombre de la categoría
|
||||
* @return bool|int si la consulta es errónea devuelve bool. Si no hay registros o se obtiene el id, devuelve int
|
||||
*/
|
||||
public static function getCategoryIdByName($categoryName)
|
||||
{
|
||||
$query = 'SELECT category_id FROM categories WHERE category_name = :name LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($categoryName, 'name');
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false || DB::$lastNumRows === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $queryRes->category_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear una nueva categoría en la BBDD.
|
||||
*
|
||||
* @throws SPException
|
||||
*/
|
||||
public static function addCategory()
|
||||
{
|
||||
if (self::checkDupCategory()){
|
||||
throw new SPException(SPException::SP_WARNING, _('Nombre de categoría duplicado'));
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO categories SET category_name = :name ,category_description = :description';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(self::$categoryName, 'name');
|
||||
$Data->addParam(self::$categoryDescription, 'description');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error al crear la categoría'));
|
||||
}
|
||||
|
||||
self::$categoryLastId = DB::$lastId;
|
||||
|
||||
$Log = new Log(_('Nueva Categoría'));
|
||||
$Log->addDetails(Html::strongText(_('Categoría')), self::$categoryName);
|
||||
$Log->writeLog();
|
||||
|
||||
Email::sendEmail($Log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si existe una categoría duplicada.
|
||||
*
|
||||
* @param int $id con el Id de la categoría a consultar
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkDupCategory($id = null)
|
||||
{
|
||||
|
||||
$Data = new QueryData();
|
||||
|
||||
if (is_null($id)) {
|
||||
$query = 'SELECT category_id FROM categories WHERE category_name = :name';
|
||||
} else {
|
||||
$query = 'SELECT category_id FROM categories WHERE category_name = :name AND category_id <> :id';
|
||||
|
||||
$Data->addParam($id, 'id');
|
||||
}
|
||||
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(self::$categoryName, 'name');
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminar una categoría de la BBDD.
|
||||
*
|
||||
@@ -156,6 +77,48 @@ class Category
|
||||
Email::sendEmail($Log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si una categoría está en uso por cuentas.
|
||||
*
|
||||
* @param int $id con el Id de la categoría a consultar
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function checkCategoryInUse($id)
|
||||
{
|
||||
$numAccounts = self::getCategoriesInAccounts($id);
|
||||
|
||||
$out = '';
|
||||
|
||||
if ($numAccounts) {
|
||||
$out[] = _('Cuentas') . " (" . $numAccounts . ")";
|
||||
}
|
||||
|
||||
if (is_array($out)) {
|
||||
return implode('<br>', $out);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el número de cuentas que usan una categoría.
|
||||
*
|
||||
* @param int $id con el Id de la categoría a consultar
|
||||
* @return false|integer con el número total de cuentas
|
||||
*/
|
||||
private static function getCategoriesInAccounts($id)
|
||||
{
|
||||
$query = 'SELECT account_id FROM accounts WHERE account_categoryId = :id';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id, 'id');
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return DB::$lastNumRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el nombre de la categoría a partir del Id.
|
||||
*
|
||||
@@ -187,7 +150,7 @@ class Category
|
||||
*/
|
||||
public static function updateCategory($id)
|
||||
{
|
||||
if (self::checkDupCategory($id)){
|
||||
if (self::checkDupCategory($id)) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Nombre de categoría duplicado'));
|
||||
}
|
||||
|
||||
@@ -214,6 +177,31 @@ class Category
|
||||
Email::sendEmail($Log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si existe una categoría duplicada.
|
||||
*
|
||||
* @param int $id con el Id de la categoría a consultar
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkDupCategory($id = null)
|
||||
{
|
||||
|
||||
$Data = new QueryData();
|
||||
|
||||
if (is_null($id)) {
|
||||
$query = 'SELECT category_id FROM categories WHERE category_name = :name';
|
||||
} else {
|
||||
$query = 'SELECT category_id FROM categories WHERE category_name = :name AND category_id <> :id';
|
||||
|
||||
$Data->addParam($id, 'id');
|
||||
}
|
||||
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(self::$categoryName, 'name');
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos de una categoría.
|
||||
*
|
||||
@@ -284,56 +272,15 @@ class Category
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si una categoría está en uso por cuentas.
|
||||
*
|
||||
* @param int $id con el Id de la categoría a consultar
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function checkCategoryInUse($id)
|
||||
{
|
||||
$numAccounts = self::getCategoriesInAccounts($id);
|
||||
|
||||
$out = '';
|
||||
|
||||
if ($numAccounts) {
|
||||
$out[] = _('Cuentas') . " (" . $numAccounts . ")";
|
||||
}
|
||||
|
||||
if (is_array($out)) {
|
||||
return implode('<br>', $out);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el número de cuentas que usan una categoría.
|
||||
*
|
||||
* @param int $id con el Id de la categoría a consultar
|
||||
* @return false|integer con el número total de cuentas
|
||||
*/
|
||||
private static function getCategoriesInAccounts($id)
|
||||
{
|
||||
$query = 'SELECT account_id FROM accounts WHERE account_categoryId = :id';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id, 'id');
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return DB::$lastNumRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear una categoría y devolver el id si existe o de la nueva
|
||||
*
|
||||
* @param $name string El nombre de la categoría
|
||||
* @param $name string El nombre de la categoría
|
||||
* @param $description string La descripción de la categoría
|
||||
* @return int
|
||||
*/
|
||||
public static function addCategoryReturnId($name, $description = ''){
|
||||
public static function addCategoryReturnId($name, $description = '')
|
||||
{
|
||||
// Comprobamos si existe la categoría o la creamos
|
||||
$newCategoryId = self::getCategoryIdByName($name);
|
||||
|
||||
@@ -344,10 +291,96 @@ class Category
|
||||
try {
|
||||
self::addCategory();
|
||||
$newCategoryId = self::$categoryLastId;
|
||||
} catch (SPException $e){
|
||||
} catch (SPException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
return (int)$newCategoryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el id de una categoría por el nombre.
|
||||
*
|
||||
* @param string $categoryName con el nombre de la categoría
|
||||
* @return bool|int si la consulta es errónea devuelve bool. Si no hay registros o se obtiene el id, devuelve int
|
||||
*/
|
||||
public static function getCategoryIdByName($categoryName)
|
||||
{
|
||||
$query = 'SELECT category_id FROM categories WHERE category_name = :name LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($categoryName, 'name');
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false || DB::$lastNumRows === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $queryRes->category_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear una nueva categoría en la BBDD.
|
||||
*
|
||||
* @throws SPException
|
||||
*/
|
||||
public static function addCategory()
|
||||
{
|
||||
if (self::checkDupCategory()) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Nombre de categoría duplicado'));
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO categories SET category_name = :name ,category_description = :description';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(self::$categoryName, 'name');
|
||||
$Data->addParam(self::$categoryDescription, 'description');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error al crear la categoría'));
|
||||
}
|
||||
|
||||
self::$categoryLastId = DB::$lastId;
|
||||
|
||||
$Log = new Log(_('Nueva Categoría'));
|
||||
$Log->addDetails(Html::strongText(_('Categoría')), self::$categoryName);
|
||||
$Log->writeLog();
|
||||
|
||||
Email::sendEmail($Log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el listado de categorías mediante una búsqueda
|
||||
*
|
||||
* @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($search)
|
||||
{
|
||||
$query = 'SELECT category_id, category_name,category_description '
|
||||
. 'FROM categories '
|
||||
. 'WHERE category_name LIKE ? '
|
||||
. 'OR category_description LIKE ? '
|
||||
. 'ORDER BY category_name';
|
||||
|
||||
$search = '%' . $search . '%';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($search);
|
||||
$Data->addParam($search);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,107 @@ class CustomFieldDef extends CustomFieldsBase
|
||||
return $queryRes && CustomFields::deleteCustomFieldForDefinition($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver los datos de definiciones de campos personalizados
|
||||
*
|
||||
* @param string $search La cadena de búsqueda
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function getCustomFieldsSearch($search)
|
||||
{
|
||||
$query = 'SELECT customfielddef_id, customfielddef_module, customfielddef_field '
|
||||
. 'FROM customFieldsDef '
|
||||
. ' ORDER BY customfielddef_module';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$customFields = array();
|
||||
|
||||
foreach ($queryRes as $customField) {
|
||||
/**
|
||||
* @var CustomFieldDef
|
||||
*/
|
||||
$field = unserialize($customField->customfielddef_field);
|
||||
|
||||
if (get_class($field) === '__PHP_Incomplete_Class') {
|
||||
$field = Util::castToClass('SP\Mgmt\CustomFieldDef', $field);
|
||||
}
|
||||
|
||||
if (stripos($field->getName(), $search) !== false
|
||||
|| stripos(self::getFieldsTypes($field->getType(), true), $search) !== false
|
||||
|| stripos(self::getFieldsModules($customField->customfielddef_module), $search) !== false
|
||||
) {
|
||||
$attribs = new \stdClass();
|
||||
$attribs->id = $customField->customfielddef_id;
|
||||
$attribs->module = self::getFieldsModules($customField->customfielddef_module);
|
||||
$attribs->name = $field->getName();
|
||||
$attribs->typeName = self::getFieldsTypes($field->getType(), true);
|
||||
$attribs->type = $field->getType();
|
||||
|
||||
$customFields[] = $attribs;
|
||||
}
|
||||
}
|
||||
|
||||
return $customFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Añadir nuevo campo personalizado
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function addCustomField()
|
||||
{
|
||||
$query = 'INSERT INTO customFieldsDef SET customfielddef_module = :module, customfielddef_field = :field';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->_module, 'module');
|
||||
$Data->addParam(serialize($this), 'field');
|
||||
|
||||
$queryRes = DB::getQuery($Data);
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar campo personalizado
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function updateCustomField()
|
||||
{
|
||||
$curField = self::getCustomFields($this->_id, true);
|
||||
|
||||
$query = 'UPDATE customFieldsDef SET ' .
|
||||
'customfielddef_module = :module, ' .
|
||||
'customfielddef_field = :field ' .
|
||||
'WHERE customfielddef_id= :id LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->_id, 'id');
|
||||
$Data->addParam($this->_module, 'module');
|
||||
$Data->addParam(serialize($this), 'field');
|
||||
|
||||
$queryRes = DB::getQuery($Data);
|
||||
|
||||
if ($queryRes && $curField->customfielddef_module !== $this->_module) {
|
||||
$queryRes = CustomFields::updateCustomFieldModule($this->_module, $this->_id);
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver los datos de definiciones de campos personalizados
|
||||
*
|
||||
@@ -134,54 +235,6 @@ class CustomFieldDef extends CustomFieldsBase
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Añadir nuevo campo personalizado
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function addCustomField()
|
||||
{
|
||||
$query = 'INSERT INTO customFieldsDef SET customfielddef_module = :module, customfielddef_field = :field';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->_module, 'module');
|
||||
$Data->addParam(serialize($this), 'field');
|
||||
|
||||
$queryRes = DB::getQuery($Data);
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar campo personalizado
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function updateCustomField()
|
||||
{
|
||||
$curField = self::getCustomFields($this->_id, true);
|
||||
|
||||
$query = 'UPDATE customFieldsDef SET ' .
|
||||
'customfielddef_module = :module, ' .
|
||||
'customfielddef_field = :field ' .
|
||||
'WHERE customfielddef_id= :id LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->_id, 'id');
|
||||
$Data->addParam($this->_module, 'module');
|
||||
$Data->addParam(serialize($this), 'field');
|
||||
|
||||
$queryRes = DB::getQuery($Data);
|
||||
|
||||
if ($queryRes && $curField->customfielddef_module !== $this->_module) {
|
||||
$queryRes = CustomFields::updateCustomFieldModule($this->_module, $this->_id);
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
|
||||
@@ -126,6 +126,8 @@ class CustomFields extends CustomFieldsBase
|
||||
$customFields[] = $attribs;
|
||||
}
|
||||
|
||||
$customFields['hash'] = '';
|
||||
|
||||
return $customFields;
|
||||
}
|
||||
|
||||
@@ -170,6 +172,7 @@ class CustomFields extends CustomFieldsBase
|
||||
$queryMerge = array_merge($queryRes, self::getCustomFieldsNoData($moduleId, $itemId));
|
||||
|
||||
$customFields = array();
|
||||
$customFieldsHash = '';
|
||||
|
||||
foreach ($queryMerge as $customField) {
|
||||
/**
|
||||
@@ -191,9 +194,13 @@ class CustomFields extends CustomFieldsBase
|
||||
$attribs->help = $field->getHelp();
|
||||
$attribs->required = $field->isRequired();
|
||||
|
||||
$customFieldsHash .= $attribs->value;
|
||||
|
||||
$customFields[] = $attribs;
|
||||
}
|
||||
|
||||
$customFields['hash'] = md5($customFieldsHash);
|
||||
|
||||
return $customFields;
|
||||
}
|
||||
|
||||
@@ -488,6 +495,7 @@ class CustomFields extends CustomFieldsBase
|
||||
* Eliminar los datos de un campo personalizado o los de una definición de campos
|
||||
*
|
||||
* @param int $itemId El Id del elemento asociado al campo
|
||||
* @param $moduleId
|
||||
* @return bool
|
||||
*/
|
||||
public static function deleteCustomFieldForItem($itemId, $moduleId)
|
||||
|
||||
63
inc/SP/Mgmt/CustomFieldsUtil.class.php
Normal file
63
inc/SP/Mgmt/CustomFieldsUtil.class.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Class CustomFieldsUtil utilidades para los campos personalizados
|
||||
*
|
||||
* @package SP\Mgmt
|
||||
*/
|
||||
class CustomFieldsUtil
|
||||
{
|
||||
public static function updateCustonFields(array &$fields, $accountId)
|
||||
{
|
||||
foreach ($fields as $id => $value) {
|
||||
$CustomFields = new CustomFields($id, $accountId, $value);
|
||||
$CustomFields->updateCustomField();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function checkHash(&$fields, $srcHhash)
|
||||
{
|
||||
if (!is_array($fields)){
|
||||
return true;
|
||||
}
|
||||
|
||||
$hash = '';
|
||||
|
||||
foreach ($fields as $value) {
|
||||
$hash .= $value;
|
||||
}
|
||||
|
||||
if (!empty($hash)) {
|
||||
return ($srcHhash == md5($hash));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -46,60 +46,6 @@ class Customer
|
||||
public static $customerLastId;
|
||||
public static $customerHash;
|
||||
|
||||
/**
|
||||
* Crear un nuevo cliente en la BBDD.
|
||||
*
|
||||
* @param null $id El Id del cliente actual (solo para comprobar duplicidad)
|
||||
* @throws SPException
|
||||
*/
|
||||
public static function addCustomer($id = null)
|
||||
{
|
||||
if(self::checkDupCustomer($id)){
|
||||
throw new SPException(SPException::SP_WARNING, _('Cliente duplicado'));
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO customers ' .
|
||||
'SET customer_name = :name,'.
|
||||
'customer_description = :description,' .
|
||||
'customer_hash = :hash';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(self::$customerName, 'name');
|
||||
$Data->addParam(self::$customerDescription, 'description');
|
||||
$Data->addParam(self::mkCustomerHash(), 'hash');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error al crear el cliente'));
|
||||
}
|
||||
|
||||
self::$customerLastId = DB::$lastId;
|
||||
|
||||
$Log = new Log(_('Nuevo Cliente'));
|
||||
$Log->addDetails(Html::strongText(_('Cliente')), self::$customerName);
|
||||
$Log->writeLog();
|
||||
|
||||
Email::sendEmail($Log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear un hash con el nombre del cliente.
|
||||
* Esta función crear un hash para detectar clientes duplicados mediante
|
||||
* la eliminación de carácteres especiales y capitalización
|
||||
*
|
||||
* @return string con el hash generado
|
||||
*/
|
||||
private static function mkCustomerHash()
|
||||
{
|
||||
$charsSrc = array(
|
||||
".", " ", "_", ", ", "-", ";",
|
||||
"'", "\"", ":", "(", ")", "|", "/");
|
||||
$newValue = strtolower(str_replace($charsSrc, '', DBUtil::escape(self::$customerName)));
|
||||
$hashValue = md5($newValue);
|
||||
|
||||
return $hashValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar un cliente en la BBDD.
|
||||
*
|
||||
@@ -108,7 +54,7 @@ class Customer
|
||||
*/
|
||||
public static function updateCustomer($id)
|
||||
{
|
||||
if(self::checkDupCustomer($id)){
|
||||
if (self::checkDupCustomer($id)) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Cliente duplicado'));
|
||||
}
|
||||
|
||||
@@ -138,6 +84,49 @@ class Customer
|
||||
Email::sendEmail($Log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si existe un cliente duplicado comprobando el hash.
|
||||
*
|
||||
* @param int $id opcional con el Id del cliente
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkDupCustomer($id = null)
|
||||
{
|
||||
$Data = new QueryData();
|
||||
$Data->addParam($id, 'id');
|
||||
|
||||
if (is_null($id)) {
|
||||
$query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash';
|
||||
} else {
|
||||
$query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash AND customer_id <> :id';
|
||||
|
||||
$Data->addParam($id, 'id');
|
||||
}
|
||||
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(self::mkCustomerHash(), 'hash');
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear un hash con el nombre del cliente.
|
||||
* Esta función crear un hash para detectar clientes duplicados mediante
|
||||
* la eliminación de carácteres especiales y capitalización
|
||||
*
|
||||
* @return string con el hash generado
|
||||
*/
|
||||
private static function mkCustomerHash()
|
||||
{
|
||||
$charsSrc = array(
|
||||
".", " ", "_", ", ", "-", ";",
|
||||
"'", "\"", ":", "(", ")", "|", "/");
|
||||
$newValue = strtolower(str_replace($charsSrc, '', DBUtil::escape(self::$customerName)));
|
||||
$hashValue = md5($newValue);
|
||||
|
||||
return $hashValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el Nombre de un cliente por su Id.
|
||||
*
|
||||
@@ -195,50 +184,35 @@ class Customer
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si existe un cliente duplicado comprobando el hash.
|
||||
* Comprobar si un cliente está en uso.
|
||||
* Esta función comprueba si un cliente está en uso por cuentas.
|
||||
*
|
||||
* @param int $id opcional con el Id del cliente
|
||||
* @return bool
|
||||
* @param int $id con el Id del cliente a consultar
|
||||
* @return int Con el número de cuentas
|
||||
*/
|
||||
public static function checkDupCustomer($id = null)
|
||||
public static function checkCustomerInUse($id)
|
||||
{
|
||||
$Data = new QueryData();
|
||||
$Data->addParam($id, 'id');
|
||||
|
||||
if (is_null($id)) {
|
||||
$query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash';
|
||||
} else {
|
||||
$query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash AND customer_id <> :id';
|
||||
|
||||
$Data->addParam($id, 'id');
|
||||
}
|
||||
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(self::mkCustomerHash(), 'hash');
|
||||
|
||||
return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
|
||||
$count['accounts'] = self::getCustomerInAccounts($id);
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el Id de un cliente por su nombre
|
||||
* Obtener el número de cuentas que usan un cliente.
|
||||
*
|
||||
* @return false|int Con el Id del cliente
|
||||
* @param int $id con el Id del cliente a consultar
|
||||
* @return int con el número total de cuentas
|
||||
*/
|
||||
public static function getCustomerByName()
|
||||
private static function getCustomerInAccounts($id)
|
||||
{
|
||||
$query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash LIMIT 1';
|
||||
$query = 'SELECT account_id FROM accounts WHERE account_customerId = :id';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(self::mkCustomerHash(), 'hash');
|
||||
$Data->addParam($id, 'id');
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
DB::getQuery($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $queryRes->customer_id;
|
||||
return DB::$lastNumRows;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -311,45 +285,15 @@ class Customer
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si un cliente está en uso.
|
||||
* Esta función comprueba si un cliente está en uso por cuentas.
|
||||
*
|
||||
* @param int $id con el Id del cliente a consultar
|
||||
* @return int Con el número de cuentas
|
||||
*/
|
||||
public static function checkCustomerInUse($id)
|
||||
{
|
||||
$count['accounts'] = self::getCustomerInAccounts($id);
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el número de cuentas que usan un cliente.
|
||||
*
|
||||
* @param int $id con el Id del cliente a consultar
|
||||
* @return int con el número total de cuentas
|
||||
*/
|
||||
private static function getCustomerInAccounts($id)
|
||||
{
|
||||
$query = 'SELECT account_id FROM accounts WHERE account_customerId = :id';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id, 'id');
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return DB::$lastNumRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Añadir un cliente
|
||||
*
|
||||
* @param $name
|
||||
* @param $description
|
||||
* @return int
|
||||
*/
|
||||
public static function addCustomerReturnId($name, $description = ''){
|
||||
public static function addCustomerReturnId($name, $description = '')
|
||||
{
|
||||
$customerId = 0;
|
||||
|
||||
self::$customerName = $name;
|
||||
@@ -359,11 +303,101 @@ class Customer
|
||||
self::addCustomer();
|
||||
$customerId = self::$customerLastId;
|
||||
} catch (SPException $e) {
|
||||
if ($e->getType() === SPException::SP_WARNING){
|
||||
if ($e->getType() === SPException::SP_WARNING) {
|
||||
$customerId = self::getCustomerByName();
|
||||
}
|
||||
}
|
||||
|
||||
return (int)$customerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear un nuevo cliente en la BBDD.
|
||||
*
|
||||
* @param null $id El Id del cliente actual (solo para comprobar duplicidad)
|
||||
* @throws SPException
|
||||
*/
|
||||
public static function addCustomer($id = null)
|
||||
{
|
||||
if (self::checkDupCustomer($id)) {
|
||||
throw new SPException(SPException::SP_WARNING, _('Cliente duplicado'));
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO customers ' .
|
||||
'SET customer_name = :name,' .
|
||||
'customer_description = :description,' .
|
||||
'customer_hash = :hash';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(self::$customerName, 'name');
|
||||
$Data->addParam(self::$customerDescription, 'description');
|
||||
$Data->addParam(self::mkCustomerHash(), 'hash');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('Error al crear el cliente'));
|
||||
}
|
||||
|
||||
self::$customerLastId = DB::$lastId;
|
||||
|
||||
$Log = new Log(_('Nuevo Cliente'));
|
||||
$Log->addDetails(Html::strongText(_('Cliente')), self::$customerName);
|
||||
$Log->writeLog();
|
||||
|
||||
Email::sendEmail($Log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el Id de un cliente por su nombre
|
||||
*
|
||||
* @return false|int Con el Id del cliente
|
||||
*/
|
||||
public static function getCustomerByName()
|
||||
{
|
||||
$query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(self::mkCustomerHash(), 'hash');
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $queryRes->customer_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el listado de clientes mediante una búsqueda
|
||||
*
|
||||
* @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($search)
|
||||
{
|
||||
$query = 'SELECT customer_id, customer_name, customer_description '
|
||||
. 'FROM customers '
|
||||
. 'WHERE customer_name LIKE ? '
|
||||
. 'OR customer_description LIKE ? '
|
||||
. 'ORDER BY customer_name';
|
||||
|
||||
$search = '%' . $search . '%';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($search);
|
||||
$Data->addParam($search);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,4 +287,47 @@ class Files
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el listado de archivos
|
||||
*
|
||||
* @param string $search La cadena de búsqueda
|
||||
* @return array|false Con los archivos de las cuentas.
|
||||
*/
|
||||
public static function getFileListSearch($search)
|
||||
{
|
||||
$query = 'SELECT accfile_id,'
|
||||
. 'accfile_name,'
|
||||
. 'CONCAT(ROUND(accfile_size/1000, 2), " KB") AS accfile_size,'
|
||||
. 'accfile_thumb,'
|
||||
. 'accfile_type,'
|
||||
. 'account_name,'
|
||||
. 'customer_name '
|
||||
. 'FROM accFiles '
|
||||
. 'JOIN accounts ON account_id = accfile_accountId '
|
||||
. 'JOIN customers ON customer_id = account_customerId '
|
||||
. 'WHERE accfile_name LIKE ? '
|
||||
. 'OR accfile_type LIKE ? '
|
||||
. 'OR account_name LIKE ? '
|
||||
. 'OR customer_name LIKE ?';
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$search = '%' . $search . '%';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($search);
|
||||
$Data->addParam($search);
|
||||
$Data->addParam($search);
|
||||
$Data->addParam($search);
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,11 @@ class QueryData
|
||||
*/
|
||||
public function addParam($value, $name = null)
|
||||
{
|
||||
$this->_data[$name] = $value;
|
||||
if (!is_null($name)) {
|
||||
$this->_data[$name] = $value;
|
||||
} else {
|
||||
$this->_data[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,204 +1,228 @@
|
||||
<div id="title" class="midroundup titleNormal">
|
||||
<?php use SP\Util\Checks;echo $title['name']; ?>
|
||||
<?php use SP\Util\Checks;
|
||||
|
||||
echo $title['name']; ?>
|
||||
<?php if ($gotData && $accountIsHistory): ?>
|
||||
<i id="history-icon" class="material-icons" title="<?php echo _('Histórico'); ?>"><?php echo $title['icon']; ?></i>
|
||||
<i id="history-icon" class="material-icons"
|
||||
title="<?php echo _('Histórico'); ?>"><?php echo $title['icon']; ?></i>
|
||||
<?php else: ?>
|
||||
<i id="history-icon" class="material-icons"><?php echo $title['icon']; ?></i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($showform): ?>
|
||||
<form method="post" name="frmaccount" id="frmAccount" onsubmit="sysPassUtil.Common.saveAccount('frmAccount'); return false;">
|
||||
<form method="post" name="frmaccount" id="frmAccount"
|
||||
onsubmit="sysPassUtil.Common.saveAccount('frmAccount'); return false;">
|
||||
<input type="hidden" name="hashcf" value="<?php echo $customFields['hash']; ?>"/>
|
||||
<input type="hidden" name="hash" value="<?php echo $changesHash; ?>">
|
||||
<input type="hidden" name="next" value="<?php echo $nextaction; ?>">
|
||||
<input type="hidden" name="actionId" value="<?php echo $actionId; ?>">
|
||||
<?php if ($gotData): ?>
|
||||
<input type="hidden" name="accountid" value="<?php echo $accountId; ?>"/>
|
||||
<?php endif; ?>
|
||||
<table class="data round">
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Nombre'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="name" name="name" type="text" required class="mdl-textfield__input fg-blue100"
|
||||
maxlength="50" value="<?php echo ($gotData) ? $accountData->account_name : ''; ?>">
|
||||
<label class="mdl-textfield__label" for="name"><?php echo _('Nombre de cuenta'); ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php echo $accountData->account_name; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Cliente'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<select id="selCustomer" name="customerId" class="select-box sel-chosen-customer" required>
|
||||
<option value=""></option>
|
||||
<?php foreach ($customers as $id => $name): ?>
|
||||
<option
|
||||
value="<?php echo $id; ?>" <?php echo ($gotData && $id == $accountData->account_customerId) ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<br><br>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="customer_new" name="customer_new" type="text" class="mdl-textfield__input fg-blue100" maxlength="50">
|
||||
<label class="mdl-textfield__label" for="name"><?php echo _('Seleccionar o escribir para crear uno nuevo'); ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php echo $accountData->customer_name; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Categoría'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<select id="selCategory" name="categoryId" class="select-box sel-chosen-category" required>
|
||||
<option value=""></option>
|
||||
<?php foreach ($categories as $id => $name): ?>
|
||||
<option
|
||||
value="<?php echo $id; ?>" <?php echo ($gotData && $id == $accountData->account_categoryId) ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php if(\SP\Core\Acl::checkUserAccess(\SP\Core\ActionsInterface::ACTION_MGM_CATEGORIES)): ?>
|
||||
<i class="material-icons" title="<?php echo _('Nueva Categoría'); ?>" onclick="sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_MGM; ?>,<?php echo $actionId; ?>, 0)">add</i>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<?php echo $accountData->category_name; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('URL / IP'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="url" name="url" type="text" class="mdl-textfield__input fg-blue100"
|
||||
maxlength="255" value="<?php echo ($gotData) ? $accountData->account_url : ''; ?>">
|
||||
<label class="mdl-textfield__label" for="name"><?php echo _('URL o IP de acceso'); ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php echo $accountData->account_url; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Usuario'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="login" name="login" type="text" required class="mdl-textfield__input fg-blue100"
|
||||
maxlength="50" value="<?php echo ($gotData) ? $accountData->account_login : ''; ?>">
|
||||
<label class="mdl-textfield__label" for="name"><?php echo _('Usuario de acceso'); ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php echo $accountData->account_login; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($showPass): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Clave'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="accountpass" name="pass" type="password" required class="mdl-textfield__input fg-blue100 passwordfield__input" maxlength="255"
|
||||
autocomplete="off">
|
||||
<label class="mdl-textfield__label" for="accountpass"><?php echo _('Clave'); ?></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Clave (repetir)'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="accountpassR" name="passR" type="password" required class="mdl-textfield__input fg-blue100"
|
||||
maxlength="255" autocomplete="off">
|
||||
<label class="mdl-textfield__label" for="accountpassR"><?php echo _('Clave (Repetir)'); ?></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Notas'); ?></td>
|
||||
<td class="valField">
|
||||
<input type="hidden" name="sk" value="<?php echo $sk; ?>">
|
||||
<input type="hidden" name="isAjax" value="1">
|
||||
|
||||
<?php endif; ?>
|
||||
<table class="data round">
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Nombre'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<textarea class="mdl-textfield__input fg-blue100" rows= "3" id="notes" name="notes" maxlength="1000"><?php echo ($gotData) ? $accountData->account_notes : ''; ?></textarea>
|
||||
<label class="mdl-textfield__label" for="notes"><?php echo _('Notas sobre la cuenta'); ?></label>
|
||||
<input id="name" name="name" type="text" required class="mdl-textfield__input fg-blue100"
|
||||
maxlength="50" value="<?php echo ($gotData) ? $accountData->account_name : ''; ?>">
|
||||
<label class="mdl-textfield__label" for="name"><?php echo _('Nombre de cuenta'); ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php echo $accountData->account_name; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Cliente'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<select id="selCustomer" name="customerId" class="select-box sel-chosen-customer" required>
|
||||
<option value=""></option>
|
||||
<?php foreach ($customers as $id => $name): ?>
|
||||
<option
|
||||
value="<?php echo $id; ?>" <?php echo ($gotData && $id == $accountData->account_customerId) ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<br><br>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="customer_new" name="customer_new" type="text" class="mdl-textfield__input fg-blue100"
|
||||
maxlength="50">
|
||||
<label class="mdl-textfield__label"
|
||||
for="name"><?php echo _('Seleccionar o escribir para crear uno nuevo'); ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php echo $accountData->customer_name; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Categoría'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<select id="selCategory" name="categoryId" class="select-box sel-chosen-category" required>
|
||||
<option value=""></option>
|
||||
<?php foreach ($categories as $id => $name): ?>
|
||||
<option
|
||||
value="<?php echo $id; ?>" <?php echo ($gotData && $id == $accountData->account_categoryId) ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php if (\SP\Core\Acl::checkUserAccess(\SP\Core\ActionsInterface::ACTION_MGM_CATEGORIES)): ?>
|
||||
<i class="material-icons" title="<?php echo _('Nueva Categoría'); ?>"
|
||||
onclick="sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_MGM; ?>,<?php echo $actionId; ?>, 0)">add</i>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<?php echo $accountData->category_name; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('URL / IP'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="url" name="url" type="text" class="mdl-textfield__input fg-blue100"
|
||||
maxlength="255" value="<?php echo ($gotData) ? $accountData->account_url : ''; ?>">
|
||||
<label class="mdl-textfield__label" for="name"><?php echo _('URL o IP de acceso'); ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php echo $accountData->account_url; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Usuario'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="login" name="login" type="text" required class="mdl-textfield__input fg-blue100"
|
||||
maxlength="50" value="<?php echo ($gotData) ? $accountData->account_login : ''; ?>">
|
||||
<label class="mdl-textfield__label" for="name"><?php echo _('Usuario de acceso'); ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php echo $accountData->account_login; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($showPass): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Clave'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="accountpass" name="pass" type="password" required
|
||||
class="mdl-textfield__input fg-blue100 passwordfield__input" maxlength="255"
|
||||
autocomplete="off">
|
||||
<label class="mdl-textfield__label" for="accountpass"><?php echo _('Clave'); ?></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Clave (repetir)'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="accountpassR" name="passR" type="password" required
|
||||
class="mdl-textfield__input fg-blue100"
|
||||
maxlength="255" autocomplete="off">
|
||||
<label class="mdl-textfield__label"
|
||||
for="accountpassR"><?php echo _('Clave (Repetir)'); ?></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Notas'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<textarea class="mdl-textfield__input fg-blue100" rows="3" id="notes" name="notes"
|
||||
maxlength="1000"><?php echo ($gotData) ? $accountData->account_notes : ''; ?></textarea>
|
||||
<label class="mdl-textfield__label"
|
||||
for="notes"><?php echo _('Notas sobre la cuenta'); ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php echo $accountData->account_notes; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</tr>
|
||||
<?php if ($showform): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Permisos'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="account-permissions">
|
||||
<fieldset class="round5">
|
||||
<legend><?php echo _('Usuarios'); ?></legend>
|
||||
<select id="selUsers" name="otherusers[]" multiple="multiple">
|
||||
<?php
|
||||
$users = array_flip($otherUsers);
|
||||
|
||||
foreach ($users as $otherUserName => $otherUserId) {
|
||||
$userSelected = '';
|
||||
|
||||
if ($gotData && $otherUserId != $accountData->account_userId) {
|
||||
if (is_array($accountOtherUsers)) {
|
||||
$userSelected = (in_array($otherUserId, $accountOtherUsers)) ? "selected" : "";
|
||||
}
|
||||
echo "<option value='" . $otherUserId . "' $userSelected>" . $otherUserName . "</option>";
|
||||
} else {
|
||||
if ($userId === $otherUserId) {
|
||||
continue;
|
||||
}
|
||||
echo "<option value='" . $otherUserId . "' $userSelected>" . $otherUserName . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br><br>
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="ueditenabled">
|
||||
<input name="ueditenabled" type="checkbox" id="ueditenabled"
|
||||
class="mdl-switch__input" <?php echo $chkUserEdit; ?>/>
|
||||
<span class="mdl-switch__label"><?php echo _('Hablitar edición'); ?></span>
|
||||
</label>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="account-permissions">
|
||||
<fieldset class="round5">
|
||||
<legend><?php echo _('Grupos'); ?></legend>
|
||||
<select id="selGroups" name="othergroups[]" multiple="multiple">
|
||||
<?php
|
||||
$groups = array_flip($otherGroups);
|
||||
|
||||
foreach ($groups as $otherGroupName => $otherGroupId) {
|
||||
$uGroupSelected = '';
|
||||
|
||||
if ($gotData && $otherGroupId != $accountData->account_userGroupId) {
|
||||
if (is_array($accountOtherGroups)) {
|
||||
$uGroupSelected = (in_array($otherGroupId, $accountOtherGroups)) ? "selected" : "";
|
||||
}
|
||||
echo "<option value='" . $otherGroupId . "' $uGroupSelected>" . $otherGroupName . "</option>";
|
||||
} else {
|
||||
if ($userGroupId === $otherGroupId) {
|
||||
continue;
|
||||
}
|
||||
echo "<option value='" . $otherGroupId . "' $uGroupSelected>" . $otherGroupName . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br><br>
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="geditenabled">
|
||||
<input name="geditenabled" type="checkbox" id="geditenabled"
|
||||
class="mdl-switch__input" <?php echo $chkGroupEdit; ?>/>
|
||||
<span class="mdl-switch__label"><?php echo _('Hablitar edición'); ?></span>
|
||||
</label
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($showform): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Permisos'); ?></td>
|
||||
<td class="valField">
|
||||
<div class="account-permissions">
|
||||
<fieldset class="round5">
|
||||
<legend><?php echo _('Usuarios'); ?></legend>
|
||||
<select id="selUsers" name="otherusers[]" multiple="multiple">
|
||||
<?php
|
||||
$users = array_flip($otherUsers);
|
||||
|
||||
foreach ($users as $otherUserName => $otherUserId) {
|
||||
$userSelected = '';
|
||||
|
||||
if ($gotData && $otherUserId != $accountData->account_userId) {
|
||||
if (is_array($accountOtherUsers)) {
|
||||
$userSelected = (in_array($otherUserId, $accountOtherUsers)) ? "selected" : "";
|
||||
}
|
||||
echo "<option value='" . $otherUserId . "' $userSelected>" . $otherUserName . "</option>";
|
||||
} else {
|
||||
if ($userId === $otherUserId) {
|
||||
continue;
|
||||
}
|
||||
echo "<option value='" . $otherUserId . "' $userSelected>" . $otherUserName . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br><br>
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="ueditenabled">
|
||||
<input name="ueditenabled" type="checkbox" id="ueditenabled" class="mdl-switch__input" <?php echo $chkUserEdit; ?>/>
|
||||
<span class="mdl-switch__label"><?php echo _('Hablitar edición'); ?></span>
|
||||
</label>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="account-permissions">
|
||||
<fieldset class="round5">
|
||||
<legend><?php echo _('Grupos'); ?></legend>
|
||||
<select id="selGroups" name="othergroups[]" multiple="multiple">
|
||||
<?php
|
||||
$groups = array_flip($otherGroups);
|
||||
|
||||
foreach ($groups as $otherGroupName => $otherGroupId) {
|
||||
$uGroupSelected = '';
|
||||
|
||||
if ($gotData && $otherGroupId != $accountData->account_userGroupId) {
|
||||
if (is_array($accountOtherGroups)) {
|
||||
$uGroupSelected = (in_array($otherGroupId, $accountOtherGroups)) ? "selected" : "";
|
||||
}
|
||||
echo "<option value='" . $otherGroupId . "' $uGroupSelected>" . $otherGroupName . "</option>";
|
||||
} else {
|
||||
if ($userGroupId === $otherGroupId) {
|
||||
continue;
|
||||
}
|
||||
echo "<option value='" . $otherGroupId . "' $uGroupSelected>" . $otherGroupName . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br><br>
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="geditenabled">
|
||||
<input name="geditenabled" type="checkbox" id="geditenabled" class="mdl-switch__input" <?php echo $chkGroupEdit; ?>/>
|
||||
<span class="mdl-switch__label"><?php echo _('Hablitar edición'); ?></span>
|
||||
</label
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if($userIsAdminApp || $userIsAdminAcc):?>
|
||||
<?php if ($userIsAdminApp || $userIsAdminAcc): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Grupo Principal'); ?></td>
|
||||
<td class="valField">
|
||||
@@ -211,124 +235,126 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showform): ?>
|
||||
<input type="hidden" name="hash" value="<?php echo $changesHash; ?>">
|
||||
<input type="hidden" name="next" value="<?php echo $nextaction; ?>">
|
||||
<input type="hidden" name="actionId" value="<?php echo $actionId; ?>">
|
||||
<?php if ($gotData): ?>
|
||||
<input type="hidden" name="accountid" value="<?php echo $accountId; ?>"/>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showHistory && is_array($historyData) && count($historyData) > 0): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Historial'); ?></td>
|
||||
<td class="valField">
|
||||
<select id="selHistory" name="historyId" class="select-box">
|
||||
<option value="0"></option>
|
||||
<?php foreach ($historyData as $id => $name): ?>
|
||||
<option
|
||||
value="<?php echo $id; ?>" <?php echo ($gotData && $id === $accountId) ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<script>
|
||||
$('#selHistory').on('change', function (e) {
|
||||
var historyId = $('#selHistory').val();
|
||||
|
||||
if (historyId > 0) {
|
||||
sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_ACC_VIEW_HISTORY; ?>, <?php echo \SP\Core\ActionsInterface::ACTION_ACC_VIEW; ?>, historyId);
|
||||
}
|
||||
});
|
||||
|
||||
$('#selHistory').chosen({
|
||||
disable_search: true,
|
||||
placeholder_text_single: "<?php echo _('Seleccionar fecha'); ?>"
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($actionId == \SP\Core\ActionsInterface::ACTION_ACC_EDIT && $accountData->user_editName): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Última Modificación'); ?></td>
|
||||
<?php if ($accountData->user_editName): ?>
|
||||
<td class="valField"><?php echo $accountData->account_dateEdit; ?><?php echo _('por'); ?><?php echo $accountData->user_editName; ?></td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
</table>
|
||||
|
||||
<?php if ($customFields): ?>
|
||||
<table class="data round extra-info secure-info">
|
||||
<?php foreach ($customFields as $index => $field): ?>
|
||||
<?php if ($index !== 'hash'): ?>
|
||||
<tr>
|
||||
<td class="descField">
|
||||
<?php echo $field->text; ?>
|
||||
<?php if ($field->help): ?>
|
||||
<div id="help-<?php echo $field->name; ?>" class="icon material-icons fg-blue80">
|
||||
help_outline
|
||||
</div>
|
||||
<div class="mdl-tooltip mdl-tooltip--large" for="help-<?php echo $field->name; ?>">
|
||||
<p><?php echo $field->help; ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="<?php echo $field->name; ?>"
|
||||
name="customfield[<?php echo $field->id; ?>]"
|
||||
type="<?php echo $field->typeName; ?>"
|
||||
class="mdl-textfield__input fg-blue100 <?php echo ($field->type === \SP\Mgmt\CustomFieldsBase::TYPE_PASSWORD) ? 'passwordfield__input-show' : ''; ?>"
|
||||
maxlength="500"
|
||||
value="<?php echo ($gotData) ? \SP\Html\Html::sanitize($field->value) : ''; ?>"
|
||||
<?php echo ($field->required) ? 'required' : ''; ?>>
|
||||
<label class="mdl-textfield__label"
|
||||
for="<?php echo $field->name; ?>"><?php echo $field->text; ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php if ($field->type === \SP\Mgmt\CustomFields::TYPE_PASSWORD && !$showViewPass): ?>
|
||||
****
|
||||
<?php elseif ($field->type === \SP\Mgmt\CustomFields::TYPE_COLOR): ?>
|
||||
<span class="round custom-input-color"
|
||||
style="background-color: <?php echo $field->value; ?>;"></span>
|
||||
<?php else: ?>
|
||||
<?php echo $field->value; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="sk" value="<?php echo $sk; ?>">
|
||||
<input type="hidden" name="isAjax" value="1">
|
||||
</form>
|
||||
|
||||
<?php if ($showform): ?>
|
||||
</form>>
|
||||
<?php endif; ?>
|
||||
|
||||
<!--Files boxes-->
|
||||
<!--Files box-->
|
||||
<?php if ($showFiles): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Archivos'); ?></td>
|
||||
<td class="valField">
|
||||
<div id="downFiles"></div>
|
||||
<?php if ($accountIsHistory): ?>
|
||||
<script>sysPassUtil.Common.getFiles(<?php echo $accountParentId; ?>, <?php echo intval($showDelete); ?>, '<?php echo $sk; ?>');</script>
|
||||
<?php else: ?>
|
||||
<script>sysPassUtil.Common.getFiles(<?php echo $accountId; ?>, <?php echo intval($showDelete); ?>, '<?php echo $sk; ?>'); </script>
|
||||
<table class="data round extra-info secure-info">
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Archivos'); ?></td>
|
||||
<td class="valField">
|
||||
<div id="downFiles"></div>
|
||||
<?php if ($accountIsHistory): ?>
|
||||
<script>sysPassUtil.Common.getFiles(<?php echo $accountParentId; ?>, <?php echo intval($showDelete); ?>, '<?php echo $sk; ?>');</script>
|
||||
<?php else: ?>
|
||||
<script>sysPassUtil.Common.getFiles(<?php echo $accountId; ?>, <?php echo intval($showDelete); ?>, '<?php echo $sk; ?>'); </script>
|
||||
<?php if ($actionId == \SP\Core\ActionsInterface::ACTION_ACC_EDIT): ?>
|
||||
<form method="post" enctype="multipart/form-data" name="upload_form" id="fileUpload">
|
||||
<input type="file" id="inFile" name="inFile"/>
|
||||
</form>
|
||||
<div id="dropzone" class="round active-tooltip"
|
||||
data-files-ext="<?php echo $filesAllowedExts; ?>"
|
||||
title="<?php echo _('Soltar archivos aquí (max. 5) o click para seleccionar') . '<br><br>' . _('Tamaño máximo de archivo') . ' ' . $maxFileSize . ' MB'; ?>">
|
||||
data-files-ext="<?php echo $filesAllowedExts; ?>"
|
||||
title="<?php echo _('Soltar archivos aquí (max. 5) o click para seleccionar') . '<br><br>' . _('Tamaño máximo de archivo') . ' ' . $maxFileSize . ' MB'; ?>">
|
||||
<i class="material-icons md-60 fg-green80">cloud_upload</i>
|
||||
</div>
|
||||
<script> sysPassUtil.Common.dropFile(<?php echo $accountId; ?>, '<?php echo $sk; ?>', <?php echo $maxFileSize; ?>, <?php echo \SP\Core\ActionsInterface::ACTION_ACC_FILES_UPLOAD; ?>); </script>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showHistory && is_array($historyData) && count($historyData) > 0): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Historial'); ?></td>
|
||||
<td class="valField">
|
||||
<select id="selHistory" name="historyId" class="select-box">
|
||||
<option value="0"></option>
|
||||
<?php foreach ($historyData as $id => $name): ?>
|
||||
<option
|
||||
value="<?php echo $id; ?>" <?php echo ($gotData && $id === $accountId) ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<script>
|
||||
$('#selHistory').on('change', function (e) {
|
||||
var historyId = $('#selHistory').val();
|
||||
|
||||
if(historyId > 0) {
|
||||
sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_ACC_VIEW_HISTORY; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_ACC_VIEW; ?>, historyId);
|
||||
}
|
||||
});
|
||||
|
||||
$('#selHistory').chosen({
|
||||
disable_search: true,
|
||||
placeholder_text_single: "<?php echo _('Seleccionar fecha'); ?>"
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($actionId == \SP\Core\ActionsInterface::ACTION_ACC_EDIT && $accountData->user_editName): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Última Modificación'); ?></td>
|
||||
<?php if ($accountData->user_editName): ?>
|
||||
<td class="valField"><?php echo $accountData->account_dateEdit; ?> <?php echo _('por'); ?> <?php echo $accountData->user_editName; ?></td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
</table>
|
||||
|
||||
<?php if($customFields): ?>
|
||||
<table class="data round extra-info secure-info">
|
||||
<?php foreach($customFields as $field):?>
|
||||
<tr>
|
||||
<td class="descField">
|
||||
<?php echo $field->text; ?>
|
||||
<?php if($field->help): ?>
|
||||
<div id="help-<?php echo $field->name; ?>" class="icon material-icons fg-blue80">help_outline</div>
|
||||
<div class="mdl-tooltip mdl-tooltip--large" for="help-<?php echo $field->name; ?>">
|
||||
<p><?php echo $field->help; ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="valField">
|
||||
<?php if ($showform): ?>
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input id="<?php echo $field->name; ?>" name="customfield[<?php echo $field->id; ?>]"
|
||||
type="<?php echo $field->typeName; ?>"
|
||||
class="mdl-textfield__input fg-blue100 <?php echo ($field->type === \SP\Mgmt\CustomFieldsBase::TYPE_PASSWORD) ? 'passwordfield__input-show' : ''; ?>"
|
||||
maxlength="500" value="<?php echo ($gotData) ? \SP\Html\Html::sanitize($field->value) : ''; ?>"
|
||||
<?php echo ($field->required) ? 'required' : ''; ?>>
|
||||
<label class="mdl-textfield__label" for="<?php echo $field->name; ?>"><?php echo $field->text; ?></label>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php if($field->type === \SP\Mgmt\CustomFields::TYPE_PASSWORD && !$showViewPass):?>
|
||||
****
|
||||
<?php elseif($field->type === \SP\Mgmt\CustomFields::TYPE_COLOR):?>
|
||||
<span class="round custom-input-color" style="background-color: <?php echo $field->value; ?>;"></span>
|
||||
<?php else:?>
|
||||
<?php echo $field->value; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<!--More info about account details-->
|
||||
@@ -399,19 +425,20 @@
|
||||
<td class="valField"><?php echo ($accountData->user_editName) ? $accountData->user_editName : $accountData->user_editLogin; ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if($showLink && $accountData->publicLink_hash): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Enlace Público'); ?></td>
|
||||
<td class="valField">
|
||||
<a href="<?php echo $publicLinkUrl; ?>" target="_blank"> <?php echo $publicLinkUrl; ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($showLink && $accountData->publicLink_hash): ?>
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Enlace Público'); ?></td>
|
||||
<td class="valField">
|
||||
<a href="<?php echo $publicLinkUrl; ?>" target="_blank"> <?php echo $publicLinkUrl; ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($gotData && $accountIsHistory): ?>
|
||||
<form method="post" name="frmAccount" id="frmAccount" onsubmit="sysPassUtil.Common.saveAccount('frmAccount'); return false;">
|
||||
<form method="post" name="frmAccount" id="frmAccount"
|
||||
onsubmit="sysPassUtil.Common.saveAccount('frmAccount'); return false;">
|
||||
<input type="hidden" name="hash" value="<?php echo $changesHash; ?>">
|
||||
<input type="hidden" name="actionId"
|
||||
value="<?php echo \SP\Core\ActionsInterface::ACTION_ACC_EDIT_RESTORE; ?>">
|
||||
@@ -422,71 +449,103 @@
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="action">
|
||||
<?php if ($showDelete): ?>
|
||||
<button id="btnDelete" type="button" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-red80" OnClick="sysPassUtil.Common.delAccount(<?php echo $accountId; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_ACC_DELETE; ?>,'<?php echo $sk; ?>');" title="<?php echo _('Eliminar Cuenta'); ?>">
|
||||
<i class="material-icons">delete</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($showDelete): ?>
|
||||
<button id="btnDelete" type="button"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-red80"
|
||||
OnClick="sysPassUtil.Common.delAccount(<?php echo $accountId; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_ACC_DELETE; ?>,'<?php echo $sk; ?>');"
|
||||
title="<?php echo _('Eliminar Cuenta'); ?>">
|
||||
<i class="material-icons">delete</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showLink && $showViewPass): ?>
|
||||
<button id="btnLink" type="button" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-green80" OnClick="sysPassUtil.Common.linksMgmtSave(<?php echo $accountId; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_MGM_PUBLICLINKS_NEW; ?>,'<?php echo $sk; ?>');" title="<?php echo _('Crear Enlace Público'); ?>">
|
||||
<i class="material-icons">link</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($showLink && $showViewPass): ?>
|
||||
<button id="btnLink" type="button"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-green80"
|
||||
OnClick="sysPassUtil.Common.linksMgmtSave(<?php echo $accountId; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_MGM_PUBLICLINKS_NEW; ?>,'<?php echo $sk; ?>');"
|
||||
title="<?php echo _('Crear Enlace Público'); ?>">
|
||||
<i class="material-icons">link</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showViewPass): ?>
|
||||
<button id="btnViewPass" type="button" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored" onClick="sysPassUtil.Common.viewPass(<?php echo $accountId; ?>,1,<?php echo $accountIsHistory; ?>)" title="<?php echo _('Ver Clave'); ?>">
|
||||
<i class="material-icons">lock_open</i>
|
||||
</button>
|
||||
<?php if(!Checks::accountPassToImageIsEnabled()): ?>
|
||||
<button id="btnClipPass" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored clip-pass-button" onmousedown="sysPassUtil.Common.viewPass(<?php echo $accountId; ?>, false, <?php echo $accountIsHistory; ?>)" title="<?php echo _('Copiar Clave en Portapapeles'); ?>" data-account-id="<?php echo $accountId; ?>">
|
||||
<?php if ($showViewPass): ?>
|
||||
<button id="btnViewPass" type="button"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored"
|
||||
onClick="sysPassUtil.Common.viewPass(<?php echo $accountId; ?>,1,<?php echo $accountIsHistory; ?>)"
|
||||
title="<?php echo _('Ver Clave'); ?>">
|
||||
<i class="material-icons">lock_open</i>
|
||||
</button>
|
||||
<?php if (!Checks::accountPassToImageIsEnabled()): ?>
|
||||
<button id="btnClipPass"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored clip-pass-button"
|
||||
onmousedown="sysPassUtil.Common.viewPass(<?php echo $accountId; ?>, false, <?php echo $accountIsHistory; ?>)"
|
||||
title="<?php echo _('Copiar Clave en Portapapeles'); ?>"
|
||||
data-account-id="<?php echo $accountId; ?>">
|
||||
<i class="material-icons">content_paste</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showEditPass): ?>
|
||||
<button id="btnEditPass" type="button" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-orange80" OnClick="sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_ACC_EDIT_PASS; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_ACC_SEARCH; ?>,<?php echo $accountId; ?>)" title="<?php echo _('Modificar Clave de Cuenta'); ?>">
|
||||
<i class="material-icons">lock_outline</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($showEditPass): ?>
|
||||
<button id="btnEditPass" type="button"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-orange80"
|
||||
OnClick="sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_ACC_EDIT_PASS; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_ACC_SEARCH; ?>,<?php echo $accountId; ?>)"
|
||||
title="<?php echo _('Modificar Clave de Cuenta'); ?>">
|
||||
<i class="material-icons">lock_outline</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($gotData && $accountIsHistory): ?>
|
||||
<button id="btnBack" type="button" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored" OnClick="sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_ACC_VIEW; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_ACC_SEARCH; ?>,<?php echo $accountParentId; ?>)" title="<?php echo _('Ver Actual'); ?>">
|
||||
<i class="material-icons">arrow_back</i>
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<button id="btnBack" type="button" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored" OnClick="sysPassUtil.Common.doAction(<?php echo $lastAction; ?>, <?php echo $actionId; ?>,<?php echo $accountParentId; ?>)" title="<?php echo _('Atrás'); ?>">
|
||||
<i class="material-icons">arrow_back</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($gotData && $accountIsHistory): ?>
|
||||
<button id="btnBack" type="button"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored"
|
||||
OnClick="sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_ACC_VIEW; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_ACC_SEARCH; ?>,<?php echo $accountParentId; ?>)"
|
||||
title="<?php echo _('Ver Actual'); ?>">
|
||||
<i class="material-icons">arrow_back</i>
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<button id="btnBack" type="button"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored"
|
||||
OnClick="sysPassUtil.Common.doAction(<?php echo $lastAction; ?>, <?php echo $actionId; ?>,<?php echo $accountParentId; ?>)"
|
||||
title="<?php echo _('Atrás'); ?>">
|
||||
<i class="material-icons">arrow_back</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showEdit): ?>
|
||||
<button id="btnEdit" type="button" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-orange80" OnClick="sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_ACC_EDIT; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_ACC_SEARCH; ?>,<?php echo $accountId; ?>)" title="<?php echo _('Modificar Cuenta'); ?>">
|
||||
<i class="material-icons">mode_edit</i>
|
||||
</button>
|
||||
<?php elseif (!$showEdit && $actionId == \SP\Core\ActionsInterface::ACTION_ACC_VIEW && Checks::mailrequestIsEnabled()): ?>
|
||||
<button id="btnRequest" type="button" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored" OnClick="sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_ACC_REQUEST; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_ACC_VIEW; ?>,<?php echo $accountId; ?>)" title="<?php echo _('Solicitar Modificación'); ?>">
|
||||
<i class="material-icons">email</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($showEdit): ?>
|
||||
<button id="btnEdit" type="button"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-orange80"
|
||||
OnClick="sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_ACC_EDIT; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_ACC_SEARCH; ?>,<?php echo $accountId; ?>)"
|
||||
title="<?php echo _('Modificar Cuenta'); ?>">
|
||||
<i class="material-icons">mode_edit</i>
|
||||
</button>
|
||||
<?php elseif (!$showEdit && $actionId == \SP\Core\ActionsInterface::ACTION_ACC_VIEW && Checks::mailrequestIsEnabled()): ?>
|
||||
<button id="btnRequest" type="button"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored"
|
||||
OnClick="sysPassUtil.Common.doAction(<?php echo \SP\Core\ActionsInterface::ACTION_ACC_REQUEST; ?>,<?php echo \SP\Core\ActionsInterface::ACTION_ACC_VIEW; ?>,<?php echo $accountId; ?>)"
|
||||
title="<?php echo _('Solicitar Modificación'); ?>">
|
||||
<i class="material-icons">email</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showRestore): ?>
|
||||
<button id="btnRestore" name="btnRestore" type="submit" form="frmAccount" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-green80" title="<?php echo _('Restaurar cuenta desde este punto'); ?>">
|
||||
<i class="material-icons">restore</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($showRestore): ?>
|
||||
<button id="btnRestore" name="btnRestore" type="submit" form="frmAccount"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-green80"
|
||||
title="<?php echo _('Restaurar cuenta desde este punto'); ?>">
|
||||
<i class="material-icons">restore</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showSave): ?>
|
||||
<button id="btnSave" name="btnSave" type="submit" form="frmAccount" class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-green80" title="<?php echo _('Guardar'); ?>">
|
||||
<i class="material-icons">save</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($showSave): ?>
|
||||
<button id="btnSave" name="btnSave" type="submit" form="frmAccount"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored bg-green80"
|
||||
title="<?php echo _('Guardar'); ?>">
|
||||
<i class="material-icons">save</i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($showform): ?>
|
||||
<script>
|
||||
$(function(){
|
||||
$(function () {
|
||||
$("#selGroups").chosen({
|
||||
placeholder_text_multiple: "<?php echo _('Seleccionar grupos secundarios'); ?>"
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
.mdl-button{margin:0 .3em}.fg-blue20{color:rgba(83,109,254,.2)}.fg-blue40{color:rgba(83,109,254,.4)}.fg-blue60{color:rgba(83,109,254,.6)}.fg-blue80{color:rgba(83,109,254,.8)}.fg-blue100{color:#536dfe}.mdl-button--fab.mdl-button--colored.bg-blue20{background-color:rgba(83,109,254,.2)}.mdl-button--fab.mdl-button--colored.bg-blue40{background-color:rgba(83,109,254,.4)}.mdl-button--fab.mdl-button--colored.bg-blue60{background-color:rgba(83,109,254,.6)}.mdl-button--fab.mdl-button--colored.bg-blue80{background-color:rgba(83,109,254,.8)}.mdl-button--fab.mdl-button--colored.bg-blue100{background-color:#536dfe}.fg-orange20{color:rgba(255,193,7,.2)}.fg-orange40{color:rgba(255,193,7,.4)}.fg-orange60{color:rgba(255,193,7,.6)}.fg-orange80{color:rgba(255,193,7,.8)}.fg-orange100{color:rgba(255,193,7,1)}.mdl-button--fab.mdl-button--colored.bg-orange20{background-color:rgba(255,193,7,.2)}.mdl-button--fab.mdl-button--colored.bg-orange40{background-color:rgba(255,193,7,.4)}.mdl-button--fab.mdl-button--colored.bg-orange60{background-color:rgba(255,193,7,.6)}.mdl-button--fab.mdl-button--colored.bg-orange80{background-color:rgba(255,193,7,.8)}.mdl-button--fab.mdl-button--colored.bg-orange100{background-color:rgba(255,193,7,1)}.fg-red20{color:rgba(244,67,54,.2)}.fg-red40{color:rgba(244,67,54,.4)}.fg-red60{color:rgba(244,67,54,.6)}.fg-red80{color:rgba(244,67,54,.8)}.fg-red100{color:#f44336}.mdl-button--fab.mdl-button--colored.bg-red20{background-color:rgba(244,67,54,.2)}.mdl-button--fab.mdl-button--colored.bg-red40{background-color:rgba(244,67,54,.4)}.mdl-button--fab.mdl-button--colored.bg-red60{background-color:rgba(244,67,54,.6)}.mdl-button--fab.mdl-button--colored.bg-red80{background-color:rgba(244,67,54,.8)}.mdl-button--fab.mdl-button--colored.bg-red100{background-color:#f44336}.fg-green20{color:rgba(0,150,136,.2)}.fg-green40{color:rgba(0,150,136,.4)}.fg-green60{color:rgba(0,150,136,.6)}.fg-green80{color:rgba(0,150,136,.8)}.fg-green00{color:#009688}.mdl-button--fab.mdl-button--colored.bg-green20{background-color:rgba(0,150,136,0.2)}.mdl-button--fab.mdl-button--colored.bg-green40{background-color:rgba(0,150,136,0.4)}.mdl-button--fab.mdl-button--colored.bg-green60{background-color:rgba(0,150,136,.6)}.mdl-button--fab.mdl-button--colored.bg-green80{background-color:rgba(0,150,136,.8)}.mdl-button--fab.mdl-button--colored.bg-green100{background-color:#009688}.mdl-tooltip{text-align:justify;max-width:400px}.mdl-switch--inline{display:inline;margin:0 1em}
|
||||
.mdl-button{margin:0 .3em}.fg-blue20{color:rgba(83,109,254,.2)}.fg-blue40{color:rgba(83,109,254,.4)}.fg-blue60{color:rgba(83,109,254,.6)}.fg-blue80{color:rgba(83,109,254,.8)}.fg-blue100{color:#536dfe}.mdl-button--fab.mdl-button--colored.bg-blue20{background-color:rgba(83,109,254,.2)}.mdl-button--fab.mdl-button--colored.bg-blue40{background-color:rgba(83,109,254,.4)}.mdl-button--fab.mdl-button--colored.bg-blue60{background-color:rgba(83,109,254,.6)}.mdl-button--fab.mdl-button--colored.bg-blue80{background-color:rgba(83,109,254,.8)}.mdl-button--fab.mdl-button--colored.bg-blue100{background-color:#536dfe}.fg-orange20{color:rgba(255,193,7,.2)}.fg-orange40{color:rgba(255,193,7,.4)}.fg-orange60{color:rgba(255,193,7,.6)}.fg-orange80{color:rgba(255,193,7,.8)}.fg-orange100{color:rgba(255,193,7,1)}.mdl-button--fab.mdl-button--colored.bg-orange20{background-color:rgba(255,193,7,.2)}.mdl-button--fab.mdl-button--colored.bg-orange40{background-color:rgba(255,193,7,.4)}.mdl-button--fab.mdl-button--colored.bg-orange60{background-color:rgba(255,193,7,.6)}.mdl-button--fab.mdl-button--colored.bg-orange80{background-color:rgba(255,193,7,.8)}.mdl-button--fab.mdl-button--colored.bg-orange100{background-color:rgba(255,193,7,1)}.fg-red20{color:rgba(244,67,54,.2)}.fg-red40{color:rgba(244,67,54,.4)}.fg-red60{color:rgba(244,67,54,.6)}.fg-red80{color:rgba(244,67,54,.8)}.fg-red100{color:#f44336}.mdl-button--fab.mdl-button--colored.bg-red20{background-color:rgba(244,67,54,.2)}.mdl-button--fab.mdl-button--colored.bg-red40{background-color:rgba(244,67,54,.4)}.mdl-button--fab.mdl-button--colored.bg-red60{background-color:rgba(244,67,54,.6)}.mdl-button--fab.mdl-button--colored.bg-red80{background-color:rgba(244,67,54,.8)}.mdl-button--fab.mdl-button--colored.bg-red100{background-color:#f44336}.fg-green20{color:rgba(0,150,136,.2)}.fg-green40{color:rgba(0,150,136,.4)}.fg-green60{color:rgba(0,150,136,.6)}.fg-green80{color:rgba(0,150,136,.8)}.fg-green100{color:#009688}.mdl-button--fab.mdl-button--colored.bg-green20{background-color:rgba(0,150,136,0.2)}.mdl-button--fab.mdl-button--colored.bg-green40{background-color:rgba(0,150,136,0.4)}.mdl-button--fab.mdl-button--colored.bg-green60{background-color:rgba(0,150,136,.6)}.mdl-button--fab.mdl-button--colored.bg-green80{background-color:rgba(0,150,136,.8)}.mdl-button--fab.mdl-button--colored.bg-green100{background-color:#009688}.mdl-tooltip{text-align:justify;max-width:400px}.mdl-switch--inline{display:inline;margin:0 1em}
|
||||
29
inc/themes/material-blue/datagrid-nav-full.inc
Normal file
29
inc/themes/material-blue/datagrid-nav-full.inc
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* @var $data SP\Html\DataGrid\DataGridTab
|
||||
* @var $this SP\Core\Template
|
||||
*/
|
||||
?>
|
||||
<div id="pageNav" class="round shadow">
|
||||
<div id="pageNavLeft">
|
||||
<?php echo $data->getPager()->getTotalRows(); ?> @ <?php echo $data->getTime(); ?>s
|
||||
<?php if ($data->getPager()->getFilterOn()): ?>
|
||||
<span class="filterOn round"><?php echo _('Filtro ON'); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div id="pageNavRight">
|
||||
<?php if ($data->getPager()->getLimitStart() >= 1): ?>
|
||||
<img src="imgs/arrow_first.png" onClick="<?php echo $data->getPager()->getOnClickFirst(); ?>"
|
||||
title="<?php echo _('Primera página'); ?>"/>
|
||||
<img src="imgs/arrow_left.png" onClick="<?php echo $data->getPager()->getOnClickPrev(); ?>"
|
||||
title="<?php echo _('Página anterior'); ?>"/>
|
||||
<?php endif; ?>
|
||||
<?php echo $data->getPager()->getFirstPage(), '/', $data->getPager()->getLastPage(); ?>
|
||||
<?php if ($data->getPager()->getLimitStart() < $data->getPager()->getTotalRows() && $data->getPager()->getFirstPage() != $data->getPager()->getLastPage()): ?>
|
||||
<img src="imgs/arrow_right.png" onClick="<?php echo $data->getPager()->getOnClickNext(); ?>"
|
||||
title="<?php echo _('Página siguiente'); ?>"/>
|
||||
<img src="imgs/arrow_last.png" onClick="<?php echo $data->getPager()->getOnClickLast(); ?>"
|
||||
title="<?php echo _('Última página'); ?>"/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
51
inc/themes/material-blue/datagrid-rows.inc
Normal file
51
inc/themes/material-blue/datagrid-rows.inc
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @var $data SP\Html\DataGrid\DataGridTab
|
||||
* @var $this SP\Core\Template
|
||||
*/
|
||||
?>
|
||||
|
||||
<!-- Rows -->
|
||||
<?php if (count($data->getData()->getData()) === 0): ?>
|
||||
<div class="noRes round"><?php echo _('No se encontraron registros'); ?></div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($data->getData()->getData() as $item): ?>
|
||||
<ul>
|
||||
<?php foreach ($data->getData()->getDataRowSources() as $rowSrc): ?>
|
||||
<li class="cell-data" style="width: <?php echo $data->getHeader()->getWidth(); ?>%;">
|
||||
<?php echo (!is_null($item->$rowSrc)) ? $item->$rowSrc : ' '; // Fix height ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (count($data->getData()->getDataRowSourcesWithIcon()) > 0): ?>
|
||||
<li class="cell-nodata" style="width: <?php echo $data->getHeader()->getWidth(); ?>%;">
|
||||
<?php foreach ($data->getData()->getDataRowSourcesWithIcon() as $rowSrcIcon): ?>
|
||||
<?php if ($item->$rowSrcIcon[0] == 1): ?>
|
||||
<i class="material-icons" title="<?php echo $rowSrcIcon[1]->getTitle(); ?>">
|
||||
<?php echo $rowSrcIcon[1]->getIcon(); ?>
|
||||
</i>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<li class="cell-actions round">
|
||||
<?php foreach ($data->getDataActions() as $action): ?>
|
||||
<?php if (!$action->isSkip()): ?>
|
||||
<?php if ($action->getFilterRowSource() && $item->{$action->getFilterRowSource()} == 1): continue; endif; ?>
|
||||
<i class="material-icons <?php echo $action->getIcon()->getClass(); ?>"
|
||||
title="<?php echo $action->getTitle(); ?>"
|
||||
data-itemid="<?php echo $item->{$data->getData()->getDataRowSourceId()}; ?>"
|
||||
data-activetab="<?php echo $index; ?>"
|
||||
data-nextactionid="<?php echo $actionId; ?>"
|
||||
Onclick="<?php echo $action->getOnClick(); ?>"><?php echo $action->getIcon()->getIcon(); ?></i>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</li>
|
||||
</ul>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<!-- Pager -->
|
||||
<?php include $data->getDataPagerTemplate(); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
@@ -1,40 +1,23 @@
|
||||
<!-- Start Tabs-->
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<?php foreach ($tabs as $index => $tab):
|
||||
/**
|
||||
* @var $tab SP\Html\DataGrid\DataGridTab
|
||||
*/
|
||||
?>
|
||||
<li>
|
||||
<a href="#tabs-<?php echo $index; ?>"
|
||||
title="<?php echo $tab->getTitle(); ?>"><?php echo $tab->getTitle(); ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php foreach ($tabs as $index => $tab):
|
||||
/**
|
||||
* @var $tab SP\Html\DataGrid\DataGridTab
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* @var $data SP\Html\DataGrid\DataGridTab
|
||||
* @var $this SP\Core\Template
|
||||
* @var $action SP\Html\DataGrid\DataGridAction|SP\Html\DataGrid\DataGridActionSearch
|
||||
*/
|
||||
?>
|
||||
<div id="tabs">
|
||||
<ul id="tabsHeader"></ul>
|
||||
|
||||
<?php foreach ($tabs as $index => $data): ?>
|
||||
<script>
|
||||
$('#tabsHeader').append('<li><a href="#tabs-<?php echo $index; ?>" title="<?php echo $data->getTitle(); ?>"><?php echo $data->getTitle(); ?></a></li>');
|
||||
</script>
|
||||
|
||||
<div id="tabs-<?php echo $index; ?>">
|
||||
<div class="action fullWidth">
|
||||
<ul>
|
||||
<?php foreach ($tab->getDataActions() as $action): ?>
|
||||
<?php if ($action->isNew()): ?>
|
||||
<li>
|
||||
<button
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored mdl-js-ripple-effect"
|
||||
data-itemid="0" data-activetab="<?php echo $index; ?>"
|
||||
data-nextactionid="<?php echo $tab->getOnCloseAction(); ?>"
|
||||
OnClick="<?php echo $action->getOnClick(); ?>">
|
||||
<i class="material-icons"
|
||||
title="<?php echo $action->getTitle(); ?>"><?php echo $action->getIcon()->getIcon(); ?></i>
|
||||
</button>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<li>
|
||||
<button id="btnBack" type="button"
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored"
|
||||
@@ -43,59 +26,51 @@
|
||||
<i class="material-icons">arrow_back</i>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="<?php echo $tab->getId(); ?>" class="data-header">
|
||||
<ul class="round5 header-grey">
|
||||
<?php foreach ($tab->getHeader()->getHeaders() as $header): ?>
|
||||
<li style="width: <?php echo $tab->getHeader()->getWidth(); ?>%;"><?php echo $header; ?></li>
|
||||
<?php foreach ($data->getDataActions() as $action): ?>
|
||||
<?php if ($action->getType() === \SP\Html\DataGrid\DataGridActionType::NEW_ITEM): ?>
|
||||
<li>
|
||||
<button
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored mdl-js-ripple-effect"
|
||||
data-itemid="0" data-activetab="<?php echo $index; ?>"
|
||||
data-nextactionid="<?php echo $data->getOnCloseAction(); ?>"
|
||||
OnClick="<?php echo $action->getOnClick(); ?>"
|
||||
title="<?php echo $action->getTitle(); ?>">
|
||||
<i class="material-icons"><?php echo $action->getIcon()->getIcon(); ?></i>
|
||||
</button>
|
||||
</li>
|
||||
<?php elseif ($action->getType() === \SP\Html\DataGrid\DataGridActionType::SEARCH_ITEM): ?>
|
||||
<li class="datagrid-action-search" style="width: auto;">
|
||||
<form method="post" id="<?php echo $action->getName(); ?>"
|
||||
name="<?php echo $action->getName(); ?>"
|
||||
onsubmit="<?php echo $action->getOnSubmit(); ?>">
|
||||
<i id="btnClear" class="material-icons" title="<?php echo _('Limpiar'); ?>" onclick="$('#<?php echo $action->getName(); ?>').trigger('reset').submit();">clear_all</i>
|
||||
<div class="mdl-textfield mdl-js-textfield">
|
||||
<input class="mdl-textfield__input fg-blue100" type="text" id="txtSearch"
|
||||
name="search" value=""/>
|
||||
<label class="mdl-textfield__label"
|
||||
for="txtSearch"><?php echo $action->getTitle(); ?></label>
|
||||
</div>
|
||||
<input type="hidden" name="target" value="data-rows-<?php echo $data->getId(); ?>">
|
||||
<input type="hidden" name="activeTab" value="<?php echo $index; ?>">
|
||||
<input type="hidden" name="actionId" value="<?php echo $action->getId(); ?>">
|
||||
<input type="hidden" name="isAjax" value="1">
|
||||
</form>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="data-rows">
|
||||
<?php foreach ($tab->getData()->getData() as $item): ?>
|
||||
<ul>
|
||||
<?php foreach ($tab->getData()->getDataRowSources() as $rowSrc): ?>
|
||||
<li class="cell-data" style="width: <?php echo $tab->getHeader()->getWidth(); ?>%;">
|
||||
<?php echo (!is_null($item->$rowSrc)) ? $item->$rowSrc : ' '; // Fix height ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (count($tab->getData()->getDataRowSourcesWithIcon()) > 0): ?>
|
||||
<li class="cell-nodata" style="width: <?php echo $tab->getHeader()->getWidth(); ?>%;">
|
||||
<?php foreach ($tab->getData()->getDataRowSourcesWithIcon() as $rowSrcIcon): ?>
|
||||
<?php if ($item->$rowSrcIcon[0] == 1): ?>
|
||||
<i class="material-icons" title="<?php echo $rowSrcIcon[1]->getTitle(); ?>">
|
||||
<?php echo $rowSrcIcon[1]->getIcon(); ?>
|
||||
</i>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<li class="cell-actions round">
|
||||
<?php foreach ($tab->getDataActions() as $action): ?>
|
||||
<?php if (!$action->isSkip()): ?>
|
||||
<?php if ($action->getFilterRowSource() && $item->{$action->getFilterRowSource()} == 1): continue; endif; ?>
|
||||
<i class="material-icons <?php echo $action->getIcon()->getClass(); ?>"
|
||||
title="<?php echo $action->getTitle(); ?>"
|
||||
data-itemid="<?php echo $item->{$tab->getData()->getDataRowSourceId()}; ?>"
|
||||
data-activetab="<?php echo $index; ?>"
|
||||
data-nextactionid="<?php echo $actionId; ?>"
|
||||
Onclick="<?php echo $action->getOnClick(); ?>"><?php echo $action->getIcon()->getIcon(); ?></i>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</li>
|
||||
</ul>
|
||||
<?php endforeach; ?>
|
||||
<div id="<?php echo $data->getId(); ?>" class="data-header">
|
||||
<ul class="round5 header-grey">
|
||||
<?php foreach ($data->getHeader()->getHeaders() as $header): ?>
|
||||
<li style="width: <?php echo $data->getHeader()->getWidth(); ?>%;"><?php echo $header; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="pageNav" class="round shadow">
|
||||
<div id="pageNavLeft">
|
||||
<?php echo count($tab->getData()->getData()); ?> @ <?php echo $tab->getTime(); ?>s
|
||||
</div>
|
||||
<div id="data-rows-<?php echo $data->getId(); ?>" class="data-rows">
|
||||
<?php include $data->getDataRowTemplate(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
@@ -103,12 +78,6 @@
|
||||
|
||||
<script>
|
||||
$("#tabs").tabs({
|
||||
active: <?php echo $activeTabId; ?>,
|
||||
create: function (event, ui) {
|
||||
$("input:visible:first").focus();
|
||||
},
|
||||
activate: function (event, ui) {
|
||||
sysPassUtil.Common.setContentSize();
|
||||
}
|
||||
active: <?php echo $activeTabId; ?>
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
<a href="<?php echo $wikiPageUrl, $account['name']; ?>" target="_blank">
|
||||
<i class="material-icons" title="<?php echo _('Enlace a Wiki'); ?>">library_books</i>
|
||||
</a>
|
||||
<i class="material-icons fg-green80" title="<?php echo _('Ver en Wiki'); ?>" onClick="sysPassUtil.Common.viewWiki('<?php echo $account['name']; ?>',<?php echo \SP\Core\ActionsInterface::ACTION_WIKI_VIEW; ?>)">library_books</i>
|
||||
<i class="material-icons fg-green100" title="<?php echo _('Ver en Wiki'); ?>" onClick="sysPassUtil.Common.viewWiki('<?php echo $account['name']; ?>',<?php echo \SP\Core\ActionsInterface::ACTION_WIKI_VIEW; ?>)">library_books</i>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo $wikiPageUrl, $account['name']; ?>" target="_blank">
|
||||
<i class="material-icons" title="<?php echo _('Enlace a Wiki'); ?>">library_books</i>
|
||||
@@ -232,9 +232,6 @@
|
||||
<?php endif; ?>
|
||||
<script>
|
||||
$(function () {
|
||||
// Actualizar el token de seguridad
|
||||
$("#frmSearch :input[name='sk']").val('<?php echo $sk; ?>');
|
||||
|
||||
$('#data-search-header').find('.sort-down').each(function () {
|
||||
$(this).click(function () {
|
||||
var key = $(this).parent().data('key');
|
||||
|
||||
@@ -63,17 +63,20 @@
|
||||
sysPassUtil.Common.clearSearch(1);
|
||||
sysPassUtil.Common.accSearch(0, e)
|
||||
});
|
||||
|
||||
$('#frmSearch #btnClear').click(function (e) {
|
||||
sysPassUtil.Common.clearSearch();
|
||||
sysPassUtil.Common.accSearch(0, e);
|
||||
})
|
||||
});
|
||||
|
||||
$('#frmSearch input:text:visible:first').focus();
|
||||
$('#frmSearch #txtSearch').on('keyup', function (e) {
|
||||
sysPassUtil.Common.accSearch(1, e)
|
||||
});
|
||||
|
||||
$('#frmSearch #rpp').on('change', function (e) {
|
||||
sysPassUtil.Common.accSearch(0, e);
|
||||
})
|
||||
});
|
||||
|
||||
<?php if ( $showGlobalSearch ): ?>
|
||||
$('#chkgsearch').click(
|
||||
|
||||
@@ -223,12 +223,18 @@ sysPass.Util.Common = function () {
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'html',
|
||||
dataType: 'json',
|
||||
url: APP_ROOT + '/ajax/ajax_search.php',
|
||||
data: frmData,
|
||||
success: function (response) {
|
||||
$('#resBuscar').html(response);
|
||||
success: function (json) {
|
||||
$('#resBuscar').html(json.html);
|
||||
$('#resBuscar').css("max-height", $('html').height() - windowAdjustSize);
|
||||
|
||||
|
||||
if (typeof json.sk !== 'undefined') {
|
||||
// Actualizar el token de seguridad
|
||||
$("#frmSearch").find(":input[name='sk']").val(json.sk);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$('#resBuscar').html(resMsg("nofancyerror"));
|
||||
@@ -893,6 +899,35 @@ sysPass.Util.Common = function () {
|
||||
sendAjax(data, url);
|
||||
};
|
||||
|
||||
var appMgmtSearch = function (form, sk) {
|
||||
var data = $(form).serialize();
|
||||
var target = form.elements.target.value;
|
||||
|
||||
data = data + '&sk=' + sk;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
url: APP_ROOT + '/ajax/ajax_appMgmtSearch.php',
|
||||
data: data,
|
||||
success: function (json) {
|
||||
if (json.status === 0) {
|
||||
$('#' + target).html(json.html);
|
||||
} else {
|
||||
$('#' + target).html(resMsg('nofancyerror', json.description));
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$('#' + target).html(resMsg('nofancyerror', 'error'));
|
||||
},
|
||||
complete: function () {
|
||||
sysPassUtil.hideLoading();
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
// Función para crear un enlace público
|
||||
var linksMgmtSave = function (itemId, actionId, sk) {
|
||||
var url = '/ajax/ajax_appMgmtSave.php';
|
||||
@@ -1298,7 +1333,7 @@ sysPass.Util.Common = function () {
|
||||
// Función para mostrar los datos de un registro
|
||||
var viewWiki = function (pageName, actionId, sk) {
|
||||
|
||||
var data = {'pageName' : pageName, 'actionId': actionId, 'sk': sk, 'isAjax': 1};
|
||||
var data = {'pageName': pageName, 'actionId': actionId, 'sk': sk, 'isAjax': 1};
|
||||
var url = APP_ROOT + '/ajax/ajax_wiki.php';
|
||||
|
||||
$.ajax({
|
||||
@@ -1320,6 +1355,7 @@ sysPass.Util.Common = function () {
|
||||
accSearch: accSearch,
|
||||
appMgmtData: appMgmtData,
|
||||
appMgmtSave: appMgmtSave,
|
||||
appMgmtSearch: appMgmtSearch,
|
||||
appMgmtDelete: appMgmtDelete,
|
||||
checkboxDetect: checkboxDetect,
|
||||
checkDokuWikiConn: checkDokuWikiConn,
|
||||
|
||||
2
js/functions.min.js
vendored
2
js/functions.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user