Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
232
Issues
232
List
Boards
Labels
Service Desk
Milestones
Merge Requests
36
Merge Requests
36
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
3f2d80e8
Commit
3f2d80e8
authored
2 hours ago
by
Brian Hatchet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exporting single entities properly
parent
12231b32
chore-refactor-permissions-export
1 merge request
!349
Chore refactor permissions export
Pipeline
#86148417
passed with stages
in 9 minutes and 45 seconds
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1489 additions
and
1581 deletions
+1489
-1581
Api/Factory.php
Api/Factory.php
+29
-25
Controllers/api/v1/newsfeed.php
Controllers/api/v1/newsfeed.php
+2
-1
classes/ElggEntity.php
classes/ElggEntity.php
+1458
-1555
No files found.
Api/Factory.php
View file @
3f2d80e8
...
...
@@ -209,35 +209,39 @@ class Factory
* @return array - an array of the entities
* @deprecated
*/
public
static
function
exportable
(
$entities
,
$exceptions
=
[],
$exportContext
=
false
,
$includePermissions
=
true
)
public
static
function
exportable
(
$entities
,
$exceptions
=
[],
$exportContext
=
false
,
$includePermissions
=
true
)
:
array
{
$permissionsManager
=
Di
::
_
()
->
get
(
'Permissions\Manager'
);
if
(
!
$entities
)
{
return
[];
foreach
(
$entities
as
$k
=>
$entity
)
{
$entities
[
$k
]
=
Factory
::
export
(
$entity
,
$exceptions
,
$exportContext
,
$includePermissions
);
}
return
$entities
;
}
foreach
(
$entities
as
$k
=>
$entity
)
{
if
(
$exportContext
&&
method_exists
(
$entity
,
'setExportContext'
))
{
$entity
->
setExportContext
(
$exportContext
);
}
/**
* Exports a single entity, called by exportable for arrays
*/
public
static
function
export
(
$entity
,
$exceptions
=
false
,
$exportContext
=
false
,
$includePermissions
=
true
)
:
array
{
if
(
$exportContext
&&
method_exists
(
$entity
,
'setExportContext'
))
{
$entity
->
setExportContext
(
$exportContext
);
}
$entities
[
$k
]
=
$entity
->
export
();
//Calculate new permissions object with the entities
if
(
$includePermissions
&&
$entity
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Session
::
getLoggedinUser
(),
'entities'
=>
[
$entity
],
]);
$entities
[
$k
][
'permissions'
]
=
$permissions
->
exportPermission
(
$entity
->
getGuid
());
}
$entities
[
$k
][
'guid'
]
=
(
string
)
$entities
[
$k
][
'guid'
];
//javascript doesn't like long numbers..
if
(
isset
(
$entities
[
$k
][
'ownerObj'
][
'guid'
]))
{
$entities
[
$k
][
'ownerObj'
][
'guid'
]
=
(
string
)
$entity
->
ownerObj
[
'guid'
];
}
foreach
(
$exceptions
as
$exception
)
{
$entities
[
$k
][
$exception
]
=
$entity
->
$exception
;
}
$export
=
$entity
->
export
();
//Calculate new permissions object with the entities
if
(
$includePermissions
&&
$entity
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Session
::
getLoggedinUser
(),
'entities'
=>
[
$entity
],
]);
$export
[
'permissions'
]
=
$permissions
->
exportPermission
(
$entity
->
getGuid
());
}
return
$entities
;
$export
[
'guid'
]
=
(
string
)
$export
[
'guid'
];
//javascript doesn't like long numbers..
if
(
isset
(
$export
[
'ownerObj'
][
'guid'
]))
{
$export
[
'ownerObj'
][
'guid'
]
=
(
string
)
$entity
->
ownerObj
[
'guid'
];
}
foreach
(
$exceptions
as
$exception
)
{
$export
[
$exception
]
=
$export
->
$exception
;
}
return
$export
;
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v1/newsfeed.php
View file @
3f2d80e8
...
...
@@ -42,6 +42,7 @@ class newsfeed implements Interfaces\Api
switch
(
$pages
[
0
])
{
case
'single'
:
$activity
=
new
Activity
(
$pages
[
1
]);
if
(
!
Security\ACL
::
_
()
->
read
(
$activity
))
{
return
Factory
::
response
([
'status'
=>
'error'
,
...
...
@@ -53,7 +54,7 @@ class newsfeed implements Interfaces\Api
return
Factory
::
response
([
'status'
=>
'error'
]);
}
return
Factory
::
response
([
'activity'
=>
factory
::
exportable
([
$activity
]
)]);
return
Factory
::
response
([
'activity'
=>
Factory
::
export
(
$activity
)]);
break
;
default
:
case
'personal'
:
...
...
This diff is collapsed.
Click to expand it.
classes/ElggEntity.php
View file @
3f2d80e8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment