mirror of
https://github.com/friendica/friendica
synced 2025-05-12 07:04:09 +02:00
Fixing PUBLIC usage, Fixing DB-View, Creating tests
This commit is contained in:
parent
a07acac463
commit
b5d994394e
14 changed files with 304 additions and 45 deletions
|
@ -125,9 +125,11 @@ class ProfileField extends BaseDepository
|
|||
public function selectPublicFieldsByUserId(int $uid): Collection\ProfileFields
|
||||
{
|
||||
try {
|
||||
$publicPermissionSet = $this->permissionSetDepository->selectPublic($uid);
|
||||
|
||||
return $this->select([
|
||||
'uid' => $uid,
|
||||
'psid' => PermissionSetDepository::PUBLIC,
|
||||
'psid' => $publicPermissionSet->id
|
||||
]);
|
||||
} catch (\Exception $exception) {
|
||||
throw new ProfileFieldPersistenceException(sprintf('Cannot select public ProfileField for user "%d"', $uid), $exception);
|
||||
|
@ -166,7 +168,7 @@ class ProfileField extends BaseDepository
|
|||
$permissionSetIds = $permissionSets->column('id');
|
||||
|
||||
// Includes public custom fields
|
||||
$permissionSetIds[] = PermissionSetDepository::PUBLIC;
|
||||
$permissionSetIds[] = $this->permissionSetDepository->selectPublic($uid)->id;
|
||||
|
||||
return $this->select(
|
||||
['uid' => $uid, 'psid' => $permissionSetIds],
|
||||
|
@ -215,6 +217,10 @@ class ProfileField extends BaseDepository
|
|||
*/
|
||||
public function save(Entity\ProfileField $profileField): Entity\ProfileField
|
||||
{
|
||||
if ($profileField->permissionSet->id === null) {
|
||||
throw new ProfileFieldPersistenceException('PermissionSet needs to be saved first.');
|
||||
}
|
||||
|
||||
$fields = $this->convertToTableRow($profileField);
|
||||
|
||||
try {
|
||||
|
|
|
@ -49,7 +49,7 @@ class ProfileField extends BaseFactory implements ICanCreateFromTableRow
|
|||
public function createFromTableRow(array $row, PermissionSet $permissionSet = null): Entity\ProfileField
|
||||
{
|
||||
if (empty($permissionSet) &&
|
||||
(empty($row['psid']) || !array_key_exists('allow_cid', $row) || !array_key_exists('allow_gid', $row) || !array_key_exists('deny_cid', $row) || !array_key_exists('deny_gid', $row))
|
||||
(!array_key_exists('psid', $row) || !array_key_exists('allow_cid', $row) || !array_key_exists('allow_gid', $row) || !array_key_exists('deny_cid', $row) || !array_key_exists('deny_gid', $row))
|
||||
) {
|
||||
throw new UnexpectedPermissionSetException('Either set the PermissionSet fields (join) or the PermissionSet itself');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue