mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-03 07:04:07 +01:00
chore: Move account data models and unit test for account repository.
Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -29,7 +29,7 @@ use SP\Core\Acl\ActionsInterface;
|
||||
use SP\Core\Application;
|
||||
use SP\Core\Crypt\Crypt;
|
||||
use SP\Core\Crypt\Session as CryptSession;
|
||||
use SP\DataModel\AccountPassData;
|
||||
use SP\Domain\Account\Out\AccountPassData;
|
||||
use SP\Domain\Crypt\MasterPassServiceInterface;
|
||||
use SP\Http\RequestInterface;
|
||||
use SP\Modules\Web\Controllers\Helpers\HelperBase;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -50,7 +50,7 @@ abstract class DataCollection implements IteratorAggregate, ArrayAccess, Countab
|
||||
* <b>Traversable</b>
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function getIterator()
|
||||
public function getIterator(): Traversable
|
||||
{
|
||||
return new ArrayIterator($this->attributes);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ abstract class DataCollection implements IteratorAggregate, ArrayAccess, Countab
|
||||
* @return mixed Can return all value types.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
public function offsetGet($offset): mixed
|
||||
{
|
||||
return $this->get($offset);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -51,7 +51,7 @@ abstract class EventDispatcherBase implements EventDispatcherInterface
|
||||
*
|
||||
* @since 5.1.0
|
||||
*/
|
||||
public function attach(SplObserver $observer)
|
||||
public function attach(SplObserver $observer): void
|
||||
{
|
||||
$observerClass = get_class($observer);
|
||||
|
||||
@@ -77,7 +77,7 @@ abstract class EventDispatcherBase implements EventDispatcherInterface
|
||||
* @throws InvalidClassException
|
||||
* @since 5.1.0
|
||||
*/
|
||||
public function detach(SplObserver $observer)
|
||||
public function detach(SplObserver $observer): void
|
||||
{
|
||||
$observerClass = get_class($observer);
|
||||
|
||||
@@ -95,7 +95,7 @@ abstract class EventDispatcherBase implements EventDispatcherInterface
|
||||
* @return void
|
||||
* @since 5.1.0
|
||||
*/
|
||||
public function notify()
|
||||
public function notify(): void
|
||||
{
|
||||
foreach ($this->observers as $observer) {
|
||||
$observer->update($this);
|
||||
|
||||
@@ -1,527 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, 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\DataModel;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use JsonSerializable;
|
||||
use SP\Http\Json;
|
||||
|
||||
/**
|
||||
* Class AccountData
|
||||
*
|
||||
* @package SP\Account
|
||||
*/
|
||||
class AccountData extends DataModelBase implements JsonSerializable, DataModelInterface
|
||||
{
|
||||
/**
|
||||
* @var int Id de la cuenta.
|
||||
*/
|
||||
public $id = 0;
|
||||
/**
|
||||
* @var int Id del usuario principal de la cuenta.
|
||||
*/
|
||||
public $userId = 0;
|
||||
/**
|
||||
* @var int Id del grupo principal de la cuenta.
|
||||
*/
|
||||
public $userGroupId = 0;
|
||||
/**
|
||||
* @var int Id del usuario que editó la cuenta.
|
||||
*/
|
||||
public $userEditId = 0;
|
||||
/**
|
||||
* @var string El nombre de la cuenta.
|
||||
*/
|
||||
public $name = '';
|
||||
/**
|
||||
* @var int Id del cliente de la cuenta.
|
||||
*/
|
||||
public $clientId = 0;
|
||||
/**
|
||||
* @var int Id de la categoría de la cuenta.
|
||||
*/
|
||||
public $categoryId = 0;
|
||||
/**
|
||||
* @var string El nombre de usuario de la cuenta.
|
||||
*/
|
||||
public $login = '';
|
||||
/**
|
||||
* @var string La URL de la cuenta.
|
||||
*/
|
||||
public $url = '';
|
||||
/**
|
||||
* @var string La clave de la cuenta.
|
||||
*/
|
||||
public $pass = '';
|
||||
/**
|
||||
* @var string La clave de encriptación de la cuenta
|
||||
*/
|
||||
public $key = '';
|
||||
/**
|
||||
* @var string Las nosta de la cuenta.
|
||||
*/
|
||||
public $notes = '';
|
||||
/**
|
||||
* @var bool Si se permite la edición por los usuarios secundarios.
|
||||
*/
|
||||
public $otherUserEdit = false;
|
||||
/**
|
||||
* @var bool Si se permita la edición por los grupos secundarios.
|
||||
*/
|
||||
public $otherUserGroupEdit = false;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $dateAdd = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $dateEdit = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $countView = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $countDecrypt = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $isPrivate = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $isPrivateGroup = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $passDate = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $passDateChange = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $parentId = 0;
|
||||
|
||||
|
||||
/**
|
||||
* AccountData constructor.
|
||||
*
|
||||
* @param int $accountId
|
||||
*/
|
||||
public function __construct($accountId = 0)
|
||||
{
|
||||
$this->id = (int)$accountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDateAdd()
|
||||
{
|
||||
return $this->dateAdd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $dateAdd
|
||||
*/
|
||||
public function setDateAdd($dateAdd)
|
||||
{
|
||||
$this->dateAdd = $dateAdd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDateEdit()
|
||||
{
|
||||
return $this->dateEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $dateEdit
|
||||
*/
|
||||
public function setDateEdit($dateEdit)
|
||||
{
|
||||
$this->dateEdit = $dateEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getUserEditId()
|
||||
{
|
||||
return (int)$this->userEditId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userEditId
|
||||
*/
|
||||
public function setUserEditId($userEditId)
|
||||
{
|
||||
$this->userEditId = (int)$userEditId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPass()
|
||||
{
|
||||
return $this->pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pass
|
||||
*/
|
||||
public function setPass($pass)
|
||||
{
|
||||
$this->pass = $pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*/
|
||||
public function setKey($key)
|
||||
{
|
||||
$this->key = $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return (int)$this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = (int)$id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getUserId()
|
||||
{
|
||||
return (int)$this->userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
*/
|
||||
public function setUserId($userId)
|
||||
{
|
||||
$this->userId = (int)$userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getUserGroupId()
|
||||
{
|
||||
return (int)$this->userGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userGroupId
|
||||
*/
|
||||
public function setUserGroupId($userGroupId)
|
||||
{
|
||||
$this->userGroupId = (int)$userGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOtherUserEdit()
|
||||
{
|
||||
return (int)$this->otherUserEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $otherUserEdit
|
||||
*/
|
||||
public function setOtherUserEdit($otherUserEdit)
|
||||
{
|
||||
$this->otherUserEdit = (int)$otherUserEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOtherUserGroupEdit()
|
||||
{
|
||||
return (int)$this->otherUserGroupEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $otherUserGroupEdit
|
||||
*/
|
||||
public function setOtherUserGroupEdit($otherUserGroupEdit)
|
||||
{
|
||||
$this->otherUserGroupEdit = (int)$otherUserGroupEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCategoryId()
|
||||
{
|
||||
return (int)$this->categoryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $categoryId
|
||||
*/
|
||||
public function setCategoryId($categoryId)
|
||||
{
|
||||
$this->categoryId = (int)$categoryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getClientId()
|
||||
{
|
||||
return (int)$this->clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $clientId
|
||||
*/
|
||||
public function setClientId($clientId)
|
||||
{
|
||||
$this->clientId = (int)$clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLogin()
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $login
|
||||
*/
|
||||
public function setLogin($login)
|
||||
{
|
||||
$this->login = $login;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNotes()
|
||||
{
|
||||
return $this->notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $notes
|
||||
*/
|
||||
public function setNotes($notes)
|
||||
{
|
||||
$this->notes = $notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify data which should be serialized to JSON
|
||||
*
|
||||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
* @return mixed data which can be serialized by <b>json_encode</b>,
|
||||
* which is a value of any type other than a resource.
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$data = get_object_vars($this);
|
||||
|
||||
unset($data['accountPass'], $data['accountIV']);
|
||||
|
||||
return Json::safeJson($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCountView()
|
||||
{
|
||||
return (int)$this->countView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $countView
|
||||
*/
|
||||
public function setCountView($countView)
|
||||
{
|
||||
$this->countView = (int)$countView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCountDecrypt()
|
||||
{
|
||||
return (int)$this->countDecrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $countDecrypt
|
||||
*/
|
||||
public function setCountDecrypt($countDecrypt)
|
||||
{
|
||||
$this->countDecrypt = (int)$countDecrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIsPrivate()
|
||||
{
|
||||
return (int)$this->isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $isPrivate
|
||||
*/
|
||||
public function setIsPrivate($isPrivate)
|
||||
{
|
||||
$this->isPrivate = (int)$isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPassDate()
|
||||
{
|
||||
return (int)$this->passDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $passDate
|
||||
*/
|
||||
public function setPassDate($passDate)
|
||||
{
|
||||
$this->passDate = (int)$passDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPassDateChange()
|
||||
{
|
||||
return (int)$this->passDateChange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $passDateChange
|
||||
*/
|
||||
public function setPassDateChange($passDateChange)
|
||||
{
|
||||
$this->passDateChange = (int)$passDateChange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getParentId()
|
||||
{
|
||||
return (int)$this->parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $parentId
|
||||
*/
|
||||
public function setParentId($parentId)
|
||||
{
|
||||
$this->parentId = (int)$parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIsPrivateGroup()
|
||||
{
|
||||
return (int)$this->isPrivateGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $isPrivateGroup
|
||||
*/
|
||||
public function setIsPrivateGroup($isPrivateGroup)
|
||||
{
|
||||
$this->isPrivateGroup = (int)$isPrivateGroup;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Account\Out\AccountData;
|
||||
|
||||
/**
|
||||
* Class AccountExtData
|
||||
*
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, 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\DataModel;
|
||||
|
||||
/**
|
||||
* Class AccountPassData
|
||||
*
|
||||
* @package DataModel
|
||||
*/
|
||||
class AccountPassData extends DataModelBase implements DataModelInterface
|
||||
{
|
||||
/**
|
||||
* @var int Id de la cuenta.
|
||||
*/
|
||||
public $id = 0;
|
||||
/**
|
||||
* @var string El nombre de la cuenta.
|
||||
*/
|
||||
public $name = '';
|
||||
/**
|
||||
* @var string El nombre de usuario de la cuenta.
|
||||
*/
|
||||
public $login = '';
|
||||
/**
|
||||
* @var string La clave de la cuenta.
|
||||
*/
|
||||
public $pass = '';
|
||||
/**
|
||||
* @var string La clave de encriptación de la cuenta
|
||||
*/
|
||||
public $key = '';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $parentId = 0;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $mPassHash = '';
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return (int)$this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = (int)$id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLogin()
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $login
|
||||
*/
|
||||
public function setLogin($login)
|
||||
{
|
||||
$this->login = $login;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPass()
|
||||
{
|
||||
return $this->pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pass
|
||||
*/
|
||||
public function setPass($pass)
|
||||
{
|
||||
$this->pass = $pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*/
|
||||
public function setKey($key)
|
||||
{
|
||||
$this->key = $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getParentId()
|
||||
{
|
||||
return $this->parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $parentId
|
||||
*/
|
||||
public function setParentId($parentId)
|
||||
{
|
||||
$this->parentId = $parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMPassHash()
|
||||
{
|
||||
return $this->mPassHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mPassHash
|
||||
*/
|
||||
public function setMPassHash($mPassHash)
|
||||
{
|
||||
$this->mPassHash = $mPassHash;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -25,6 +25,8 @@
|
||||
namespace SP\DataModel;
|
||||
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
|
||||
/**
|
||||
* Class AccountVData
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
/**
|
||||
* Class ActionData
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -25,6 +25,8 @@
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Core\Crypt\Vault;
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
/**
|
||||
* Class AuthTokenData
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
/**
|
||||
* Class CustomFieldDefDataOld
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -25,6 +25,9 @@
|
||||
namespace SP\DataModel;
|
||||
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
/**
|
||||
* Class CustomFieldTypeData
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
|
||||
/**
|
||||
* Class EventlogData
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
/**
|
||||
* Class ItemData
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\HydratableInterface;
|
||||
|
||||
/**
|
||||
* Class ItemPresetData
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Core\Messages\MessageInterface;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
/**
|
||||
* Class NoticeData
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -42,18 +42,18 @@ trait SerializedModel
|
||||
* @return mixed|null
|
||||
* @throws NoSuchPropertyException
|
||||
*/
|
||||
public function hydrate(string $class = null, string $property = 'data')
|
||||
public function hydrate(?string $class = null, string $property = 'data')
|
||||
{
|
||||
if (property_exists($this, $property)) {
|
||||
if ($this->$property === null) {
|
||||
if ($this->{$property} === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($class !== null) {
|
||||
return Util::unserialize($class, $this->$property);
|
||||
return Util::unserialize($class, $this->{$property});
|
||||
}
|
||||
|
||||
return unserialize($this->$property);
|
||||
return unserialize($this->{$property});
|
||||
}
|
||||
|
||||
throw new NoSuchPropertyException($property);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Core\Exceptions\InvalidArgumentException;
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Http\Address;
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
|
||||
/**
|
||||
* Class UserPassData
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
|
||||
/**
|
||||
* Class UserPassRecoverData
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace SP\DataModel;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,9 +32,9 @@ use SP\Domain\Account\Services\AccountPasswordRequest;
|
||||
use SP\Domain\Account\Services\AccountRequest;
|
||||
use SP\Domain\Account\Services\AccountSearchFilter;
|
||||
use SP\Domain\Common\In\RepositoryInterface;
|
||||
use SP\Domain\Common\Out\SimpleModel;
|
||||
use SP\Infrastructure\Database\QueryResult;
|
||||
use SP\Mvc\Model\QueryCondition;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class AccountRepository
|
||||
@@ -46,11 +46,10 @@ interface AccountRepositoryInterface extends RepositoryInterface
|
||||
/**
|
||||
* Devolver el número total de cuentas
|
||||
*
|
||||
* @return stdClass
|
||||
* @throws QueryException
|
||||
* @throws ConstraintException
|
||||
*/
|
||||
public function getTotalNumAccounts(): stdClass;
|
||||
public function getTotalNumAccounts(): SimpleModel;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
|
||||
199
lib/SP/Domain/Account/Out/AccountData.php
Normal file
199
lib/SP/Domain/Account/Out/AccountData.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/*
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2022, 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\Domain\Account\Out;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use JsonSerializable;
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
use SP\Http\Json;
|
||||
|
||||
/**
|
||||
* Class AccountData
|
||||
*/
|
||||
class AccountData extends DataModelBase implements JsonSerializable, DataModelInterface
|
||||
{
|
||||
private int $id;
|
||||
private ?int $userId = null;
|
||||
private ?int $userGroupId = null;
|
||||
private ?int $userEditId = null;
|
||||
private ?string $name = null;
|
||||
private ?int $clientId = null;
|
||||
private ?int $categoryId = null;
|
||||
private ?string $login = null;
|
||||
private ?string $url = null;
|
||||
private ?string $pass = null;
|
||||
private ?string $key = null;
|
||||
private ?string $notes = null;
|
||||
private ?int $dateAdd = 0;
|
||||
private ?int $dateEdit = 0;
|
||||
private ?int $countView = 0;
|
||||
private ?int $countDecrypt = 0;
|
||||
private ?int $isPrivate = 0;
|
||||
private ?int $isPrivateGroup = 0;
|
||||
private ?int $passDate = 0;
|
||||
private ?int $passDateChange = 0;
|
||||
private ?int $parentId = 0;
|
||||
|
||||
public function __construct(int $accountId = 0, ?array $properties = [])
|
||||
{
|
||||
parent::__construct($properties);
|
||||
|
||||
$this->id = $accountId;
|
||||
}
|
||||
|
||||
public function getDateAdd(): ?int
|
||||
{
|
||||
return $this->dateAdd;
|
||||
}
|
||||
|
||||
public function getDateEdit(): ?int
|
||||
{
|
||||
return $this->dateEdit;
|
||||
}
|
||||
|
||||
public function getUserEditId(): ?int
|
||||
{
|
||||
return $this->userEditId;
|
||||
}
|
||||
|
||||
public function getPass(): ?string
|
||||
{
|
||||
return $this->pass;
|
||||
}
|
||||
|
||||
public function setPass(string $pass)
|
||||
{
|
||||
$this->pass = $pass;
|
||||
}
|
||||
|
||||
public function getKey(): ?string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function setKey(string $key)
|
||||
{
|
||||
$this->key = $key;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getUserId(): ?int
|
||||
{
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
public function getUserGroupId(): ?int
|
||||
{
|
||||
return $this->userGroupId;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getCategoryId(): ?int
|
||||
{
|
||||
return $this->categoryId;
|
||||
}
|
||||
|
||||
public function getClientId(): ?int
|
||||
{
|
||||
return $this->clientId;
|
||||
}
|
||||
|
||||
public function getLogin(): ?string
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
public function getUrl(): ?string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function getNotes(): ?string
|
||||
{
|
||||
return $this->notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify data which should be serialized to JSON
|
||||
*
|
||||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
* @return mixed data which can be serialized by <b>json_encode</b>,
|
||||
* which is a value of any type other than a resource.
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$data = get_object_vars($this);
|
||||
|
||||
unset($data['accountPass'], $data['accountIV']);
|
||||
|
||||
return Json::safeJson($data);
|
||||
}
|
||||
|
||||
public function getCountView(): ?int
|
||||
{
|
||||
return $this->countView;
|
||||
}
|
||||
|
||||
public function getCountDecrypt(): ?int
|
||||
{
|
||||
return $this->countDecrypt;
|
||||
}
|
||||
|
||||
public function getIsPrivate(): ?int
|
||||
{
|
||||
return $this->isPrivate;
|
||||
}
|
||||
|
||||
public function getPassDate(): ?int
|
||||
{
|
||||
return $this->passDate;
|
||||
}
|
||||
|
||||
public function getPassDateChange(): ?int
|
||||
{
|
||||
return $this->passDateChange;
|
||||
}
|
||||
|
||||
public function getParentId(): ?int
|
||||
{
|
||||
return $this->parentId;
|
||||
}
|
||||
|
||||
public function getIsPrivateGroup(): ?int
|
||||
{
|
||||
return $this->isPrivateGroup;
|
||||
}
|
||||
}
|
||||
77
lib/SP/Domain/Account/Out/AccountPassData.php
Normal file
77
lib/SP/Domain/Account/Out/AccountPassData.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/*
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2022, 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\Domain\Account\Out;
|
||||
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
/**
|
||||
* Class AccountPassData
|
||||
*/
|
||||
class AccountPassData extends DataModelBase implements DataModelInterface
|
||||
{
|
||||
private ?int $id = null;
|
||||
private ?string $name = null;
|
||||
private ?string $login = null;
|
||||
private ?string $pass = null;
|
||||
private ?string $key = null;
|
||||
private ?int $parentId = null;
|
||||
private ?string $mPassHash = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getLogin(): ?string
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
public function getPass(): ?string
|
||||
{
|
||||
return $this->pass;
|
||||
}
|
||||
|
||||
public function getKey(): ?string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function getParentId(): ?int
|
||||
{
|
||||
return $this->parentId;
|
||||
}
|
||||
|
||||
public function getMPassHash(): ?string
|
||||
{
|
||||
return $this->mPassHash;
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,8 @@ use SP\Core\Exceptions\ConstraintException;
|
||||
use SP\Core\Exceptions\NoSuchPropertyException;
|
||||
use SP\Core\Exceptions\QueryException;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\AccountData;
|
||||
use SP\DataModel\AccountExtData;
|
||||
use SP\DataModel\AccountHistoryData;
|
||||
use SP\DataModel\AccountPassData;
|
||||
use SP\DataModel\Dto\AccountDetailsResponse;
|
||||
use SP\DataModel\Dto\AccountHistoryCreateDto;
|
||||
use SP\DataModel\ItemPreset\AccountPermission;
|
||||
@@ -47,6 +45,8 @@ use SP\Domain\Account\In\AccountRepositoryInterface;
|
||||
use SP\Domain\Account\In\AccountToTagRepositoryInterface;
|
||||
use SP\Domain\Account\In\AccountToUserGroupRepositoryInterface;
|
||||
use SP\Domain\Account\In\AccountToUserRepositoryInterface;
|
||||
use SP\Domain\Account\Out\AccountData;
|
||||
use SP\Domain\Account\Out\AccountPassData;
|
||||
use SP\Domain\Common\Services\Service;
|
||||
use SP\Domain\Common\Services\ServiceException;
|
||||
use SP\Domain\Common\Services\ServiceItemTrait;
|
||||
|
||||
71
lib/SP/Domain/Common/Out/DataModelBase.php
Normal file
71
lib/SP/Domain/Common/Out/DataModelBase.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/*
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2022, 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\Domain\Common\Out;
|
||||
|
||||
/**
|
||||
* Class DataModelBase
|
||||
*/
|
||||
abstract class DataModelBase
|
||||
{
|
||||
private array $properties;
|
||||
|
||||
public function __construct(?array $properties = [])
|
||||
{
|
||||
foreach ($properties as $property => $value) {
|
||||
$this->{$property} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function __get(string $name)
|
||||
{
|
||||
if (property_exists($this, $name)) {
|
||||
return $this->{$name};
|
||||
}
|
||||
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function __set(string $name, ?string $value = null): void
|
||||
{
|
||||
if (is_numeric($value)) {
|
||||
$value = (int)$value;
|
||||
}
|
||||
|
||||
if (property_exists($this, $name)) {
|
||||
$this->{$name} = $value;
|
||||
} else {
|
||||
$this->properties[$name] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\DataModel;
|
||||
namespace SP\Domain\Common\Out;
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ namespace SP\DataModel;
|
||||
*/
|
||||
interface DataModelInterface
|
||||
{
|
||||
public function getId();
|
||||
public function getId(): ?int;
|
||||
|
||||
public function getName();
|
||||
public function getName(): ?string;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\DataModel;
|
||||
namespace SP\Domain\Common\Out;
|
||||
|
||||
/**
|
||||
* Interface HydratableInterface
|
||||
@@ -32,9 +32,8 @@ namespace SP\DataModel;
|
||||
interface HydratableInterface
|
||||
{
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @param string $property
|
||||
* @param string|null $class
|
||||
* @param string $property
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -22,30 +22,16 @@
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\DataModel;
|
||||
namespace SP\Domain\Common\Out;
|
||||
|
||||
/**
|
||||
* Class DataModelBase
|
||||
* Class SimpleModel
|
||||
*
|
||||
* @package SP\DataModel
|
||||
* This model does not contain any properties, they will be set on $properties property.
|
||||
*
|
||||
* It's intended to be used when returned non-well defined objects from the repository.
|
||||
*/
|
||||
abstract class DataModelBase
|
||||
final class SimpleModel extends DataModelBase
|
||||
{
|
||||
/**
|
||||
* is utilized for reading data from inaccessible members.
|
||||
*
|
||||
* @param $name string
|
||||
*
|
||||
* @return mixed
|
||||
* @link https://php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (property_exists($this, $name)) {
|
||||
return $this->{$name};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,17 +28,18 @@ use RuntimeException;
|
||||
use SP\Core\Exceptions\ConstraintException;
|
||||
use SP\Core\Exceptions\QueryException;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\AccountData;
|
||||
use SP\DataModel\AccountExtData;
|
||||
use SP\DataModel\AccountPassData;
|
||||
use SP\DataModel\AccountSearchVData;
|
||||
use SP\DataModel\AccountVData;
|
||||
use SP\DataModel\ItemData;
|
||||
use SP\DataModel\ItemSearchData;
|
||||
use SP\Domain\Account\In\AccountRepositoryInterface;
|
||||
use SP\Domain\Account\Out\AccountData;
|
||||
use SP\Domain\Account\Out\AccountPassData;
|
||||
use SP\Domain\Account\Services\AccountPasswordRequest;
|
||||
use SP\Domain\Account\Services\AccountRequest;
|
||||
use SP\Domain\Account\Services\AccountSearchFilter;
|
||||
use SP\Domain\Common\Out\SimpleModel;
|
||||
use SP\Infrastructure\Common\Repositories\Repository;
|
||||
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
|
||||
use SP\Infrastructure\Database\QueryData;
|
||||
@@ -46,7 +47,6 @@ use SP\Infrastructure\Database\QueryResult;
|
||||
use SP\Mvc\Model\QueryAssignment;
|
||||
use SP\Mvc\Model\QueryCondition;
|
||||
use SP\Mvc\Model\QueryJoin;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class AccountRepository
|
||||
@@ -59,18 +59,15 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
|
||||
|
||||
/**
|
||||
* Devolver el número total de cuentas
|
||||
*
|
||||
* @return stdClass
|
||||
* @throws QueryException
|
||||
* @throws ConstraintException
|
||||
*/
|
||||
public function getTotalNumAccounts(): stdClass
|
||||
public function getTotalNumAccounts(): SimpleModel
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT SUM(n) AS num FROM
|
||||
(SELECT COUNT(*) AS n FROM Account UNION SELECT COUNT(*) AS n FROM AccountHistory) a';
|
||||
|
||||
$queryData = new QueryData();
|
||||
$queryData->setMapClassName(SimpleModel::class);
|
||||
$queryData->setQuery($query);
|
||||
|
||||
return $this->db->doSelect($queryData)->getData();
|
||||
@@ -81,8 +78,6 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
|
||||
* @param QueryCondition $queryCondition
|
||||
*
|
||||
* @return QueryResult
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
*/
|
||||
public function getPasswordForId(int $id, QueryCondition $queryCondition): QueryResult
|
||||
{
|
||||
@@ -103,8 +98,6 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
|
||||
* @param QueryCondition $queryCondition
|
||||
*
|
||||
* @return QueryResult
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function getPasswordHistoryForId(QueryCondition $queryCondition): QueryResult
|
||||
{
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace SP\Infrastructure\Common\Repositories;
|
||||
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
use SP\DataModel\DataModelInterface;
|
||||
use SP\Domain\Common\In\RepositoryInterface;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
use SP\Infrastructure\Database\DatabaseUtil;
|
||||
use SP\Infrastructure\Database\DbStorageInterface;
|
||||
|
||||
|
||||
@@ -91,16 +91,10 @@ final class Database implements DatabaseInterface
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function doSelect(
|
||||
QueryData $queryData,
|
||||
bool $fullCount = false
|
||||
): QueryResult {
|
||||
public function doSelect(QueryData $queryData, bool $fullCount = false): QueryResult
|
||||
{
|
||||
if ($queryData->getQuery() === '') {
|
||||
throw new QueryException(
|
||||
$queryData->getOnErrorMessage(),
|
||||
SPException::ERROR,
|
||||
__u('Blank query')
|
||||
);
|
||||
throw new QueryException($queryData->getOnErrorMessage(), SPException::ERROR, __u('Blank query'));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -140,11 +134,7 @@ final class Database implements DatabaseInterface
|
||||
|
||||
$this->eventDispatcher->notifyEvent(
|
||||
'database.query',
|
||||
new Event(
|
||||
$this,
|
||||
EventMessage::factory()
|
||||
->addDescription($queryData->getQuery())
|
||||
)
|
||||
new Event($this, EventMessage::factory()->addDescription($queryData->getQuery()))
|
||||
);
|
||||
|
||||
if (preg_match("/^(select|show)\s/i", $queryData->getQuery())) {
|
||||
|
||||
@@ -35,6 +35,8 @@ use SP\Core\Exceptions\QueryException;
|
||||
*/
|
||||
interface DatabaseInterface
|
||||
{
|
||||
public function doSelect(QueryData $queryData, bool $fullCount = false): QueryResult;
|
||||
|
||||
/**
|
||||
* Performs a DB query
|
||||
*
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
namespace SP\Infrastructure\Plugin\Repositories;
|
||||
|
||||
use SP\DataModel\EncryptedModel;
|
||||
use SP\DataModel\HydratableInterface;
|
||||
use SP\DataModel\SerializedModel;
|
||||
use SP\Domain\Common\Out\HydratableInterface;
|
||||
|
||||
/**
|
||||
* Class PluginData
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
namespace SP\Infrastructure\Plugin\Repositories;
|
||||
|
||||
use SP\DataModel\DataModelBase;
|
||||
use SP\DataModel\DataModelInterface;
|
||||
use SP\Domain\Common\Out\DataModelBase;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
|
||||
/**
|
||||
* Class PluginData
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -26,7 +26,7 @@ namespace SP\Mvc\View\Components;
|
||||
|
||||
use RuntimeException;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\DataModelInterface;
|
||||
use SP\Domain\Common\Out\DataModelInterface;
|
||||
use SP\Http\Json;
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
/*
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
* 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/>.
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Tests\Services\Account;
|
||||
@@ -35,12 +35,12 @@ use SP\Core\Exceptions\ConstraintException;
|
||||
use SP\Core\Exceptions\NoSuchPropertyException;
|
||||
use SP\Core\Exceptions\QueryException;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\DataModel\AccountData;
|
||||
use SP\DataModel\AccountSearchVData;
|
||||
use SP\DataModel\AccountVData;
|
||||
use SP\DataModel\ItemSearchData;
|
||||
use SP\DataModel\ProfileData;
|
||||
use SP\Domain\Account\AccountHistoryServiceInterface;
|
||||
use SP\Domain\Account\Out\AccountData;
|
||||
use SP\Domain\Account\Services\AccountBulkRequest;
|
||||
use SP\Domain\Account\Services\AccountHistoryService;
|
||||
use SP\Domain\Account\Services\AccountPasswordRequest;
|
||||
|
||||
@@ -30,6 +30,7 @@ use Faker\Factory;
|
||||
use Faker\Generator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use SP\Core\Application;
|
||||
use SP\Core\Context\ContextInterface;
|
||||
use SP\Core\Context\StatelessContext;
|
||||
use SP\Core\Events\EventDispatcher;
|
||||
use SP\Domain\Config\Services\ConfigBackupService;
|
||||
@@ -46,6 +47,7 @@ abstract class UnitaryTestCase extends TestCase
|
||||
protected static Generator $faker;
|
||||
protected ConfigFileService $config;
|
||||
protected Application $application;
|
||||
protected ContextInterface $context;
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
@@ -78,17 +80,17 @@ abstract class UnitaryTestCase extends TestCase
|
||||
$userLogin = new UserLoginResponse();
|
||||
$userLogin->setLogin(self::$faker->userName);
|
||||
|
||||
$context = new StatelessContext();
|
||||
$context->initialize();
|
||||
$context->setUserData($userLogin);
|
||||
$this->context = new StatelessContext();
|
||||
$this->context->initialize();
|
||||
$this->context->setUserData($userLogin);
|
||||
|
||||
$config = new ConfigFileService(
|
||||
$this->createStub(XmlHandler::class),
|
||||
$this->createStub(FileCache::class),
|
||||
$context,
|
||||
$this->context,
|
||||
$this->createStub(ConfigBackupService::class)
|
||||
);
|
||||
|
||||
return new Application($config, $this->createStub(EventDispatcher::class), $context);
|
||||
return new Application($config, $this->createStub(EventDispatcher::class), $this->context);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user