mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-06 08:34:16 +01:00
* [MOD] Code refactoring for better response times
* [FIX] Fixes #484. LDAP logins will be case-insensitive. Thanks to @basil-twisleton
This commit is contained in:
@@ -40,7 +40,7 @@ define('LOCALES_PATH', __DIR__ . DIRECTORY_SEPARATOR . 'locales');
|
||||
define('SQL_PATH', __DIR__ . DIRECTORY_SEPARATOR . 'sql');
|
||||
define('LOG_FILE', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'syspass.log');
|
||||
|
||||
define('DEBUG', false);
|
||||
define('DEBUG', true);
|
||||
|
||||
// Required random_compat polyfill for random_bytes() and random_int()
|
||||
// @see https://github.com/paragonie/random_compat/tree/v2.0.4#random_compat
|
||||
|
||||
@@ -29,7 +29,7 @@ use SP\Core\Events\EventDispatcherInterface;
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\Core\UI\Theme;
|
||||
use SP\Core\UI\ThemeInterface;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Storage\DBStorageInterface;
|
||||
use SP\Storage\FileStorageInterface;
|
||||
use SP\Storage\MySQLHandler;
|
||||
@@ -51,7 +51,7 @@ class DiFactory
|
||||
*/
|
||||
private static $DBFactory;
|
||||
/**
|
||||
* @var ItemBase[]
|
||||
* @var ItemBaseInterface[]
|
||||
*/
|
||||
private static $ItemFactory = [];
|
||||
/**
|
||||
@@ -96,22 +96,24 @@ class DiFactory
|
||||
*
|
||||
* @param string $caller La clase del objeto
|
||||
* @param mixed $itemData Los datos del elemento
|
||||
* @return ItemBase
|
||||
* @return ItemBaseInterface
|
||||
*/
|
||||
public static final function getItem($caller, $itemData = null)
|
||||
{
|
||||
// error_log(count(self::$ItemFactory) . '-' . (memory_get_usage() / 1000));
|
||||
|
||||
try {
|
||||
if (isset(self::$ItemFactory[$caller])) {
|
||||
return (null !== $itemData) ? self::$ItemFactory[$caller]->setItemData($itemData) : self::$ItemFactory[$caller];
|
||||
if (!isset(self::$ItemFactory[$caller])) {
|
||||
self::$ItemFactory[$caller] = new $caller($itemData);
|
||||
|
||||
return self::$ItemFactory[$caller];
|
||||
}
|
||||
|
||||
return (null !== $itemData) ? self::$ItemFactory[$caller]->setItemData($itemData) : self::$ItemFactory[$caller];
|
||||
} catch (InvalidClassException $e) {
|
||||
debugLog('Invalid class for item data: ' . $e->getMessage(), true);
|
||||
}
|
||||
|
||||
self::$ItemFactory[$caller] = new $caller($itemData);
|
||||
|
||||
return self::$ItemFactory[$caller];
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ use SP\Util\Util;
|
||||
* Class ApiToken
|
||||
*
|
||||
* @package SP\Mgmt\ApiTokens
|
||||
* @property ApiTokenData $itemData
|
||||
*/
|
||||
class ApiToken extends ApiTokenBase implements ItemInterface
|
||||
{
|
||||
|
||||
@@ -26,41 +26,28 @@ namespace SP\Mgmt\ApiTokens;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\ApiTokenData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class ApiTokensBase
|
||||
*
|
||||
* @package SP\Mgmt\ApiTokens
|
||||
*/
|
||||
abstract class ApiTokenBase extends ItemBase
|
||||
abstract class ApiTokenBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var ApiTokenData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* ApiTokensBase constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(ApiTokenData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver los datos del elemento
|
||||
*
|
||||
* @return ApiTokenData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(ApiTokenData::class);
|
||||
}
|
||||
}
|
||||
@@ -27,21 +27,18 @@ namespace SP\Mgmt\Categories;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\DataModel\CustomFieldData;
|
||||
use SP\Log\Log;
|
||||
use SP\Mgmt\CustomFields\CustomField;
|
||||
use SP\Mgmt\ItemInterface;
|
||||
use SP\Mgmt\ItemSelectInterface;
|
||||
use SP\Mgmt\ItemTrait;
|
||||
use SP\Storage\DB;
|
||||
use SP\Storage\QueryData;
|
||||
|
||||
|
||||
/**
|
||||
* Esta clase es la encargada de realizar las operaciones sobre las categorías de sysPass.
|
||||
*
|
||||
* @property CategoryData $itemData
|
||||
*/
|
||||
class Category extends CategoryBase implements ItemInterface, ItemSelectInterface
|
||||
{
|
||||
|
||||
@@ -26,40 +26,28 @@ namespace SP\Mgmt\Categories;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class CategoryBase
|
||||
*
|
||||
* @package SP\Mgmt\Categories
|
||||
*/
|
||||
abstract class CategoryBase extends ItemBase
|
||||
abstract class CategoryBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var CategoryData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(CategoryData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver los datos del elemento
|
||||
* @return CategoryData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(CategoryData::class);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -40,34 +40,11 @@ use SP\Util\Util;
|
||||
/**
|
||||
* Class CustomFields para la gestión de campos personalizados de los módulos
|
||||
*
|
||||
* @package SP
|
||||
* @package SP\Mgmt\CustomFields
|
||||
* @property CustomFieldData $itemData
|
||||
*/
|
||||
class CustomField extends CustomFieldBase implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* @param CustomFieldData $itemData
|
||||
* @param int $customFieldDefId
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData, $customFieldDefId = null)
|
||||
{
|
||||
$this->setDataModel(CustomFieldData::class);
|
||||
|
||||
parent::__construct($itemData);
|
||||
|
||||
if (null !== $customFieldDefId) {
|
||||
$field = CustomFieldDef::getItem()->getById($customFieldDefId);
|
||||
|
||||
$itemData->setDefinitionId($customFieldDefId);
|
||||
$itemData->setModule($field->getModule());
|
||||
$itemData->setName($field->getName());
|
||||
$itemData->setType($field->getType());
|
||||
}
|
||||
|
||||
$this->itemData = $itemData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
@@ -381,4 +358,15 @@ class CustomField extends CustomFieldBase implements ItemInterface
|
||||
{
|
||||
// TODO: Implement getByIdBatch() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @return void
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
$this->setDataModel(CustomFieldData::class);
|
||||
}
|
||||
}
|
||||
@@ -26,42 +26,15 @@ namespace SP\Mgmt\CustomFields;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\DataModel\CustomFieldBaseData;
|
||||
use SP\DataModel\CustomFieldData;
|
||||
use SP\DataModel\CustomFieldDefData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class CustomFieldsBase para la definición de campos personalizados
|
||||
*
|
||||
* @package SP
|
||||
*/
|
||||
abstract class CustomFieldBase extends ItemBase
|
||||
abstract class CustomFieldBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var CustomFieldBaseData|CustomFieldDefData|CustomFieldData */
|
||||
protected $itemData;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
*
|
||||
* @param CustomFieldBaseData $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(CustomFieldBaseData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver los datos del elemento
|
||||
* @return CustomFieldBaseData|CustomFieldDefData|CustomFieldData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
}
|
||||
use ItemBaseTrait;
|
||||
}
|
||||
@@ -38,24 +38,12 @@ use SP\Util\Util;
|
||||
* Class CustomFieldDef para la gestión de definiciones de campos personalizados
|
||||
*
|
||||
* @package SP
|
||||
* @property CustomFieldDefData $itemData
|
||||
*/
|
||||
class CustomFieldDef extends CustomFieldBase implements ItemInterface
|
||||
{
|
||||
use ItemTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
*
|
||||
* @param CustomFieldDefData $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
{
|
||||
$this->setDataModel(CustomFieldDefData::class);
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
@@ -287,4 +275,15 @@ class CustomFieldDef extends CustomFieldBase implements ItemInterface
|
||||
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @return void
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
$this->setDataModel(CustomFieldDefData::class);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -40,18 +40,6 @@ use SP\Util\Util;
|
||||
*/
|
||||
class CustomFieldDefSearch extends CustomFieldBase implements ItemSearchInterface
|
||||
{
|
||||
/**
|
||||
* Category constructor.
|
||||
*
|
||||
* @param CustomFieldDefData $itemData
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
{
|
||||
$this->setDataModel('SP\DataModel\CustomFieldDefData');
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ItemSearchData $SearchData
|
||||
* @return array|\SP\DataModel\CustomFieldDefData[]
|
||||
@@ -95,4 +83,15 @@ class CustomFieldDefSearch extends CustomFieldBase implements ItemSearchInterfac
|
||||
|
||||
return $customFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @return void
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
$this->setDataModel(CustomFieldDefData::class);
|
||||
}
|
||||
}
|
||||
@@ -28,13 +28,8 @@ namespace SP\Mgmt\Customers;
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Account\AccountUtil;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Core\Session;
|
||||
use SP\DataModel\CustomerData;
|
||||
use SP\DataModel\CustomFieldData;
|
||||
use SP\Log\Log;
|
||||
use SP\Mgmt\CustomFields\CustomField;
|
||||
use SP\Mgmt\ItemInterface;
|
||||
use SP\Mgmt\ItemSelectInterface;
|
||||
use SP\Mgmt\ItemTrait;
|
||||
@@ -43,6 +38,8 @@ use SP\Storage\QueryData;
|
||||
|
||||
/**
|
||||
* Esta clase es la encargada de realizar las operaciones sobre los clientes de sysPass
|
||||
*
|
||||
* @property CustomerData $itemData
|
||||
*/
|
||||
class Customer extends CustomerBase implements ItemInterface, ItemSelectInterface
|
||||
{
|
||||
|
||||
@@ -26,41 +26,28 @@ namespace SP\Mgmt\Customers;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\CustomerData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class CustomerBase
|
||||
*
|
||||
* @package SP\Mgmt\Customers
|
||||
*/
|
||||
abstract class CustomerBase extends ItemBase
|
||||
abstract class CustomerBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var CustomerData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(CustomerData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver los datos del elemento
|
||||
*
|
||||
* @return CustomerData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(CustomerData::class);
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,8 @@ defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
* Esta clase es la encargada de realizar operaciones con archivos de las cuentas de sysPass
|
||||
*
|
||||
* @property FileData $itemData
|
||||
*/
|
||||
class File extends FileBase implements ItemInterface, ItemSelectInterface
|
||||
{
|
||||
|
||||
@@ -24,40 +24,28 @@
|
||||
|
||||
namespace SP\Mgmt\Files;
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\FileData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class FileBase
|
||||
*
|
||||
* @package SP\Mgmt\Files
|
||||
*/
|
||||
abstract class FileBase extends ItemBase
|
||||
abstract class FileBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var FileData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param FileData $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(FileData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver los datos del elemento
|
||||
* @return FileData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(FileData::class);
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ namespace SP\Mgmt\Groups;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\GroupData;
|
||||
use SP\DataModel\GroupUsersData;
|
||||
use SP\Log\Log;
|
||||
use SP\Mgmt\ItemInterface;
|
||||
use SP\Mgmt\ItemSelectInterface;
|
||||
use SP\Mgmt\ItemTrait;
|
||||
@@ -39,6 +38,8 @@ defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
* Esta clase es la encargada de realizar las operaciones sobre los grupos de usuarios.
|
||||
*
|
||||
* @property GroupData $itemData
|
||||
*/
|
||||
class Group extends GroupBase implements ItemInterface, ItemSelectInterface
|
||||
{
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace SP\Mgmt\Groups;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\GroupAccountsData;
|
||||
use SP\Mgmt\ItemInterface;
|
||||
use SP\Mgmt\ItemTrait;
|
||||
@@ -37,6 +36,7 @@ use SP\Storage\QueryData;
|
||||
* Class GroupAccounts
|
||||
*
|
||||
* @package SP\Mgmt\Groups
|
||||
* @property GroupAccountsData $itemData
|
||||
*/
|
||||
class GroupAccounts extends GroupAccountsBase implements ItemInterface
|
||||
{
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
|
||||
namespace SP\Mgmt\Groups;
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\GroupAccountsData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
@@ -34,30 +36,18 @@ defined('APP_ROOT') || die();
|
||||
*
|
||||
* @package SP\Mgmt\Groups
|
||||
*/
|
||||
abstract class GroupAccountsBase extends ItemBase
|
||||
abstract class GroupAccountsBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var GroupAccountsData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param GroupAccountsData $itemData
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel('SP\DataModel\GroupAccountsData');
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GroupAccountsData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(GroupAccountsData::class);
|
||||
}
|
||||
}
|
||||
@@ -24,39 +24,28 @@
|
||||
|
||||
namespace SP\Mgmt\Groups;
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\GroupData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class GroupBase
|
||||
*
|
||||
* @package SP\Mgmt\Groups
|
||||
*/
|
||||
abstract class GroupBase extends ItemBase
|
||||
abstract class GroupBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var GroupData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param GroupData $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(GroupData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GroupData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(GroupData::class);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -38,6 +38,7 @@ use SP\Storage\QueryData;
|
||||
* Class GroupUser
|
||||
*
|
||||
* @package SP\Mgmt\Groups
|
||||
* @property GroupUsersData $itemData
|
||||
*/
|
||||
class GroupUsers extends GroupUsersBase implements ItemInterface, ItemSelectInterface
|
||||
{
|
||||
@@ -45,30 +46,12 @@ class GroupUsers extends GroupUsersBase implements ItemInterface, ItemSelectInte
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws SPException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function add()
|
||||
public function update()
|
||||
{
|
||||
if (!is_array($this->itemData->getUsers())
|
||||
|| count($this->itemData->getUsers()) === 0
|
||||
) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'INSERT INTO usrToGroups (usertogroup_userId, usertogroup_groupId) VALUES ' . $this->getParamsFromArray($this->itemData->getUsers(), '(?,?)');
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
foreach ($this->itemData->getUsers() as $user){
|
||||
$Data->addParam($user);
|
||||
$Data->addParam($this->itemData->getUsertogroupGroupId());
|
||||
}
|
||||
|
||||
$Data->setOnErrorMessage(__('Error al asignar los usuarios al grupo', false));
|
||||
|
||||
DB::getQuery($Data);
|
||||
$this->delete($this->itemData->getUsertogroupGroupId());
|
||||
$this->add();
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -95,12 +78,30 @@ class GroupUsers extends GroupUsersBase implements ItemInterface, ItemSelectInte
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @throws SPException
|
||||
*/
|
||||
public function update()
|
||||
public function add()
|
||||
{
|
||||
$this->delete($this->itemData->getUsertogroupGroupId());
|
||||
$this->add();
|
||||
if (!is_array($this->itemData->getUsers())
|
||||
|| count($this->itemData->getUsers()) === 0
|
||||
) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$query = /** @lang SQL */
|
||||
'INSERT INTO usrToGroups (usertogroup_userId, usertogroup_groupId) VALUES ' . $this->getParamsFromArray($this->itemData->getUsers(), '(?,?)');
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
foreach ($this->itemData->getUsers() as $user) {
|
||||
$Data->addParam($user);
|
||||
$Data->addParam($this->itemData->getUsertogroupGroupId());
|
||||
}
|
||||
|
||||
$Data->setOnErrorMessage(__('Error al asignar los usuarios al grupo', false));
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -24,39 +24,28 @@
|
||||
|
||||
namespace SP\Mgmt\Groups;
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\GroupUsersData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class GroupUserBase
|
||||
*
|
||||
* @package SP\Mgmt\Groups
|
||||
*/
|
||||
abstract class GroupUsersBase extends ItemBase
|
||||
abstract class GroupUsersBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var GroupUsersData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param GroupUsersData $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(GroupUsersData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GroupUsersData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(GroupUsersData::class);
|
||||
}
|
||||
}
|
||||
73
inc/SP/Mgmt/ItemBaseInterface.class.php
Normal file
73
inc/SP/Mgmt/ItemBaseInterface.class.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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;
|
||||
|
||||
use SP\DataModel\DataModelInterface;
|
||||
|
||||
/**
|
||||
* Interface ItemBaseInterface
|
||||
*
|
||||
* @package SP\Mgmt
|
||||
*/
|
||||
interface ItemBaseInterface
|
||||
{
|
||||
/**
|
||||
* Devolver la instancia almacenada de la clase. Si no existe, se crea
|
||||
*
|
||||
* @param $itemData
|
||||
* @return static
|
||||
*/
|
||||
public static function getItem($itemData = null);
|
||||
|
||||
/**
|
||||
* Devolver una nueva instancia de la clase
|
||||
*
|
||||
* @param null $itemData
|
||||
* @return static
|
||||
*/
|
||||
public static function getNewItem($itemData = null);
|
||||
|
||||
/**
|
||||
* Devolver los datos del elemento
|
||||
*
|
||||
* @return mixed|DataModelInterface
|
||||
*/
|
||||
public function getItemData();
|
||||
|
||||
/**
|
||||
* Establecer los datos del elemento
|
||||
*
|
||||
* @param mixed|DataModelInterface $itemData
|
||||
* @return static
|
||||
*/
|
||||
public function setItemData($itemData);
|
||||
|
||||
/**
|
||||
* Obtener el nombre de la clase para el modelo de datos
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataModel();
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -30,11 +30,11 @@ use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\DataModelInterface;
|
||||
|
||||
/**
|
||||
* Class ItemBase
|
||||
* Class ItemBaseTrait
|
||||
*
|
||||
* @package SP\Mgmt
|
||||
*/
|
||||
abstract class ItemBase
|
||||
trait ItemBaseTrait
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@@ -53,6 +53,8 @@ abstract class ItemBase
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
{
|
||||
$this->init();
|
||||
|
||||
if (null !== $itemData) {
|
||||
$this->setItemData($itemData);
|
||||
} else {
|
||||
@@ -100,7 +102,7 @@ abstract class ItemBase
|
||||
*/
|
||||
public final function setItemData($itemData)
|
||||
{
|
||||
if (null !== $this->dataModel && !$itemData instanceof $this->dataModel) {
|
||||
if (null !== $this->dataModel && ($itemData instanceof $this->dataModel) === false) {
|
||||
throw new InvalidClassException(SPException::SP_ERROR, $this->dataModel);
|
||||
}
|
||||
|
||||
@@ -119,17 +121,24 @@ abstract class ItemBase
|
||||
|
||||
/**
|
||||
* @param string $dataModel
|
||||
* @return $this
|
||||
* @return static
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
protected final function setDataModel($dataModel)
|
||||
{
|
||||
if (false === class_exists($dataModel)) {
|
||||
throw new InvalidClassException($dataModel);
|
||||
throw new InvalidClassException(SPException::SP_ERROR, $dataModel);
|
||||
}
|
||||
|
||||
$this->dataModel = $dataModel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected abstract function init();
|
||||
}
|
||||
@@ -36,6 +36,7 @@ use SP\Storage\QueryData;
|
||||
* Class Notice
|
||||
*
|
||||
* @package SP\Mgmt\Notices
|
||||
* @property NoticeData $itemData
|
||||
*/
|
||||
class Notice extends NoticeBase implements ItemInterface
|
||||
{
|
||||
|
||||
@@ -26,40 +26,28 @@ namespace SP\Mgmt\Notices;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\NoticeData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class NoticeBase
|
||||
*
|
||||
* @package SP\Mgmt\Notices
|
||||
*/
|
||||
abstract class NoticeBase extends ItemBase
|
||||
abstract class NoticeBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var NoticeData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Notice constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(NoticeData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver los datos del elemento
|
||||
* @return NoticeData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(NoticeData::class);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ use SP\Storage\QueryData;
|
||||
* Class Plugin
|
||||
*
|
||||
* @package SP\Mgmt\Plugins
|
||||
* @property PluginData $itemData
|
||||
*/
|
||||
class Plugin extends PluginBase implements ItemInterface
|
||||
{
|
||||
|
||||
@@ -26,40 +26,28 @@ namespace SP\Mgmt\Plugins;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\PluginData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class CategoryBase
|
||||
*
|
||||
* @package SP\Mgmt\Categories
|
||||
*/
|
||||
abstract class PluginBase extends ItemBase
|
||||
abstract class PluginBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var PluginData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Plugin constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(PluginData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver los datos del elemento
|
||||
* @return PluginData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(PluginData::class);
|
||||
}
|
||||
}
|
||||
@@ -38,9 +38,10 @@ use SP\Storage\DB;
|
||||
use SP\Storage\QueryData;
|
||||
use SP\Util\Util;
|
||||
|
||||
|
||||
/**
|
||||
* Esta clase es la encargada de realizar las operaciones sobre los perfiles de usuarios.
|
||||
*
|
||||
* @property ProfileData $itemData
|
||||
*/
|
||||
class Profile extends ProfileBase implements ItemInterface, ItemSelectInterface
|
||||
{
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
|
||||
namespace SP\Mgmt\Profiles;
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\ProfileData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
@@ -34,31 +36,18 @@ defined('APP_ROOT') || die();
|
||||
*
|
||||
* @package SP
|
||||
*/
|
||||
abstract class ProfileBase extends ItemBase
|
||||
abstract class ProfileBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var ProfileData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param ProfileData $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(ProfileData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ProfileData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(ProfileData::class);
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ defined('APP_ROOT') || die();
|
||||
* Class PublicLink para la creación de enlaces públicos
|
||||
*
|
||||
* @package SP
|
||||
* @property PublicLinkBaseData $itemData
|
||||
*/
|
||||
class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
{
|
||||
|
||||
@@ -30,43 +30,32 @@ use SP\Account\Account;
|
||||
use SP\Config\Config;
|
||||
use SP\Core\Crypt\Crypt;
|
||||
use SP\Core\Crypt\Session as CryptSession;
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\AccountExtData;
|
||||
use SP\DataModel\PublicLinkData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\DataModel\PublicLinkBaseData;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class PublicLinks para la gestión de enlaces públicos
|
||||
*
|
||||
* @package SP
|
||||
* @property PublicLinkBaseData $itemData
|
||||
*/
|
||||
abstract class PublicLinkBase extends ItemBase
|
||||
abstract class PublicLinkBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var PublicLinkData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param PublicLinkData $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(PublicLinkBaseData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PublicLinkData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(PublicLinkBaseData::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,6 +75,26 @@ abstract class PublicLinkBase extends ItemBase
|
||||
$this->itemData->setPassIV($securedKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generar el hash para el enlace
|
||||
*
|
||||
* @param bool $refresh Si es necesario regenerar el hash
|
||||
* @return string
|
||||
*/
|
||||
protected final function createLinkHash($refresh = false)
|
||||
{
|
||||
if ($refresh === true
|
||||
|| $this->itemData->getLinkHash() === ''
|
||||
) {
|
||||
$hash = hash('sha256', uniqid('sysPassPublicLink', true));
|
||||
|
||||
$this->itemData->setPublicLinkHash($hash);
|
||||
$this->itemData->setLinkHash($hash);
|
||||
}
|
||||
|
||||
return $this->itemData->getLinkHash();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos de una cuenta y encriptarlos para el enlace
|
||||
*
|
||||
@@ -113,30 +122,8 @@ abstract class PublicLinkBase extends ItemBase
|
||||
$this->itemData->setPassIV($linkSecuredKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generar el hash para el enlace
|
||||
*
|
||||
* @param bool $refresh Si es necesario regenerar el hash
|
||||
* @return string
|
||||
*/
|
||||
protected final function createLinkHash($refresh = false)
|
||||
{
|
||||
if ($refresh === true
|
||||
|| $this->itemData->getLinkHash() === ''
|
||||
) {
|
||||
$hash = hash('sha256', uniqid('sysPassPublicLink', true));
|
||||
|
||||
$this->itemData->setPublicLinkHash($hash);
|
||||
$this->itemData->setLinkHash($hash);
|
||||
}
|
||||
|
||||
return $this->itemData->getLinkHash();
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el tiempo de caducidad del enlace
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected final function calcDateExpire()
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@ use SP\Storage\QueryData;
|
||||
* Class Tags
|
||||
*
|
||||
* @package SP\Mgmt\Tags
|
||||
* @property TagData $itemData
|
||||
*/
|
||||
class Tag extends TagBase implements ItemInterface, ItemSelectInterface
|
||||
{
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
|
||||
namespace SP\Mgmt\Tags;
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\TagData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
@@ -34,31 +36,18 @@ defined('APP_ROOT') || die();
|
||||
*
|
||||
* @package SP\Mgmt\Tags
|
||||
*/
|
||||
class TagBase extends ItemBase
|
||||
class TagBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var TagData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param TagData $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(TagData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TagData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(TagData::class);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
namespace SP\Mgmt\Tracks;
|
||||
|
||||
use SP\DataModel\TrackData;
|
||||
use SP\Mgmt\ItemInterface;
|
||||
use SP\Storage\DB;
|
||||
use SP\Storage\QueryData;
|
||||
@@ -32,6 +33,7 @@ use SP\Storage\QueryData;
|
||||
* Class Track
|
||||
*
|
||||
* @package SP\Mgmt\Tracks
|
||||
* @property TrackData $itemData
|
||||
*/
|
||||
class Track extends TrackBase implements ItemInterface
|
||||
{
|
||||
|
||||
@@ -26,40 +26,28 @@ namespace SP\Mgmt\Tracks;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\TrackData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class TrackBase
|
||||
*
|
||||
* @package SP\Mgmt\Tracks
|
||||
*/
|
||||
abstract class TrackBase extends ItemBase
|
||||
abstract class TrackBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var TrackData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Track constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(TrackData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver los datos del elemento
|
||||
* @return TrackData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(TrackData::class);
|
||||
}
|
||||
}
|
||||
@@ -26,39 +26,29 @@ namespace SP\Mgmt\Users;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\UserData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class UserBase
|
||||
*
|
||||
* @package SP
|
||||
* @property UserData $itemdata
|
||||
*/
|
||||
abstract class UserBase extends ItemBase
|
||||
abstract class UserBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var UserData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param UserData $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(UserData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(UserData::class);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,6 @@ use SP\Core\Exceptions\SPException;
|
||||
use SP\Core\Messages\LogMessage;
|
||||
use SP\Log\Email;
|
||||
use SP\Log\Log;
|
||||
use SP\Mgmt\ItemInterface;
|
||||
use SP\Storage\DB;
|
||||
use SP\Storage\QueryData;
|
||||
|
||||
@@ -41,7 +40,7 @@ defined('APP_ROOT') || die();
|
||||
*
|
||||
* @package SP
|
||||
*/
|
||||
class UserLdap extends UserBase implements ItemInterface
|
||||
class UserLdap extends User
|
||||
{
|
||||
/**
|
||||
* Comprobar si los datos del usuario de LDAP están en la BBDD.
|
||||
@@ -54,7 +53,7 @@ class UserLdap extends UserBase implements ItemInterface
|
||||
public static function checkLDAPUserInDB($userLogin)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT user_login FROM usrData WHERE user_login = ? LIMIT 1';
|
||||
'SELECT user_login FROM usrData WHERE LOWER(user_login) = LOWER(?) LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
@@ -149,7 +148,7 @@ class UserLdap extends UserBase implements ItemInterface
|
||||
$query = /** @lang SQL */
|
||||
'SELECT user_login, user_email
|
||||
FROM usrData
|
||||
WHERE UPPER(user_login) = UPPER(?) OR UPPER(user_email) = UPPER(?)';
|
||||
WHERE LOWER(user_login) = LOWER(?) OR LOWER(user_email) = LOWER(?)';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
@@ -161,15 +160,6 @@ class UserLdap extends UserBase implements ItemInterface
|
||||
return $Data->getQueryNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
// TODO: Implement delete() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
@@ -183,7 +173,7 @@ class UserLdap extends UserBase implements ItemInterface
|
||||
user_email = ?,
|
||||
user_lastUpdate = NOW(),
|
||||
user_isLdap = 1
|
||||
WHERE user_login = ? LIMIT 1';
|
||||
WHERE LOWER(user_login) = LOWER(?) LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
@@ -199,58 +189,31 @@ class UserLdap extends UserBase implements ItemInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return mixed
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
// TODO: Implement getById() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
// TODO: Implement getAll() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return mixed
|
||||
*/
|
||||
public function checkInUse($id)
|
||||
{
|
||||
// TODO: Implement checkInUse() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkDuplicatedOnUpdate()
|
||||
{
|
||||
// TODO: Implement checkDuplicatedOnUpdate() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminar elementos en lote
|
||||
*
|
||||
* @param array $ids
|
||||
* @return $this
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function deleteBatch(array $ids)
|
||||
public function updateOnLogin()
|
||||
{
|
||||
// TODO: Implement deleteBatch() method.
|
||||
}
|
||||
$query = 'UPDATE usrData SET
|
||||
user_pass = ?,
|
||||
user_hashSalt = \'\',
|
||||
user_name = ?,
|
||||
user_email = ?,
|
||||
user_lastUpdate = NOW(),
|
||||
user_lastLogin = NOW(),
|
||||
user_isLdap = 1
|
||||
WHERE LOWER(user_login) = LOWER(?) LIMIT 1';
|
||||
|
||||
/**
|
||||
* Devolver los elementos con los ids especificados
|
||||
*
|
||||
* @param array $ids
|
||||
* @return mixed
|
||||
*/
|
||||
public function getByIdBatch(array $ids)
|
||||
{
|
||||
// TODO: Implement getByIdBatch() method.
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(Hash::hashKey($this->itemData->getUserPass()));
|
||||
$Data->addParam($this->itemData->getUserName());
|
||||
$Data->addParam($this->itemData->getUserEmail());
|
||||
$Data->addParam($this->itemData->getUserLogin());
|
||||
$Data->setOnErrorMessage(__('Error al actualizar la clave del usuario en la BBDD', false));
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,11 @@ use SP\DataModel\UserData;
|
||||
use SP\Log\Log;
|
||||
use SP\Util\Util;
|
||||
|
||||
/**
|
||||
* Class UserLdapSync
|
||||
*
|
||||
* @package SP\Mgmt\Users
|
||||
*/
|
||||
class UserLdapSync
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,6 @@ defined('APP_ROOT') || die();
|
||||
use SP\Core\Crypt\Hash;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\GroupUsersData;
|
||||
use SP\DataModel\UserData;
|
||||
use SP\DataModel\UserLoginData;
|
||||
use SP\Log\Email;
|
||||
use SP\Log\Log;
|
||||
|
||||
@@ -32,6 +32,7 @@ use SP\Config\ConfigDB;
|
||||
use SP\Controller\LoginController;
|
||||
use SP\Core\Crypt\Crypt;
|
||||
use SP\Core\Crypt\Hash;
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\Core\Exceptions\QueryException;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Core\Upgrade\User as UpgradeUser;
|
||||
@@ -48,19 +49,21 @@ use SP\Core\Crypt\Session as CryptSession;
|
||||
* Class UserPass para la gestión de las claves de un usuario
|
||||
*
|
||||
* @package SP
|
||||
* @property UserPassData $itemData
|
||||
*/
|
||||
class UserPass extends UserBase
|
||||
{
|
||||
// La clave maestra incorrecta
|
||||
const MPASS_WRONG = 0;
|
||||
// La clave maestra correcta
|
||||
|
||||
// La clave maestra incorrecta
|
||||
const MPASS_OK = 1;
|
||||
// La clave maestra no está guardada
|
||||
// La clave maestra correcta
|
||||
const MPASS_NOTSET = 2;
|
||||
// La clave maestra ha cambiado
|
||||
// La clave maestra no está guardada
|
||||
const MPASS_CHANGED = 3;
|
||||
// Comprobar la clave maestra con la calve del usuario anterior
|
||||
// La clave maestra ha cambiado
|
||||
const MPASS_CHECKOLD = 4;
|
||||
// Comprobar la clave maestra con la calve del usuario anterior
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
@@ -70,19 +73,6 @@ class UserPass extends UserBase
|
||||
*/
|
||||
private static $clearUserMPass = '';
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
*
|
||||
* @param UserPassData $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
{
|
||||
$this->setDataModel(UserPassData::class);
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el IV del usuario a partir del Id.
|
||||
*
|
||||
@@ -334,4 +324,15 @@ class UserPass extends UserBase
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
$this->setDataModel(UserPassData::class);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ defined('APP_ROOT') || die();
|
||||
* Class UserPassRecover para la gestión de recuperaciones de claves de usuarios
|
||||
*
|
||||
* @package SP
|
||||
* @property UserPassRecoverData $itemData
|
||||
*/
|
||||
class UserPassRecover extends UserPassRecoverBase implements ItemInterface
|
||||
{
|
||||
|
||||
@@ -26,36 +26,28 @@ namespace SP\Mgmt\Users;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\UserPassRecoverData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class UserPassRecoverBase
|
||||
*
|
||||
* @package SP\Mgmt\Users
|
||||
*/
|
||||
abstract class UserPassRecoverBase extends ItemBase
|
||||
abstract class UserPassRecoverBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var UserPassRecoverData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param UserPassRecoverData $itemData
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
$this->setDataModel('SP\DataModel\UserPassRecoverData');
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserPassRecoverData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(UserPassRecoverData::class);
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ use SP\Util\Util;
|
||||
* Class UsersPreferences para la gestion de las preferencias de usuarios
|
||||
*
|
||||
* @package SP
|
||||
* @property UserPreferencesData $itemData
|
||||
*/
|
||||
class UserPreferences extends UserPreferencesBase implements ItemInterface
|
||||
{
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -26,39 +26,28 @@ namespace SP\Mgmt\Users;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\Exceptions\InvalidClassException;
|
||||
use SP\DataModel\UserPreferencesData;
|
||||
use SP\Mgmt\ItemBase;
|
||||
use SP\Mgmt\ItemBaseInterface;
|
||||
use SP\Mgmt\ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Class UserPreferencesBase
|
||||
*
|
||||
* @package SP\Mgmt\Users
|
||||
*/
|
||||
abstract class UserPreferencesBase extends ItemBase
|
||||
abstract class UserPreferencesBase implements ItemBaseInterface
|
||||
{
|
||||
/** @var UserPreferencesData */
|
||||
protected $itemData;
|
||||
use ItemBaseTrait;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
* Inicializar la clase
|
||||
*
|
||||
* @param UserPreferencesData $itemData
|
||||
* @throws \SP\Core\Exceptions\InvalidClassException
|
||||
* @return void
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
public function __construct($itemData = null)
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel(UserPreferencesData::class);
|
||||
}
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserPreferencesData
|
||||
*/
|
||||
public function getItemData()
|
||||
{
|
||||
return parent::getItemData();
|
||||
$this->setDataModel(UserPreferencesData::class);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,9 @@ class UserUtil
|
||||
public static function checkUserMail(UserData $UserData)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT user_id FROM usrData WHERE user_login = ? AND user_email = ? LIMIT 1';
|
||||
'SELECT user_id FROM usrData
|
||||
WHERE LOWER(user_login) = LOWER(?)
|
||||
AND LOWER(user_email) = LOWER(?) LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
2
inc/themes/material-blue/css/styles.min.css
vendored
2
inc/themes/material-blue/css/styles.min.css
vendored
File diff suppressed because one or more lines are too long
2
js/app-requests.min.js
vendored
2
js/app-requests.min.js
vendored
@@ -1,5 +1,5 @@
|
||||
var $jscomp={scope:{},checkStringArgs:function(b,d,c){if(null==b)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(d instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return b+""}};
|
||||
$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(b,d,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");b!=Array.prototype&&b!=Object.prototype&&(b[d]=c.value)};$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global&&null!=global?global:b};$jscomp.global=$jscomp.getGlobal(this);
|
||||
$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(b,d,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");b!=Array.prototype&&b!=Object.prototype&&(b[d]=c.value)};$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global?global:b};$jscomp.global=$jscomp.getGlobal(this);
|
||||
$jscomp.polyfill=function(b,d,c,e){if(d){c=$jscomp.global;b=b.split(".");for(e=0;e<b.length-1;e++){var a=b[e];a in c||(c[a]={});c=c[a]}b=b[b.length-1];e=c[b];d=d(e);d!=e&&null!=d&&$jscomp.defineProperty(c,b,{configurable:!0,writable:!0,value:d})}};
|
||||
$jscomp.polyfill("String.prototype.startsWith",function(b){return b?b:function(b,c){var d=$jscomp.checkStringArgs(this,b,"startsWith");b+="";for(var a=d.length,h=b.length,g=Math.max(0,Math.min(c|0,d.length)),f=0;f<h&&g<a;)if(d[g++]!=b[f++])return!1;return f>=h}},"es6-impl","es3");
|
||||
sysPass.Requests=function(b){var d=b.log,c=[],e={get:function(){return c},add:function(a){var b=""===a.hash?SparkMD5.hash(JSON.stringify(a),!1):a.hash;if(0<c.length&&c[c.length-1].hash===b)return c;d.info("history:add");a.hash=b;c.push(a);15<=c.length&&c.splice(0,10);return c},del:function(){d.info("history:del");if("undefined"!==typeof c.pop())return c[c.length-1]},reset:function(){d.info("history:reset");c=[]},length:function(){return c.length}};return{getRequestOpts:function(){return Object.create({type:"json",
|
||||
|
||||
Reference in New Issue
Block a user