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
215
Issues
215
List
Boards
Labels
Service Desk
Milestones
Merge Requests
32
Merge Requests
32
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
90466971
Commit
90466971
authored
1 hour ago
by
Emiliano Balbuena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): Allow admins to edit Pro settings; Custom <head> support
Closes
#824
Closes
#825
parent
31683298
epic/minds-pro
1 merge request
!308
WIP: (feat): Minds Pro
Pipeline
#81679144
failed with stages
in 4 minutes and 4 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
3 deletions
+67
-3
settings.php
Controllers/api/v2/pro/settings.php
+31
-2
Manager.php
Core/Pro/Manager.php
+24
-0
Repository.php
Core/Pro/Repository.php
+2
-0
Settings.php
Core/Pro/Settings.php
+10
-1
No files found.
Controllers/api/v2/pro/settings.php
View file @
90466971
...
...
@@ -10,6 +10,7 @@ use Exception;
use
Minds\Core\Di\Di
;
use
Minds\Core\Pro\Manager
;
use
Minds\Core\Session
;
use
Minds\Entities\User
;
use
Minds\Interfaces
;
use
Minds\Api\Factory
;
...
...
@@ -22,10 +23,24 @@ class settings implements Interfaces\Api
*/
public
function
get
(
$pages
)
{
$user
=
Session
::
getLoggedinUser
();
if
(
isset
(
$pages
[
0
])
&&
$pages
[
0
])
{
if
(
!
Session
::
isAdmin
())
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'You are not authorized'
,
]);
}
$user
=
new
User
(
$pages
[
0
]);
}
/** @var Manager $manager */
$manager
=
Di
::
_
()
->
get
(
'Pro\Manager'
);
$manager
->
setUser
(
Session
::
getLoggedinUser
());
->
setUser
(
$user
)
->
setActor
(
Session
::
getLoggedinUser
());
return
Factory
::
response
([
'isActive'
=>
$manager
->
isActive
(),
...
...
@@ -40,10 +55,24 @@ class settings implements Interfaces\Api
*/
public
function
post
(
$pages
)
{
$user
=
Session
::
getLoggedinUser
();
if
(
isset
(
$pages
[
0
])
&&
$pages
[
0
])
{
if
(
!
Session
::
isAdmin
())
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'You are not authorized'
,
]);
}
$user
=
new
User
(
$pages
[
0
]);
}
/** @var Manager $manager */
$manager
=
Di
::
_
()
->
get
(
'Pro\Manager'
);
$manager
->
setUser
(
Session
::
getLoggedinUser
());
->
setUser
(
$user
)
->
setActor
(
Session
::
getLoggedinUser
());
if
(
!
$manager
->
isActive
())
{
return
Factory
::
response
([
...
...
This diff is collapsed.
Click to expand it.
Core/Pro/Manager.php
View file @
90466971
...
...
@@ -27,6 +27,9 @@ class Manager
/** @var User */
protected
$user
;
/** @var User */
protected
$actor
;
/**
* Manager constructor.
* @param Repository $repository
...
...
@@ -56,6 +59,16 @@ class Manager
return
$this
;
}
/**
* @param User $actor
* @return Manager
*/
public
function
setActor
(
User
$actor
)
{
$this
->
actor
=
$actor
;
return
$this
;
}
/**
* @return bool
* @throws Exception
...
...
@@ -136,6 +149,10 @@ class Manager
return
$this
->
hydrate
(
$settings
);
}
/**
* @param $settings
* @return Settings
*/
public
function
hydrate
(
$settings
)
{
return
$this
->
hydrateSettingsDelegate
...
...
@@ -257,6 +274,13 @@ class Manager
->
setScheme
(
$values
[
'scheme'
]);
}
if
(
isset
(
$values
[
'custom_head'
])
&&
$this
->
actor
->
isAdmin
())
{
// TODO: Validate!
$settings
->
setCustomHead
(
$values
[
'custom_head'
]);
}
return
$this
->
repository
->
update
(
$settings
);
}
}
This diff is collapsed.
Click to expand it.
Core/Pro/Repository.php
View file @
90466971
...
...
@@ -98,6 +98,7 @@ class Repository
->
setFooterLinks
(
$data
[
'footer_links'
]
??
[])
->
setTagList
(
$data
[
'tag_list'
]
??
[])
->
setScheme
(
$data
[
'scheme'
]
??
''
)
->
setCustomHead
(
$data
[
'custom_head'
]
??
''
)
;
$response
[]
=
$settings
;
...
...
@@ -144,6 +145,7 @@ class Repository
'footer_links'
=>
$settings
->
getFooterLinks
(),
'tag_list'
=>
$settings
->
getTagList
(),
'scheme'
=>
$settings
->
getScheme
(),
'custom_head'
=>
$settings
->
getCustomHead
(),
]),
];
...
...
This diff is collapsed.
Click to expand it.
Core/Pro/Settings.php
View file @
90466971
...
...
@@ -44,6 +44,8 @@ use Minds\Traits\MagicAttributes;
* @method Settings setLogoImage(string $logoImage)
* @method array getFeaturedContent()
* @method Settings setFeaturedContent(array $featuredContent)
* @method string getCustomHead()
* @method Settings setCustomHead(string $customHead)
*/
class
Settings
implements
JsonSerializable
{
...
...
@@ -105,6 +107,12 @@ class Settings implements JsonSerializable
/** @var array */
protected
$featuredContent
=
[];
/** @var string */
protected
$customHead
=
''
;
/**
* @return string
*/
public
function
getOneLineHeadline
()
{
return
preg_replace
(
"/
\\
r?
\\
n+/"
,
' '
,
$this
->
headline
);
...
...
@@ -125,7 +133,6 @@ class Settings implements JsonSerializable
'domain'
=>
$this
->
domain
,
'title'
=>
$this
->
title
,
'headline'
=>
$this
->
headline
,
'one_line_headline'
=>
$this
->
getOneLineHeadline
(),
'text_color'
=>
$textColor
,
'primary_color'
=>
$primaryColor
,
'plain_background_color'
=>
$plainBackgroundColor
,
...
...
@@ -138,6 +145,8 @@ class Settings implements JsonSerializable
'logo_image'
=>
$this
->
logoImage
,
'featured_content'
=>
$this
->
featuredContent
,
'scheme'
=>
$this
->
scheme
,
'custom_head'
=>
$this
->
customHead
,
'one_line_headline'
=>
$this
->
getOneLineHeadline
(),
'styles'
=>
$this
->
buildStyles
(),
];
}
...
...
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