Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

View and edit other users sites role capability

givanza0793e853e9c
diff --git a/admin/controller/settings/sites.php b/admin/controller/settings/sites.php
index 8865eda..dbc54ba 100755
--- a/admin/controller/settings/sites.php
+++ b/admin/controller/settings/sites.php
@@ -25,21 +25,29 @@ namespace Vvveb\Controller\Settings;
use Vvveb\Controller\Base;
use Vvveb\Sql\SiteSQL;
use Vvveb\System\Sites as SitesList;
+use Vvveb\System\User\Admin;
class Sites extends Base {
function add() {
}
function index() {
- $view = $this->view;
- $sites = new SiteSQL();
- $this->view->sites = $sites->getAll();
+ $view = $this->view;
+ $sites = new SiteSQL();
+
+ $options = [];
+
+ if (Admin::hasCapability('view_other_sites')) {
+ unset($options['site_id']);
+ } else {
+ $options['site_id'] = Admin :: siteAccess();
+ }
$page = $this->request->get['page'] ?? 1;
$limit = $this->request->get['limit'] ?? 10;
$results = $sites->getAll(
- [
+ $options + [
'start' => ($page - 1) * $limit,
'limit' => $limit,
]
diff --git a/admin/sql/mysqli/post.sql b/admin/sql/mysqli/post.sql
index 221f313..8f09600 100755
--- a/admin/sql/mysqli/post.sql
+++ b/admin/sql/mysqli/post.sql
@@ -247,6 +247,7 @@
IN language_id INT,
IN comment_count INT,
IN comment_status INT,
+ IN admin_id INT,
IN type CHAR,
OUT fetch_row,
@@ -296,6 +297,11 @@
@IF isset(:post_id)
THEN
AND _.post_id = :post_id
+ END @IF
+
+ @IF isset(:admin_id)
+ THEN
+ AND _.admin_id = :admin_id
END @IF
@IF isset(:type)
diff --git a/admin/sql/mysqli/site.sql b/admin/sql/mysqli/site.sql
index eb11260..284e5b8 100755
--- a/admin/sql/mysqli/site.sql
+++ b/admin/sql/mysqli/site.sql
@@ -1,10 +1,11 @@
--- Languages
+-- Sites
-- get all sites
PROCEDURE getAll(
IN start INT,
IN limit INT,
+ IN site_id ARRAY,
-- return array of sites for sites query
OUT fetch_all,
@@ -16,6 +17,14 @@
SELECT *, site_id as array_key
FROM site as sites
+ WHERE 1
+
+ -- site_id
+ @IF isset(:site_id)
+ THEN
+ AND sites.site_id IN (:site_id)
+ END @IF
+
-- limit
@IF isset(:limit)
THEN
@@ -150,4 +159,4 @@
END
-
\ No newline at end of file
+
diff --git a/admin/sql/pgsql/post.sql b/admin/sql/pgsql/post.sql
index 4374e4d..6f295f0 100755
--- a/admin/sql/pgsql/post.sql
+++ b/admin/sql/pgsql/post.sql
@@ -189,6 +189,7 @@
IN language_id INT,
IN comment_count INT,
IN comment_status INT,
+ IN admin_id INT,
IN type CHAR,
OUT fetch_row,
@@ -238,6 +239,11 @@
@IF isset(:post_id)
THEN
AND _.post_id = :post_id
+ END @IF
+
+ @IF isset(:admin_id)
+ THEN
+ AND _.admin_id = :admin_id
END @IF
@IF isset(:type)
diff --git a/admin/sql/pgsql/site.sql b/admin/sql/pgsql/site.sql
index 74c7215..64e934c 100755
--- a/admin/sql/pgsql/site.sql
+++ b/admin/sql/pgsql/site.sql
@@ -5,6 +5,7 @@
PROCEDURE getAll(
IN start INT,
IN limit INT,
+ IN site_id ARRAY,
-- return array of sites for sites query
OUT fetch_all,
@@ -16,6 +17,14 @@
SELECT *, site_id as array_key
FROM site as sites
+ WHERE 1
+
+ -- site_id
+ @IF isset(:site_id)
+ THEN
+ AND sites.site_id IN (:site_id)
+ END @IF
+
-- limit
@IF isset(:limit)
THEN
diff --git a/admin/sql/sqlite/post.sql b/admin/sql/sqlite/post.sql
index 92e8717..258e8b0 100755
--- a/admin/sql/sqlite/post.sql
+++ b/admin/sql/sqlite/post.sql
@@ -185,6 +185,7 @@
IN language_id INT,
IN comment_count INT,
IN comment_status INT,
+ IN admin_id INT,
IN type CHAR,
OUT fetch_row,
@@ -234,6 +235,11 @@
@IF isset(:post_id)
THEN
AND _.post_id = :post_id
+ END @IF
+
+ @IF isset(:admin_id)
+ THEN
+ AND _.admin_id = :admin_id
END @IF
@IF isset(:type)
diff --git a/admin/sql/sqlite/site.sql b/admin/sql/sqlite/site.sql
index 74c7215..284e5b8 100755
--- a/admin/sql/sqlite/site.sql
+++ b/admin/sql/sqlite/site.sql
@@ -1,10 +1,11 @@
--- Languages
+-- Sites
-- get all sites
PROCEDURE getAll(
IN start INT,
IN limit INT,
+ IN site_id ARRAY,
-- return array of sites for sites query
OUT fetch_all,
@@ -16,6 +17,14 @@
SELECT *, site_id as array_key
FROM site as sites
+ WHERE 1
+
+ -- site_id
+ @IF isset(:site_id)
+ THEN
+ AND sites.site_id IN (:site_id)
+ END @IF
+
-- limit
@IF isset(:limit)
THEN
diff --git a/install/sql/insert/admin/role.sql b/install/sql/insert/admin/role.sql
index 1e7ee69..f9a797c 100755
--- a/install/sql/insert/admin/role.sql
+++ b/install/sql/insert/admin/role.sql
@@ -1,10 +1,10 @@
INSERT INTO `role` (`role_id`, `name`, `display_name`, `permissions`) VALUES
-(1, 'super_admin', 'Super Administrator', '{"allow":["*"], "deny":[], "capabilities":["view_other_posts","edit_other_posts","view_other_products","edit_other_products"]}'),
-(2, 'admin', 'Administrator', '{"allow":["*"], "deny":["admin/*"], "capabilities":["view_other_posts","edit_other_posts","view_other_products","edit_other_products"]}'),
-(3, 'editor', 'Editor', '{"allow":["index/index","content/*", "editor/*","media/media/scan"], "deny":[], "capabilities":["view_other_posts","edit_other_posts","view_other_products","edit_other_products"]}'),
+(1, 'super_admin', 'Super Administrator', '{"allow":["*"], "deny":[], "capabilities":["view_other_posts","edit_other_posts","view_other_products","edit_other_products","view_other_sites","edit_other_sites"]}'),
+(2, 'admin', 'Administrator', '{"allow":["*"], "deny":["admin/*"], "capabilities":["view_other_posts","edit_other_posts","view_other_products","edit_other_products","view_other_sites","edit_other_sites"]}'),
+(3, 'editor', 'Editor', '{"allow":["index/index","content/*", "editor/*","media/media/scan"], "deny":[], "capabilities":["view_other_posts","edit_other_posts","view_other_products","edit_other_products","view_other_sites","edit_other_sites"]}'),
(4, 'author', 'Author', '{"allow":["index/index","content/*", "editor/*","media/media/scan"], "deny":[]}'),
(5, 'contributor', 'Contributor', '{"allow":["index/index","content/*", "editor/*","media/media/scan"], "deny":[]}'),
(6, 'shop', 'Shop', '{"allow":["index/index","product/*","order/*","media/media/scan"], "deny":[], "capabilities":["view_other_products","edit_other_products"]}'),
(7, 'vendor', 'Vendor', '{"allow":["index/index","product/*","order/*","media/media/scan"], "deny":["product/vendors/*","product/vendor/*","product/manufacturers/*", "product/manufacturer/*"]}'),
(8, 'rest', 'Rest', '{"allow":["content/*"],"deny":["*/save","*/delete"], "capabilities":["view_other_products","edit_other_products"]}}'),
-(9, 'demo', 'Demo', '{"allow":["*"],"deny":["*/save","*/delete","*/rename","*/upload", "*/activate","*/deactivate","*/update","*/deletemenu"], "capabilities":["view_other_posts","view_other_products"]}');
+(9, 'demo', 'Demo', '{"allow":["*"],"deny":["*/save","*/delete","*/rename","*/upload", "*/activate","*/deactivate","*/update","*/deletemenu"], "capabilities":["view_other_posts","view_other_products","view_other_sites"]}');
diff --git a/system/data/capabilities.php b/system/data/capabilities.php
index cc9c5fe..c7edb5a 100644
--- a/system/data/capabilities.php
+++ b/system/data/capabilities.php
@@ -27,4 +27,6 @@ return [
'edit_other_posts' => __('Edit other users posts'),
'view_other_products' => __('View other users products'),
'edit_other_products' => __('Edit other users products'),
+ 'view_other_sites' => __('View other users sites'),
+ 'edit_other_sites' => __('Edit other users sites'),
];