mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-14 04:16:54 +01:00
* [ADD] New feature that allows to set global customers which would be displayed for all users.
This commit is contained in:
@@ -512,7 +512,9 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite
|
||||
|
||||
if (!$Acl->isShowViewPass()) {
|
||||
throw new ItemException(__('No tiene permisos para acceder a esta cuenta', false));
|
||||
} elseif (!UserPass::checkUserUpdateMPass(Session::getUserData()->getUserId())) {
|
||||
}
|
||||
|
||||
if (!UserPass::checkUserUpdateMPass(Session::getUserData()->getUserId())) {
|
||||
throw new ItemException(__('Clave maestra actualizada', false) . '<br>' . __('Reinicie la sesión para cambiarla', false));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class Upgrade
|
||||
/**
|
||||
* @var array Versiones actualizables
|
||||
*/
|
||||
private static $dbUpgrade = ['110', '112.1', '112.2', '112.3', '112.13', '112.19', '112.20', '120.01', '120.02', '130.16011001', '130.16100601', '200.17011302', '200.17011701', '210.17022601', '213.17031402'];
|
||||
private static $dbUpgrade = ['110', '112.1', '112.2', '112.3', '112.13', '112.19', '112.20', '120.01', '120.02', '130.16011001', '130.16100601', '200.17011302', '200.17011701', '210.17022601', '213.17031402', '220.17040501'];
|
||||
private static $cfgUpgrade = ['112.4', '130.16020501', '200.17011202'];
|
||||
private static $auxUpgrade = ['120.01', '120.02', '200.17010901', '200.17011202'];
|
||||
private static $appUpgrade = ['210.17022601'];
|
||||
|
||||
@@ -49,6 +49,10 @@ class CustomerData extends DataModelBase implements DataModelInterface
|
||||
* @var string
|
||||
*/
|
||||
public $customer_hash = '';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $customer_isGlobal = 0;
|
||||
|
||||
/**
|
||||
* CustomerData constructor.
|
||||
@@ -135,4 +139,20 @@ class CustomerData extends DataModelBase implements DataModelInterface
|
||||
{
|
||||
return $this->customer_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCustomerIsGlobal()
|
||||
{
|
||||
return (int)$this->customer_isGlobal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $customer_isGlobal
|
||||
*/
|
||||
public function setCustomerIsGlobal($customer_isGlobal)
|
||||
{
|
||||
$this->customer_isGlobal = (bool)$customer_isGlobal;
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,7 @@ class CustomerForm extends FormBase implements FormInterface
|
||||
$this->CustomerData->setCustomerId($this->itemId);
|
||||
$this->CustomerData->setCustomerName(Request::analyze('name'));
|
||||
$this->CustomerData->setCustomerDescription(Request::analyze('description'));
|
||||
$this->CustomerData->setCustomerIsGlobal(Request::analyze('isglobal', 0, false, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,12 +59,14 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
'INSERT INTO customers
|
||||
SET customer_name = ?,
|
||||
customer_description = ?,
|
||||
customer_isGlobal = ?,
|
||||
customer_hash = ?';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getCustomerName());
|
||||
$Data->addParam($this->itemData->getCustomerDescription());
|
||||
$Data->addParam($this->itemData->getCustomerIsGlobal());
|
||||
$Data->addParam($this->makeItemHash($this->itemData->getCustomerName()));
|
||||
$Data->setOnErrorMessage(__('Error al crear el cliente', false));
|
||||
|
||||
@@ -159,7 +161,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
public function getById($id)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT customer_id, customer_name, customer_description FROM customers WHERE customer_id = ? LIMIT 1';
|
||||
'SELECT customer_id, customer_name, customer_description, customer_isGlobal FROM customers WHERE customer_id = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
@@ -183,6 +185,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
'UPDATE customers
|
||||
SET customer_name = ?,
|
||||
customer_description = ?,
|
||||
customer_isGlobal = ?,
|
||||
customer_hash = ?
|
||||
WHERE customer_id = ? LIMIT 1';
|
||||
|
||||
@@ -190,6 +193,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getCustomerName());
|
||||
$Data->addParam($this->itemData->getCustomerDescription());
|
||||
$Data->addParam($this->itemData->getCustomerIsGlobal());
|
||||
$Data->addParam($this->makeItemHash($this->itemData->getCustomerName()));
|
||||
$Data->addParam($this->itemData->getCustomerId());
|
||||
$Data->setOnErrorMessage(__('Error al actualizar el cliente', false));
|
||||
@@ -225,7 +229,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
public function getAll()
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT customer_id, customer_name, customer_description FROM customers ORDER BY customer_name';
|
||||
'SELECT customer_id, customer_name, customer_description, customer_isGlobal FROM customers ORDER BY customer_name';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
@@ -250,7 +254,8 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
'SELECT customer_id as id, customer_name as name
|
||||
FROM accounts
|
||||
RIGHT JOIN customers ON customer_id = account_customerId
|
||||
WHERE account_customerId IS NULL
|
||||
WHERE account_customerId IS NULL
|
||||
OR customer_isGlobal = 1
|
||||
OR (' . implode(' AND ', $queryWhere) . ')
|
||||
GROUP BY customer_id
|
||||
ORDER BY customer_name';
|
||||
@@ -273,7 +278,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
}
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'SELECT customer_id, customer_name, customer_description FROM customers WHERE customer_id IN (' . $this->getParamsFromArray($ids) . ')';
|
||||
'SELECT customer_id, customer_name, customer_description, customer_isGlobal FROM customers WHERE customer_id IN (' . $this->getParamsFromArray($ids) . ')';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
|
||||
1
inc/sql/22017040501.sql
Normal file
1
inc/sql/22017040501.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE `customers` ADD `customer_isGlobal` BIT(1) DEFAULT b'0' NULL;
|
||||
@@ -17,6 +17,7 @@ CREATE TABLE `customers` (
|
||||
`customer_name` varchar(100) NOT NULL,
|
||||
`customer_hash` varbinary(40) NOT NULL,
|
||||
`customer_description` varchar(255) DEFAULT NULL,
|
||||
`customer_isGlobal` bit DEFAULT b'0',
|
||||
PRIMARY KEY (`customer_id`),
|
||||
KEY `IDX_name` (`customer_name`,`customer_hash`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@@ -29,7 +30,7 @@ CREATE TABLE `categories` (
|
||||
`category_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`category_name` varchar(50) NOT NULL,
|
||||
`category_hash` varbinary(40) NOT NULL,
|
||||
`category_description` varchar(255) DEFAULT NULL,
|
||||
`category_description` varchar(255) DEFAULT NULL
|
||||
PRIMARY KEY (`category_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
@@ -41,6 +41,29 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="descField">
|
||||
<div id="help-isglobal"
|
||||
class="icon material-icons <?php echo $icons->getIconHelp()->getClass(); ?>"><?php echo $icons->getIconHelp()->getIcon(); ?></div>
|
||||
<div class="mdl-tooltip mdl-tooltip--large" for="help-isglobal">
|
||||
<p>
|
||||
<?php echo __('Indica si el cliente es visible para todos los usuarios.'); ?>
|
||||
</p>
|
||||
<p>
|
||||
<?php echo __('Por defecto los clientes asignados a cuentas sólo son visibles para los usuarios con acceso a las cuentas.'); ?>
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="valField">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="isglobal">
|
||||
<input type="checkbox" id="isglobal"
|
||||
class="mdl-switch__input mdl-color-text--indigo-400"
|
||||
name="isglobal" <?php echo $customer->getCustomerIsGlobal() ? 'checked' : ' '; ?>/>
|
||||
<span class="mdl-switch__label"><?php echo __('Global'); ?></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if ($customFields): ?>
|
||||
<?php include $this->includeTemplate('aux-customfields', 'common'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user