Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Avatars for users and admin. Capabilities for role.

givanz010d8c591a7d
diff --git a/admin/component/admin.php b/admin/component/admin.php
index 93c94fa..b6306e3 100755
--- a/admin/component/admin.php
+++ b/admin/component/admin.php
@@ -24,6 +24,7 @@ namespace Vvveb\Component;
use Vvveb\System\Component\ComponentBase;
use Vvveb\System\Event;
+use Vvveb\System\Images;
use Vvveb\System\User\Admin as AdminUser;
class Admin extends ComponentBase {
@@ -43,6 +44,11 @@ class Admin extends ComponentBase {
function results() {
$results = AdminUser::current();
+
+ if (isset($results['avatar'])) {
+ $results['avatar']= Images::image($results['avatar'], 'admin');
+ }
+
list($results) = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
diff --git a/admin/controller/admin/role.php b/admin/controller/admin/role.php
index 96c8481..0465ae8 100755
--- a/admin/controller/admin/role.php
+++ b/admin/controller/admin/role.php
@@ -37,24 +37,27 @@ class Role extends Base {
RoleList::mkmap(DIR_APP . 'controller', $tree);
$this->view->tree = $tree['controller'];
- $controllers = RoleList::getControllerList();
- $this->view->controllers = $controllers;
+ $controllers = RoleList::getControllerList();
+ $this->view->controllers = $controllers;
+ $this->view->capabilities = RoleList::getCapabilitiesList();
$role = new RoleSQL();
$this->view->role = $role->get(['role_id' => $role_id]);
if ($this->view->role) {
- $this->view->role['permissions'] = json_decode($this->view->role['permissions'], true);
- $this->view->role['permissions']['deny'] = $this->view->role['permissions']['deny'] ? $this->view->role['permissions']['deny'] : [];
- $this->view->role['permissions']['allow'] = $this->view->role['permissions']['allow'] ? $this->view->role['permissions']['allow'] : [];
+ $this->view->role['permissions'] = json_decode($this->view->role['permissions'], true);
+ $this->view->role['permissions']['deny'] = $this->view->role['permissions']['deny'] ?? [];
+ $this->view->role['permissions']['allow'] = $this->view->role['permissions']['allow'] ?? [];
+ $this->view->role['permissions']['capabilities'] = $this->view->role['permissions']['capabilities'] ?? [];
}
}
function save() {
- $data = $this->request->post['role'] ?? [];
- $allow = $this->request->post['allow'] ?? [];
- $deny = $this->request->post['deny'] ?? [];
- $permissions = ['deny' => $allow, 'allow' => $deny];
+ $data = $this->request->post['role'] ?? [];
+ $allow = $this->request->post['allow'] ?? [];
+ $deny = $this->request->post['deny'] ?? [];
+ $capabilities = $this->request->post['capabilities'] ?? [];
+ $permissions = ['deny' => $allow, 'allow' => $deny, 'capabilities' => $capabilities];
$role_id = $this->request->get['role_id'] ?? false;
diff --git a/admin/controller/base.php b/admin/controller/base.php
index b816e7d..d436316 100755
--- a/admin/controller/base.php
+++ b/admin/controller/base.php
@@ -80,14 +80,16 @@ class Base {
$default_custom_posts =
[
'post' => [
- 'type' => 'post',
- 'plural' => 'posts',
- 'icon' => 'icon-document-text-outline',
+ 'type' => 'post',
+ 'plural' => 'posts',
+ 'icon' => 'icon-document-text-outline',
+ 'comments'=> true,
],
'page' => [
- 'type' => 'page',
- 'plural' => 'pages',
- 'icon' => 'icon-document-outline',
+ 'type' => 'page',
+ 'plural' => 'pages',
+ 'icon' => 'icon-document-outline',
+ 'comments'=> false,
],
];
@@ -111,6 +113,10 @@ class Base {
$posts_menu[$type]['icon-img'] = $settings['icon-img'] ?? '';
$posts_menu[$type]['url'] .= "&type=$type";
+ if (isset($settings['comments']) && ! $settings['comments']) {
+ unset($posts_menu[$type]['items']['comments']);
+ }
+
foreach ($posts_menu[$type]['items'] as $item => &$values) {
if (isset($values['url'])) {
$values['url'] .= "&type=$type";
@@ -536,9 +542,14 @@ class Base {
$action = $action ?? $this->request->get['origaction'] ?? '';
$type = $type ?? $this->request->get['type'] ?? '';
$action = $action ? '/' . $action : '';
- $type = $type ? '/' . $type : '';
$url = 'https://docs.vvveb.com/';
+ if ($type == 'post' || $type == 'page'/* || $type == 'product'*/) {
+ $type = $type ? '/' . $type : '';
+ } else {
+ $type = '';
+ }
+
$documentionList = include DIR_SYSTEM . 'data/documentation-map.php';
if (isset($documentionList[$module . $action . $type])) {
diff --git a/admin/controller/content/edit.php b/admin/controller/content/edit.php
index 60dcb3e..6529067 100644
--- a/admin/controller/content/edit.php
+++ b/admin/controller/content/edit.php
@@ -132,7 +132,8 @@ class Edit extends Base {
foreach ($post[$this->object . '_content'] as &$content) {
if (! isset($post['url'])) {
$post['url'] = \Vvveb\url($route, ['slug'=> $content['slug']]);
- if (!$post['url']) {
+
+ if (! $post['url']) {
$post['url'] = \Vvveb\url($altRoute, ['slug'=> $content['slug']]);
}
}
@@ -149,7 +150,8 @@ class Edit extends Base {
$content['url'] = \Vvveb\url($route, $content + $language);
$content['revision_count'] = 0;
- if (!$content['url']) {
+
+ if (! $content['url']) {
$content['url'] = \Vvveb\url($altRoute, $content + $language);
}
@@ -197,8 +199,8 @@ class Edit extends Base {
//$view->validatorJson = $validator->getJSON();
$view->type = __($this->type);
$view->type_name = $type_name;
- $view->posts_list_url = \Vvveb\url(['module' => 'content/posts', 'type' => $this->type]);
- $view->revisions_url = \Vvveb\url(['module' => "$controller/revisions", 'type' => $this->type, $this->object . '_id' => $post_id]);
+ $view->posts_list_url = \Vvveb\url(['module' => $this->list, 'type' => $this->type]);
+ $view->revisions_url = \Vvveb\url(['module' => "$controller/revisions", 'object' => $this->object, 'type' => $this->type, $this->object . '_id' => $post_id]);
}
private function addCategory($taxonomy_id, $name) {
diff --git a/admin/controller/content/post.php b/admin/controller/content/post.php
index 794b4f9..4920a78 100755
--- a/admin/controller/content/post.php
+++ b/admin/controller/content/post.php
@@ -27,7 +27,9 @@ class Post extends Edit {
protected $object = 'post';
- protected $module = 'content/post';
+ protected $module = 'content/post';
+
+ protected $list = 'content/posts';
function save() {
parent::save();
diff --git a/admin/controller/content/posts.php b/admin/controller/content/posts.php
index 6cdc782..2fce788 100755
--- a/admin/controller/content/posts.php
+++ b/admin/controller/content/posts.php
@@ -28,6 +28,7 @@ use function Vvveb\humanReadable;
use Vvveb\Sql\PostSQL;
use Vvveb\System\Cache;
use Vvveb\System\Images;
+use Vvveb\System\User\Admin;
class Posts extends Base {
protected $type = 'post';
@@ -113,10 +114,19 @@ class Posts extends Base {
$this->type = $this->request->get['type'] ?? 'post';
$this->filter = $this->request->get['filter'] ?? [];
+
$options = [
'type' => $this->type,
'comment_count' => true,
- ] + $this->global + $this->filter;
+ ] + $this->global;
+
+ if (Admin::hasCapability('view_other_posts')) {
+ unset($options['admin_id']);
+ } else {
+ $options['admin_id'] = $this->global['admin_id'];
+ }
+
+ $options += $this->filter;
//override admin if admin_id filter set
if (isset($this->filter['admin_id'])) {
diff --git a/admin/controller/content/revisions.php b/admin/controller/content/revisions.php
index 91201d3..24324b8 100644
--- a/admin/controller/content/revisions.php
+++ b/admin/controller/content/revisions.php
@@ -30,6 +30,8 @@ use Vvveb\System\Images;
class Revisions extends Base {
protected $type = 'post';
+
+ protected $object = 'post';
//check for other modules permission like revision and editor to enable links like save/delete etc
protected $additionalPermissionCheck = ['content/revisions/save'];
@@ -40,14 +42,17 @@ class Revisions extends Base {
function init() {
if (isset($this->request->get['type'])) {
$this->type = $this->request->get['type'];
+ }
+ if (isset($this->request->get['object'])) {
+ $this->object = $this->request->get['object'];
}
-
- $this->revisions = model($this->type . '_content_revision');
- $this->post = model($this->type);
+
+ $this->revisions = model($this->object . '_content_revision');
+ $this->post = model($this->object);
$this->options = ['type' => $this->type];
- foreach ([$this->type . '_id', 'language_id', 'created_at'] as $param) {
+ foreach ([$this->object . '_id', 'language_id', 'created_at'] as $param) {
if (isset($this->request->get[$param])) {
$this->options[$param] = $this->request->get[$param];
}
@@ -97,7 +102,7 @@ class Revisions extends Base {
function index() {
$view = $this->view;
- $revisions = model($this->type . '_content_revision');
+ $revisions = model($this->object . '_content_revision');
$this->options += $this->global;
$revisions = $this->revisions->getAll($this->options); // all post/product revisions
@@ -105,7 +110,7 @@ class Revisions extends Base {
$post = $this->post->get($this->options); // post/product content
if (isset($post['image'])) {
- $post['image'] = $post['image'] = Images::image($post['image'], $this->type, 'thumb');
+ $post['image'] = $post['image'] = Images::image($post['image'], $this->object, 'thumb');
}
$results = [
@@ -118,7 +123,7 @@ class Revisions extends Base {
$view->limit = $this->options['limit'];
$view->type = $this->type;
- $view->revisionUrl = \Vvveb\url(['module' => 'content/revisions', 'action' => 'revision', 'type' => $this->type]);
+ $view->revisionUrl = \Vvveb\url(['module' => 'content/revisions', 'action' => 'revision', 'type' => $this->type, 'object' => $this->object]);
$view->type_name = humanReadable(__($this->type));
$view->type_name_plural = humanReadable(__($view->type . 's'));
}
diff --git a/admin/controller/editor/editor.php b/admin/controller/editor/editor.php
index 82816f0..1b9370e 100755
--- a/admin/controller/editor/editor.php
+++ b/admin/controller/editor/editor.php
@@ -116,7 +116,7 @@ class Editor extends Base {
$view->themeComponents = $components;
$view->themeSections = $sections;
$view->themeBlocks = $blocks;
- $view->themeJs = $themeJs;
+ $view->themeJs = $themeJs;
}
function index() {
diff --git a/admin/controller/product/product.php b/admin/controller/product/product.php
index c295440..3902c30 100755
--- a/admin/controller/product/product.php
+++ b/admin/controller/product/product.php
@@ -34,7 +34,9 @@ class Product extends Edit {
protected $object = 'product';
- protected $module = 'product/product';
+ protected $module = 'product/product';
+
+ protected $list = 'product/products';
protected $revisions = true;
diff --git a/admin/controller/product/products.php b/admin/controller/product/products.php
index 895e809..bb39aeb 100755
--- a/admin/controller/product/products.php
+++ b/admin/controller/product/products.php
@@ -28,6 +28,7 @@ use function Vvveb\humanReadable;
use Vvveb\Sql\ProductSQL;
use Vvveb\System\Core\View;
use Vvveb\System\Images;
+use Vvveb\System\User\Admin;
use function Vvveb\url;
class Products extends Base {
@@ -74,7 +75,15 @@ class Products extends Base {
$options = [
'type' => $this->type,
- ] + $this->global + $this->filter;
+ ] + $this->global;
+
+ if (Admin::hasCapability('view_other_products')) {
+ unset($options['admin_id']);
+ } else {
+ $options['admin_id'] = $this->global['admin_id'];
+ }
+
+ $options += $this->filter;
$results = $products->getAll($options);
diff --git a/admin/controller/product/revisions.php b/admin/controller/product/revisions.php
index 4eb4f1d..a8e208f 100644
--- a/admin/controller/product/revisions.php
+++ b/admin/controller/product/revisions.php
@@ -26,6 +26,8 @@ use Vvveb\Controller\Content\Revisions as RevisionsBase;
class Revisions extends RevisionsBase {
protected $type = 'product';
+
+ protected $object = 'product';
protected $additionalPermissionCheck = ['product/revisions/save'];
}
diff --git a/admin/controller/theme/themes.php b/admin/controller/theme/themes.php
index 9a50d5f..545e459 100755
--- a/admin/controller/theme/themes.php
+++ b/admin/controller/theme/themes.php
@@ -24,11 +24,27 @@ namespace Vvveb\Controller\Theme;
use function Vvveb\__;
use Vvveb\Controller\Base;
+use function Vvveb\rrmdir;
+use function Vvveb\sanitizeFileName;
use Vvveb\System\Extensions\Themes as ThemesList;
use Vvveb\System\Import\Theme;
use Vvveb\System\Sites;
class Themes extends Base {
+ function delete() {
+ $theme = sanitizeFileName(basename($this->request->get['theme'] ?? ''));
+
+ if ($theme) {
+ if (rrmdir(DIR_THEMES . DS . $theme)) {
+ $this->view->success[] = _('Theme removed!');
+ } else {
+ $this->view->errors[] = _('Error removing theme!');
+ }
+ }
+
+ return $this->index();
+ }
+
function upload() {
$files = $this->request->files;
$error = false;
diff --git a/admin/controller/user/user.php b/admin/controller/user/user.php
index c09b039..7db9ee6 100755
--- a/admin/controller/user/user.php
+++ b/admin/controller/user/user.php
@@ -51,15 +51,18 @@ class User extends Base {
unset($user['password']);
}
- //default user
- $user['image_url'] = Images::image($this->type);
- //featured image
- if (isset($user['image'])) {
- $user['image_url'] = Images::image($this->type, $user['image']);
+ //featured avatar
+ if (isset($user['avatar'])) {
+ $user['avatar_url'] = Images::image($user['avatar'], $this->type);
}
$view->user = $user;
}
+
+ $admin_path = \Vvveb\adminPath();
+ $controllerPath = $admin_path . 'index.php?module=media/media';
+ $view->scanUrl = "$controllerPath&action=scan";
+ $view->uploadUrl = "$controllerPath&action=upload";
}
function loginAs() {
diff --git a/admin/controller/user/users.php b/admin/controller/user/users.php
index db48e82..5f794a9 100755
--- a/admin/controller/user/users.php
+++ b/admin/controller/user/users.php
@@ -69,6 +69,10 @@ class Users extends Base {
if ($results[$type]) {
foreach ($results[$type] as $id => &$user) {
+ if (isset($user['avatar'])) {
+ $user['avatar']= Images::image($user['avatar'], 'admin');
+ }
+
$user['status_text'] = $user['status'] == '1' ? __('active') : __('inactive');
$user['image'] = Images::image($type, $user['image'] ?? '');
$user['delete-url'] = \Vvveb\url(['module' => $this->module, 'action' => 'delete'] + ["{$type}_id[]" => $user["{$type}_id"]]);
diff --git a/admin/sql/mysqli/post.sql b/admin/sql/mysqli/post.sql
index 3345b35..1d33909 100755
--- a/admin/sql/mysqli/post.sql
+++ b/admin/sql/mysqli/post.sql
@@ -34,7 +34,7 @@
)
BEGIN
- SELECT pd.*,posts.*,ad.username,ad.display_name,ad.admin_id,ad.email
+ SELECT pd.*,posts.*,ad.username,ad.display_name,ad.admin_id,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name
@IF isset(:comment_count)
THEN
,(SELECT COUNT(c.comment_id)
diff --git a/admin/sql/mysqli/product.sql b/admin/sql/mysqli/product.sql
index 1ab9d8b..e0397f2 100755
--- a/admin/sql/mysqli/product.sql
+++ b/admin/sql/mysqli/product.sql
@@ -42,8 +42,8 @@
,(SELECT pp.price FROM product_promotion pp
WHERE pp.product_id = _.product_id AND pp.user_group_id = :user_group_id
AND (
- (pp.from_date = '0000-00-00' OR pp.from_date < NOW())
- AND (pp.to_date = '0000-00-00' OR pp.to_date > NOW())
+ (pp.from_date = NULL OR pp.from_date < NOW())
+ AND (pp.to_date = NULL OR pp.to_date > NOW())
)
ORDER BY pp.priority ASC, pp.price ASC
LIMIT 1
@@ -716,6 +716,7 @@
IN language_id INT,
IN user_group_id INT,
IN site_id INT,
+ IN admin_id INT,
IN product_id ARRAY,
IN taxonomy_item_id INT,
IN manufacturer_id INT,
@@ -772,9 +773,9 @@
WHERE pd2.product_id = products.product_id
AND pd2.user_group_id = :user_group_id
AND pd2.quantity = '1'
- AND ((pd2.from_date = '0000-00-00'
+ AND ((pd2.from_date = NULL
OR pd2.from_date < NOW())
- AND (pd2.to_date = '0000-00-00'
+ AND (pd2.to_date = NULL
OR pd2.to_date > NOW()))
ORDER BY pd2.priority ASC, pd2.price ASC
LIMIT 1) AS discount
@@ -789,9 +790,9 @@
FROM product_promotion ps
WHERE ps.product_id = products.product_id
AND ps.user_group_id = :user_group_id
- AND ((ps.from_date = '0000-00-00'
+ AND ((ps.from_date = NULL
OR ps.from_date < NOW())
- AND (ps.to_date = '0000-00-00'
+ AND (ps.to_date = NULL
OR ps.to_date > NOW()))
ORDER BY ps.priority ASC, ps.price ASC
LIMIT 1) AS special
@@ -938,6 +939,11 @@
THEN
AND products.manufacturer_id = :manufacturer_id
END @IF
+
+ @IF isset(:admin_id) && !empty(:admin_id)
+ THEN
+ AND products.admin_id = :admin_id
+ END @IF
@IF isset(:vendor_id) && !empty(:vendor_id)
THEN
diff --git a/admin/sql/pgsql/post.sql b/admin/sql/pgsql/post.sql
index dffa4c6..4374e4d 100755
--- a/admin/sql/pgsql/post.sql
+++ b/admin/sql/pgsql/post.sql
@@ -34,7 +34,7 @@
)
BEGIN
- SELECT pd.*,posts.*,ad.username,ad.display_name,ad.admin_id,ad.email
+ SELECT pd.*,posts.*,ad.username,ad.display_name,ad.admin_id,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name
@IF isset(:comment_count)
THEN
,(SELECT COUNT(c.comment_id)
diff --git a/admin/sql/pgsql/product.sql b/admin/sql/pgsql/product.sql
index 6befc71..926e274 100755
--- a/admin/sql/pgsql/product.sql
+++ b/admin/sql/pgsql/product.sql
@@ -42,8 +42,8 @@
,(SELECT pp.price FROM product_promotion pp
WHERE pp.product_id = _.product_id AND pp.user_group_id = :user_group_id
AND (
- (pp.from_date = '0000-00-00' OR pp.from_date < NOW())
- AND (pp.to_date = '0000-00-00' OR pp.to_date > NOW())
+ (pp.from_date = NULL OR pp.from_date < NOW())
+ AND (pp.to_date = NULL OR pp.to_date > NOW())
)
ORDER BY pp.priority ASC, pp.price ASC
LIMIT 1
@@ -715,6 +715,7 @@
IN language_id INT,
IN user_group_id INT,
IN site_id INT,
+ IN admin_id INT,
IN product_id ARRAY,
IN taxonomy_item_id INT,
IN manufacturer_id INT,
@@ -772,9 +773,9 @@
WHERE pd2.product_id = products.product_id
AND pd2.user_group_id = :user_group_id
AND pd2.quantity = '1'
- AND ((pd2.from_date = '0000-00-00'
+ AND ((pd2.from_date = NULL
OR pd2.from_date < NOW())
- AND (pd2.to_date = '0000-00-00'
+ AND (pd2.to_date = NULL
OR pd2.to_date > NOW()))
ORDER BY pd2.priority ASC, pd2.price ASC
LIMIT 1) AS discount
@@ -789,9 +790,9 @@
FROM product_promotion ps
WHERE ps.product_id = products.product_id
AND ps.user_group_id = :user_group_id
- AND ((ps.from_date = '0000-00-00'
+ AND ((ps.from_date = NULL
OR ps.from_date < NOW())
- AND (ps.to_date = '0000-00-00'
+ AND (ps.to_date = NULL
OR ps.to_date > NOW()))
ORDER BY ps.priority ASC, ps.price ASC
LIMIT 1) AS special
@@ -943,6 +944,11 @@
THEN
AND products.manufacturer_id = :manufacturer_id
END @IF
+
+ @IF isset(:admin_id) && !empty(:admin_id)
+ THEN
+ AND products.admin_id = :admin_id
+ END @IF
@IF isset(:vendor_id) && !empty(:vendor_id)
THEN
diff --git a/admin/sql/sqlite/post.sql b/admin/sql/sqlite/post.sql
index 75a6767..92e8717 100755
--- a/admin/sql/sqlite/post.sql
+++ b/admin/sql/sqlite/post.sql
@@ -34,7 +34,7 @@
)
BEGIN
- SELECT pd.*,posts.*,ad.username,ad.display_name,ad.admin_id,ad.email
+ SELECT pd.*,posts.*,ad.username,ad.display_name,ad.admin_id,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name
@IF isset(:comment_count)
THEN
,(SELECT COUNT(c.comment_id)
diff --git a/admin/sql/sqlite/product.sql b/admin/sql/sqlite/product.sql
index 3b5e7f8..c75c033 100755
--- a/admin/sql/sqlite/product.sql
+++ b/admin/sql/sqlite/product.sql
@@ -42,8 +42,8 @@
,(SELECT pp.price FROM product_promotion pp
WHERE pp.product_id = _.product_id AND pp.user_group_id = :user_group_id
AND (
- (pp.from_date = '0000-00-00' OR pp.from_date < date('now'))
- AND (pp.to_date = '0000-00-00' OR pp.to_date > date('now'))
+ (pp.from_date = NULL OR pp.from_date < date('now'))
+ AND (pp.to_date = NULL OR pp.to_date > date('now'))
)
ORDER BY pp.priority ASC, pp.price ASC
LIMIT 1
@@ -716,6 +716,7 @@
IN language_id INT,
IN user_group_id INT,
IN site_id INT,
+ IN admin_id INT,
IN product_id ARRAY,
IN taxonomy_item_id INT,
IN manufacturer_id INT,
@@ -774,9 +775,9 @@
WHERE pd2.product_id = products.product_id
AND pd2.user_group_id = :user_group_id
AND pd2.quantity = '1'
- AND ((pd2.from_date = '0000-00-00'
+ AND ((pd2.from_date = NULL
OR pd2.from_date < date('now'))
- AND (pd2.to_date = '0000-00-00'
+ AND (pd2.to_date = NULL
OR pd2.to_date > date('now')))
ORDER BY pd2.priority ASC, pd2.price ASC
LIMIT 1) AS discount
@@ -791,9 +792,9 @@
FROM product_promotion ps
WHERE ps.product_id = products.product_id
AND ps.user_group_id = :user_group_id
- AND ((ps.from_date = '0000-00-00'
+ AND ((ps.from_date = NULL
OR ps.from_date < date('now'))
- AND (ps.to_date = '0000-00-00'
+ AND (ps.to_date = NULL
OR ps.to_date > date('now')))
ORDER BY ps.priority ASC, ps.price ASC
LIMIT 1) AS special
@@ -941,6 +942,11 @@
THEN
AND products.manufacturer_id = :manufacturer_id
END @IF
+
+ @IF isset(:admin_id) && !empty(:admin_id)
+ THEN
+ AND products.admin_id = :admin_id
+ END @IF
@IF isset(:vendor_id) && !empty(:vendor_id)
THEN
diff --git a/admin/template/admin/role.tpl b/admin/template/admin/role.tpl
index f012616..183484d 100755
--- a/admin/template/admin/role.tpl
+++ b/admin/template/admin/role.tpl
@@ -109,3 +109,23 @@ reset($tree);
$generate_menu($tree); }
$uniq = Vvveb\System\Functions\Str::random(5);
?>
+
+
+@capability = [data-v-capabilities] [data-v-capability]
+@capability|deleteAllButFirstChild
+
+@capability|before = <?php
+if(isset($this->capabilities) && is_array($this->capabilities)) {
+ foreach ($this->capabilities as $value => $name) {?>
+
+
+ @capability [data-v-capability-name]|innerText = $name
+ @capability [data-v-capability-value] = $value
+ @capability [data-v-capability-value]|name = <?php echo "capabilities[$value]";?>
+ @capability [data-v-capability-value]|addNewAttribute = <?php
+ if (in_array($value, $this->role['permissions']['capabilities'])) echo 'checked';
+ ?>
+
+ @capability|after = <?php
+ }
+}?>
diff --git a/admin/template/admin/user.tpl b/admin/template/admin/user.tpl
index 3e3ecdc..0f45564 100755
--- a/admin/template/admin/user.tpl
+++ b/admin/template/admin/user.tpl
@@ -43,3 +43,8 @@ import(common.tpl)
[data-v-role-list] [data-v-role]|after = <?php
}
?>
+
+/* Avatar */
+[data-v-user] [data-v-avatar]|data-v-avatar = $this->user['avatar_url']
+[data-v-user] input[data-v-avatar]|value = $this->user['avatar']
+[data-v-user] img[data-v-avatar]|src = <?php echo (isset($this->user['avatar_url']) && $this->user['avatar_url']) ? $this->user['avatar_url'] : 'img/placeholder.svg';?>
diff --git a/admin/template/components/admin.tpl b/admin/template/components/admin.tpl
index 84d4ce8..2cf0f3a 100755
--- a/admin/template/components/admin.tpl
+++ b/admin/template/components/admin.tpl
@@ -7,6 +7,7 @@
?>
[data-v-component-admin] [data-v-admin-*]|innerText = $admin['@@__data-v-admin-(*)__@@']
+[data-v-component-admin] img[data-v-admin-*]|src = $admin['@@__data-v-admin-(*)__@@']
[data-v-component-admin] a[data-v-admin-edit-url]|href = $admin['edit-url']
[data-v-component-admin]|append = <?php
diff --git a/admin/template/content/revisions.tpl b/admin/template/content/revisions.tpl
index aab2fb3..f435d96 100644
--- a/admin/template/content/revisions.tpl
+++ b/admin/template/content/revisions.tpl
@@ -16,3 +16,7 @@ foreach ($this->revisions as $revision) {?>
@revision|after = <?php
}
?>
+
+[data-v-type_name_plural] = $this->type_name_plural
+[data-v-type-name] = $this->type_name
+[data-v-type] = $this->type
diff --git a/admin/template/product/revisions.tpl b/admin/template/product/revisions.tpl
index aab2fb3..f435d96 100644
--- a/admin/template/product/revisions.tpl
+++ b/admin/template/product/revisions.tpl
@@ -16,3 +16,7 @@ foreach ($this->revisions as $revision) {?>
@revision|after = <?php
}
?>
+
+[data-v-type_name_plural] = $this->type_name_plural
+[data-v-type-name] = $this->type_name
+[data-v-type] = $this->type
diff --git a/admin/template/user/user.tpl b/admin/template/user/user.tpl
index cb769e5..0ed4d88 100755
--- a/admin/template/user/user.tpl
+++ b/admin/template/user/user.tpl
@@ -1,3 +1,8 @@
import(crud.tpl, {"type":"user"})
[data-v-user] select[data-v-user-*] option|addNewAttribute = <?php if (isset($this->user) && $this->user['status'] == '@@__value__@@') echo 'selected';?>
+
+/* Avatar */
+[data-v-user] [data-v-avatar]|data-v-avatar = $this->user['avatar_url']
+[data-v-user] input[data-v-avatar]|value = $this->user['avatar']
+[data-v-user] img[data-v-avatar]|src = <?php echo (isset($this->user['avatar_url']) && $this->user['avatar_url']) ? $this->user['avatar_url'] : 'img/placeholder.svg';?>
diff --git a/app/component/breadcrumb.php b/app/component/breadcrumb.php
index 2866788..481605c 100755
--- a/app/component/breadcrumb.php
+++ b/app/component/breadcrumb.php
@@ -41,20 +41,21 @@ class Breadcrumb extends ComponentBase {
}
function results() {
- $request = Request::getInstance();
- $route = $request->get['route'] ?? '';
- $slug = $request->get['slug'] ?? '';
- $name = $request->get['name'] ?? '';
+ $request = Request::getInstance();
+ $route = $request->get['route'] ?? '';
+ $slug = $request->get['slug'] ?? '';
+ $name = $request->get['name'] ?? '';
+ $homeText = __('Home');
$breadcrumb = [
- ['text' => 'home', 'url' => '/'],
+ ['text' => $homeText, 'url' => '/'],
];
switch ($route) {
//product page
case 'product/product/index':
$breadcrumb = [
- ['text' => 'home', 'url' => '/'],
+ ['text' => __('Home'), 'url' => '/'],
];
$product_id = $request->get['product_id'] ?? false;
@@ -72,14 +73,14 @@ class Breadcrumb extends ComponentBase {
]);
}
}
-
+
$breadcrumb[] = ['text' => $name, 'url' => false];
break;
//product category page
case 'product/category/index':
$breadcrumb = [
- ['text' => 'home', 'url' => '/'],
+ ['text' => $homeText, 'url' => '/'],
['text' => $slug, 'url' => false],
];
@@ -87,7 +88,7 @@ class Breadcrumb extends ComponentBase {
//shop page
case 'product/index':
$breadcrumb = [
- ['text' => 'home', 'url' => '/'],
+ ['text' => $homeText, 'url' => '/'],
['text' => 'shop', 'url' => false],
];
@@ -95,7 +96,7 @@ class Breadcrumb extends ComponentBase {
//manufacturer page
case 'product/manufacturer/index':
$breadcrumb = [
- ['text' => 'home', 'url' => '/'],
+ ['text' => $homeText, 'url' => '/'],
['text' => $slug, 'url' => false],
];
@@ -103,7 +104,7 @@ class Breadcrumb extends ComponentBase {
//vendor page
case 'product/vendor/index':
$breadcrumb = [
- ['text' => 'home', 'url' => '/'],
+ ['text' => $homeText, 'url' => '/'],
['text' => $slug, 'url' => false],
];
@@ -112,7 +113,7 @@ class Breadcrumb extends ComponentBase {
case 'content':
case 'content/index':
$breadcrumb = [
- ['text' => 'home', 'url' => '/'],
+ ['text' => $homeText, 'url' => '/'],
['text' => __('blog'), 'url' => false],
];
@@ -129,7 +130,7 @@ class Breadcrumb extends ComponentBase {
}
$breadcrumb = [
- ['text' => 'home', 'url' => '/'],
+ ['text' => $homeText, 'url' => '/'],
['text' => $result['name'], 'url' => url('content/category/index', $result)],
['text' => $slug, 'url' => false],
];
@@ -147,7 +148,7 @@ class Breadcrumb extends ComponentBase {
}
$breadcrumb = [
- ['text' => 'home', 'url' => '/'],
+ ['text' => $homeText, 'url' => '/'],
['text' => $slug, 'url' => false],
];
@@ -155,7 +156,7 @@ class Breadcrumb extends ComponentBase {
//post category page
case 'content/category/index':
$breadcrumb = [
- ['text' => 'home', 'url' => '/'],
+ ['text' => $homeText, 'url' => '/'],
['text' => $slug, 'url' => false],
];
diff --git a/app/component/post.php b/app/component/post.php
index 9582c4f..b5838c5 100755
--- a/app/component/post.php
+++ b/app/component/post.php
@@ -56,6 +56,10 @@ class Post extends ComponentBase {
$results['image'] = Images::image($results['image'], 'post');
}
+ if (isset($results['avatar'])) {
+ $results['avatar'] = Images::image($results['avatar'], 'admin');
+ }
+
//comments translations
$results['comment_count'] = $results['comment_count'] ?? 0;
$results['comment_text'] = sprintf(__('%d comment', '%d comments', (int)$results['comment_count']), $results['comment_count']);
diff --git a/app/component/posts.php b/app/component/posts.php
index 5d4dc6e..6ca252a 100755
--- a/app/component/posts.php
+++ b/app/component/posts.php
@@ -147,6 +147,10 @@ class Posts extends ComponentBase {
$post['image'] = $post['images'][] = Images::image($post['image'], 'post', $this->options['image_size']);
}
+ if (isset($post['avatar'])) {
+ $post['avatar'] = $post['avatar'] = Images::image($post['avatar'], 'admin');
+ }
+
if (empty($post['excerpt']) && ! empty($post['content'])) {
$post['excerpt'] = substr(strip_tags($post['content']), 0, $this->options['excerpt_limit']);
}
diff --git a/app/controller/base.php b/app/controller/base.php
index baffc30..5dc7d6a 100755
--- a/app/controller/base.php
+++ b/app/controller/base.php
@@ -151,6 +151,7 @@ class Base {
$site = siteSettings();
$user = User::current();
+ $site['url'] = '//' . $_SERVER['HTTP_HOST'] ?? '';
$this->global['site_id'] = SITE_ID ?? 1;
$this->global['user_id'] = $user['user_id'] ?? false;
diff --git a/app/controller/product/vendor.php b/app/controller/product/vendor.php
index 9fdd119..6211f88 100755
--- a/app/controller/product/vendor.php
+++ b/app/controller/product/vendor.php
@@ -25,6 +25,7 @@ namespace Vvveb\Controller\Product;
use \Vvveb\Sql\VendorSQL;
use function Vvveb\__;
use Vvveb\Controller\Base;
+use Vvveb\System\Images;
class Vendor extends Base {
function index() {
@@ -37,9 +38,12 @@ class Vendor extends Base {
$vendor = $vendorSql->get($options);
if ($vendor) {
+ if (isset($vendor['image'])) {
+ $vendor['image_url'] = Images::image($vendor['image'], 'vendor');
+ }
+
$this->request->request['vendor_id'] = $vendor['vendor_id'];
$this->view->vendor = $vendor;
- $this->view->vendor_name = $vendor['name'];
} else {
$message = __('Vendor not found!');
$this->notFound(true, $message);
diff --git a/app/sql/mysqli/admin.sql b/app/sql/mysqli/admin.sql
new file mode 100755
index 0000000..3a1e561
--- /dev/null
+++ b/app/sql/mysqli/admin.sql
@@ -0,0 +1,5 @@
+-- Admin
+
+ -- get common code from admin
+ import(/admin/admin.sql);
+
diff --git a/app/sql/mysqli/post.sql b/app/sql/mysqli/post.sql
index 8b266e7..3a191f9 100755
--- a/app/sql/mysqli/post.sql
+++ b/app/sql/mysqli/post.sql
@@ -18,7 +18,7 @@
)
BEGIN
- SELECT _.*,pd.*,ad.admin_id,ad.username,ad.display_name,ad.email
+ SELECT _.*,pd.*,ad.admin_id,ad.username,ad.display_name,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name
@IF isset(:comment_count)
THEN
diff --git a/app/sql/pgsql/admin.sql b/app/sql/pgsql/admin.sql
new file mode 100755
index 0000000..3a1e561
--- /dev/null
+++ b/app/sql/pgsql/admin.sql
@@ -0,0 +1,5 @@
+-- Admin
+
+ -- get common code from admin
+ import(/admin/admin.sql);
+
diff --git a/app/sql/pgsql/post.sql b/app/sql/pgsql/post.sql
index 7ec6df4..dde06f0 100755
--- a/app/sql/pgsql/post.sql
+++ b/app/sql/pgsql/post.sql
@@ -18,7 +18,7 @@
)
BEGIN
- SELECT _.*,pd.*,ad.admin_id,ad.username,ad.display_name,ad.email
+ SELECT _.*,pd.*,ad.admin_id,ad.username,ad.display_name,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name
@IF isset(:comment_count)
THEN
diff --git a/app/sql/sqlite/admin.sql b/app/sql/sqlite/admin.sql
new file mode 100755
index 0000000..3a1e561
--- /dev/null
+++ b/app/sql/sqlite/admin.sql
@@ -0,0 +1,5 @@
+-- Admin
+
+ -- get common code from admin
+ import(/admin/admin.sql);
+
diff --git a/app/sql/sqlite/post.sql b/app/sql/sqlite/post.sql
index 3c91738..c197af8 100755
--- a/app/sql/sqlite/post.sql
+++ b/app/sql/sqlite/post.sql
@@ -18,7 +18,7 @@
)
BEGIN
- SELECT _.*,pd.*,ad.admin_id,ad.username,ad.display_name,ad.email
+ SELECT _.*,pd.*,ad.admin_id,ad.username,ad.display_name,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name
@IF isset(:comment_count)
THEN
diff --git a/app/template/common.tpl b/app/template/common.tpl
index 7a88df0..61182ce 100755
--- a/app/template/common.tpl
+++ b/app/template/common.tpl
@@ -30,7 +30,7 @@ if (isset($_COOKIE['theme'])) {
$vvveb_is_page_edit = Vvveb\isEditor();
?>
-[data-v-global-*] = <?php
+[data-v-global-*]|innerText = <?php
$name = '@@__data-v-global-(*)__@@';
$path = str_replace('-', '.', $name);
if (isset($this->global) && $path) {
@@ -46,6 +46,14 @@ if (isset($this->global) && $path) {
}
?>
+a[data-v-global-*]|href = <?php
+$name = '@@__data-v-global-(*)__@@';
+$path = str_replace('-', '.', $name);
+if (isset($this->global) && $path) {
+ echo \Vvveb\arrayPath($this->global, $path);
+}
+?>
+
head > link[hreflang]|deleteAllButFirst
diff --git a/app/template/components/menu.tpl b/app/template/components/menu.tpl
index 7871703..5ffa6ff 100755
--- a/app/template/components/menu.tpl
+++ b/app/template/components/menu.tpl
@@ -15,7 +15,7 @@ if (isset($this->_component['menu']) && isset($this->_component['menu'][$_menu_i
//$_pagination_count = $this->menu[$_menu_idx]['count'];
//$_pagination_limit = $this->categories[$_menu_idx]['limit'];
$_categories = $this->_component['menu'][$_menu_idx]['menus'] ?? [];
- if ($vvveb_is_page_edit) {
+ if (isset($vvveb_is_page_edit) && $vvveb_is_page_edit) {
$_categories = [
['menu_item_id' => 1, 'parent_id' => 0, 'children' => 1, 'class' => 'vvveb-hidden'],
['menu_item_id' => 2, 'parent_id' => 1, 'children' => 0, 'class' => 'vvveb-hidden'],
@@ -66,4 +66,4 @@ $generate_menu = function ($parent_id) use (&$_categories, &$generate_menu, &$pa
@category-recursive|after = <?php
}
-?>
\ No newline at end of file
+?>
diff --git a/app/template/editor.tpl b/app/template/editor.tpl
index c0b252b..b376c91 100755
--- a/app/template/editor.tpl
+++ b/app/template/editor.tpl
@@ -1,6 +1,6 @@
//set editing flag
head|append = <?php
-$vvveb_is_page_edit = $vvveb_is_page_edit = Vvveb\isEditor();
+$vvveb_is_page_edit = Vvveb\isEditor();
$is_admin = \Vvveb\isAdmin();
if ($is_admin && !$vvveb_is_page_edit) {
echo '<link href="' . Vvveb\publicUrlPath() . 'admin/default/css/admin-bar.css" rel="stylesheet">';
diff --git a/app/template/product/vendor.tpl b/app/template/product/vendor.tpl
index c8b4ad1..baf6c15 100755
--- a/app/template/product/vendor.tpl
+++ b/app/template/product/vendor.tpl
@@ -2,4 +2,6 @@ import(common.tpl)
head > title = <?php echo htmlentities(ucfirst($this->vendor_name));?>
-[data-v-vendor-name] = <?php echo htmlentities(ucfirst($this->vendor_name));?>
+[data-v-vendor-*]|innerText = $this->vendor['@@__data-v-vendor-(*)__@@']
+img[data-v-vendor-*]|src = $this->vendor['@@__data-v-vendor-(*)__@@']
+[data-v-vendor-name] = <?php echo htmlentities(ucfirst($this->vendor['name']));?>
diff --git a/app/validate/signup.php b/app/validate/signup.php
index 8aa064f..cf224d3 100755
--- a/app/validate/signup.php
+++ b/app/validate/signup.php
@@ -39,4 +39,7 @@ return [
'minLength' => 6,
'maxLength' => 32,
],
+ 'confirm_password' => [
+ 'match' => 'password',
+ ],
];
diff --git a/config/routes.php b/config/routes.php
index fae67dc..7f4208c 100755
--- a/config/routes.php
+++ b/config/routes.php
@@ -78,14 +78,15 @@ return [
'/{language{2,5}}/product/{slug}' => ['module' => 'product/product/index', 'edit'=>'?module=product/product&slug={slug}'],
//catalog
- '/shop' => ['module' => 'product/index'],
- '/shop/#page#' => ['module' => 'product/index'],
- '/shop/{slug}' => ['module' => 'product/category/index'],
- '/shop/{slug}/#page#' => ['module' => 'product/category/index'],
- '/shop/{slug}/#page#/filters-{filters}' => ['module' => 'product/category/index'],
- '/manufacturer/{slug}' => ['module' => 'product/manufacturer/index'],
- '/vendor/{slug}' => ['module' => 'product/vendor/index'],
- '/product/{slug}' => ['module' => 'product/product/index', 'edit'=>'?module=product/product&slug={slug}'],
+ '/shop' => ['module' => 'product/index'],
+ '/shop/#page#' => ['module' => 'product/index'],
+ '/shop/{slug}' => ['module' => 'product/category/index'],
+ '/shop/{slug}/#page#' => ['module' => 'product/category/index'],
+ '/shop/{slug}/#page#/filters-{filters}' => ['module' => 'product/category/index'],
+ '/manufacturer/{slug}' => ['module' => 'product/manufacturer/index'],
+ '/vendor/{slug}' => ['module' => 'product/vendor/index'],
+ '/vendor/{slug}/#page#' => ['module' => 'product/vendor/index'],
+ '/product/{slug}' => ['module' => 'product/product/index', 'edit'=>'?module=product/product&slug={slug}'],
//compare
'/cart/compare' => ['module' => 'cart/compare/index'],
@@ -93,14 +94,15 @@ return [
'/cart/compare/remove/#product_id#' => ['module' => 'cart/compare/remove'],
//multi language catalog - language code must be at least 2 characters
- '/{language{2,5}}/shop' => ['module' => 'product/index'],
- '/{language{2,5}}/shop/#page#' => ['module' => 'product/index'],
- '/{language{2,5}}/shop/{slug}' => ['module' => 'product/category/index'],
- '/{language{2,5}}/shop/{slug}/#page#' => ['module' => 'product/category/index'],
- '/{language{2,5}}/shop/{slug}/#page#/filters-{filters}' => ['module' => 'product/category/index'],
- '/{language{2,5}}/manufacturer/{slug}' => ['module' => 'product/manufacturer/index'],
- '/{language{2,5}}/vendor/{slug}' => ['module' => 'product/vendor/index'],
- '/{language{2,5}}/product/{slug}' => ['module' => 'product/product/index', 'edit'=>'?module=product/product&slug={slug}'],
+ '/{language{2,5}}/shop' => ['module' => 'product/index'],
+ '/{language{2,5}}/shop/#page#' => ['module' => 'product/index'],
+ '/{language{2,5}}/shop/{slug}' => ['module' => 'product/category/index'],
+ '/{language{2,5}}/shop/{slug}/#page#' => ['module' => 'product/category/index'],
+ '/{language{2,5}}/shop/{slug}/#page#/filters-{filters}' => ['module' => 'product/category/index'],
+ '/{language{2,5}}/manufacturer/{slug}' => ['module' => 'product/manufacturer/index'],
+ '/{language{2,5}}/vendor/{slug}' => ['module' => 'product/vendor/index'],
+ '/{language{2,5}}/vendor/{slug}/#page#' => ['module' => 'product/vendor/index'],
+ '/{language{2,5}}/product/{slug}' => ['module' => 'product/product/index', 'edit'=>'?module=product/product&slug={slug}'],
//checkout
'/cart' => ['module' => 'cart/cart/index'],
diff --git a/install/sql/insert/admin/admin.sql b/install/sql/insert/admin/admin.sql
index edffc58..38f19d8 100755
--- a/install/sql/insert/admin/admin.sql
+++ b/install/sql/insert/admin/admin.sql
@@ -1,10 +1,11 @@
-INSERT INTO `admin` (`admin_id`, `username`, `first_name`, `last_name`,`password`, `email`, `url`, `created_at`, `token`, `status`, `display_name`, `role_id`) VALUES
+INSERT INTO `admin` (`admin_id`, `username`, `first_name`, `last_name`,`password`, `email`, `url`, `created_at`, `token`, `status`, `display_name`, `avatar`, `bio`, `role_id`) VALUES
-(1, 'admin', 'Admin', 'Admin', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Admin', 1),
-(2, 'administrator', 'Administrator', 'Administrator', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Administrator', 2),
-(3, 'editor', 'Editor', 'Editor','$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Editor', 3),
-(4, 'author', 'Author', 'Author', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Author', 4),
-(5, 'contributor', 'Contributor', 'Contributor', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Contributor', 5),
-(6, 'shop', 'Shop', 'Shop', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Shop assistant', 6),
-(7, 'rest', 'Rest', 'Rest', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Rest Api', 7),
-(8, 'demo', 'Demo', 'Demo', '$2y$11$oNa5z5S1gabs8vB/GU9KRuFxw1psuMx8rPaVjnVLm8mm./ufAiRgm', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Demo', 8);
\ No newline at end of file
+(1, 'admin', 'Admin', 'Admin', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Admin', 'vvveb.svg', 'This is a brief biography', 1),
+(2, 'administrator', 'Administrator', 'Administrator', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Administrator', 'vvveb.svg', 'This is a brief biography', 2),
+(3, 'editor', 'Editor', 'Editor','$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Editor', 'vvveb.svg', 'This is a brief biography', 3),
+(4, 'author', 'Author', 'Author', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Author', 'vvveb.svg', 'This is a brief biography', 4),
+(5, 'contributor', 'Contributor', 'Contributor', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Contributor', 'vvveb.svg', 'This is a brief biography', 5),
+(6, 'shop', 'Shop', 'Shop', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Shop assistant', 'vvveb.svg', 'This is a brief biography', 6),
+(7, 'vendor', 'Vendor', 'Vendor', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Vendor', 'vvveb.svg', 'This is a brief biography', 7),
+(8, 'rest', 'Rest', 'Rest', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Rest Api', 'vvveb.svg', 'This is a brief biography', 8),
+(9, 'demo', 'Demo', 'Demo', '$2y$11$oNa5z5S1gabs8vB/GU9KRuFxw1psuMx8rPaVjnVLm8mm./ufAiRgm', '[email protected]', '', '2022-05-01 00:00:00', '', 0, 'Demo', 'vvveb.svg', 'This is a brief biography', 9);
\ No newline at end of file
diff --git a/install/sql/insert/admin/role.sql b/install/sql/insert/admin/role.sql
index 98dc492..1e7ee69 100755
--- a/install/sql/insert/admin/role.sql
+++ b/install/sql/insert/admin/role.sql
@@ -1,9 +1,10 @@
INSERT INTO `role` (`role_id`, `name`, `display_name`, `permissions`) VALUES
-(1, 'super_admin', 'Super Administrator', '{"allow":["*"], "deny":[]}'),
-(2, 'admin', 'Administrator', '{"allow":["*"], "deny":["admin/*"]}'),
-(3, 'editor', 'Editor', '{"allow":["index/index","content/*", "editor/*"], "deny":[]}'),
-(4, 'author', 'Author', '{"allow":["index/index","content/*", "editor/*"], "deny":[]}'),
-(5, 'contributor', 'Contributor', '{"allow":["index/index","content/*", "editor/*"], "deny":[]}'),
-(6, 'shop', 'Shop', '{"allow":["index/index","product/*","order/*"], "deny":[]}'),
-(7, 'rest', 'Rest', '{"allow":["content/*"],"deny":["*/save","*/delete"]}'),
-(8, 'demo', 'Demo', '{"allow":["*"],"deny":["*/save","*/delete","*/rename","*/upload", "*/activate","*/deactivate","*/update","*/deletemenu"]}');
+(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"]}'),
+(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"]}');
diff --git a/install/sql/insert/product/vendor.sql b/install/sql/insert/product/vendor.sql
index 8329d88..05e8d60 100755
--- a/install/sql/insert/product/vendor.sql
+++ b/install/sql/insert/product/vendor.sql
@@ -1,7 +1,7 @@
INSERT INTO `vendor` VALUES
-(1,'Vendor 1','vendor-1','posts/1.jpg',0),
-(2,'Vendor 2','vendor-2','posts/2.jpg',0),
-(3,'Vendor 3','vendor-3','posts/3.jpg',0),
-(4,'Vendor 4','vendor-4','posts/4.jpg',0),
-(5,'Vendor 5','vendor-5','posts/5.jpg',0),
-(6,'Vendor 6','vendor-6','posts/6.jpg',0);
+(1,1,'Vendor 1','vendor-1','posts/1.jpg',0),
+(2,1,'Vendor 2','vendor-2','posts/2.jpg',0),
+(3,1,'Vendor 3','vendor-3','posts/3.jpg',0),
+(4,1,'Vendor 4','vendor-4','posts/4.jpg',0),
+(5,1,'Vendor 5','vendor-5','posts/5.jpg',0),
+(6,1,'Vendor 6','vendor-6','posts/6.jpg',0);
diff --git a/install/sql/insert/user/user.sql b/install/sql/insert/user/user.sql
index f3ccee8..1dcbab4 100755
--- a/install/sql/insert/user/user.sql
+++ b/install/sql/insert/user/user.sql
@@ -1,2 +1,2 @@
-INSERT INTO `user` (`user_id`, `username`, `first_name`, `last_name`, `password`, `email`, `url`, `created_at`, `token`, `status`, `display_name`) VALUES
-(1, 'johndoe', 'John', 'Doe', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', '2022-05-01 00:00:00', '', 1, 'johndoe');
+INSERT INTO `user` (`user_id`, `username`, `first_name`, `last_name`, `password`, `email`, `url`, `display_name`, `created_at`, `token`, `avatar`, `bio`, `status`) VALUES
+(1, 'johndoe', 'John', 'Doe', '$2y$11$o52ahesifBsklkPV8eTWSeoKbBHJXxaoDZUIDYiFYdAmHQSyfDM3W', '[email protected]', '', 'johndoe', '2022-05-01 00:00:00', '', 'placeholder.svg', 'This is a brief biography', 1);
diff --git a/install/sql/mysqli/schema/admin/admin.sql b/install/sql/mysqli/schema/admin/admin.sql
index f13514a..99d65e9 100755
--- a/install/sql/mysqli/schema/admin/admin.sql
+++ b/install/sql/mysqli/schema/admin/admin.sql
@@ -10,6 +10,8 @@ CREATE TABLE `admin` (
`phone_number` varchar(32) NOT NULL DEFAULT '',
`url` varchar(100) NOT NULL DEFAULT '',
`display_name` varchar(250) NOT NULL DEFAULT '',
+ `avatar` varchar(250) NOT NULL DEFAULT '',
+ `bio` text,
`role_id` INT UNSIGNED DEFAULT NULL,
`status` INT UNSIGNED NOT NULL DEFAULT '0',
`token` varchar(32) NOT NULL DEFAULT '',
diff --git a/install/sql/mysqli/schema/product/product.sql b/install/sql/mysqli/schema/product/product.sql
index a03657b..05a11af 100755
--- a/install/sql/mysqli/schema/product/product.sql
+++ b/install/sql/mysqli/schema/product/product.sql
@@ -2,6 +2,7 @@ DROP TABLE IF EXISTS `product`;
CREATE TABLE `product` (
`product_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ `admin_id` INT unsigned NOT NULL DEFAULT '0',
`parent_id` INT UNSIGNED NOT NULL DEFAULT 0,
`model` varchar(64) NOT NULL,
`sku` varchar(64) NOT NULL,
diff --git a/install/sql/mysqli/schema/product/vendor.sql b/install/sql/mysqli/schema/product/vendor.sql
index 865a3c7..2610491 100755
--- a/install/sql/mysqli/schema/product/vendor.sql
+++ b/install/sql/mysqli/schema/product/vendor.sql
@@ -2,6 +2,7 @@ DROP TABLE IF EXISTS `vendor`;
CREATE TABLE `vendor` (
`vendor_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ `admin_id` INT unsigned NOT NULL DEFAULT '0',
`name` varchar(191) NOT NULL DEFAULT "",
`slug` varchar(191) NOT NULL DEFAULT "",
`image` varchar(191) NOT NULL,
diff --git a/install/sql/mysqli/schema/user/user.sql b/install/sql/mysqli/schema/user/user.sql
index 5de96fd..8447611 100755
--- a/install/sql/mysqli/schema/user/user.sql
+++ b/install/sql/mysqli/schema/user/user.sql
@@ -13,6 +13,7 @@ CREATE TABLE `user` (
`status` INT UNSIGNED NOT NULL DEFAULT '0',
`display_name` varchar(250) NOT NULL DEFAULT '',
`avatar` varchar(250) NOT NULL DEFAULT '',
+ `bio` text,
`token` varchar(32) NOT NULL DEFAULT '',
-- `fields` text NOT NULL DEFAULT '',
`subscribe` tinyint NOT NULL DEFAULT 0,
diff --git a/install/sql/pgsql/schema/admin/admin.sql b/install/sql/pgsql/schema/admin/admin.sql
index e181173..cbce022 100755
--- a/install/sql/pgsql/schema/admin/admin.sql
+++ b/install/sql/pgsql/schema/admin/admin.sql
@@ -13,6 +13,8 @@ CREATE TABLE "admin" (
"phone_number" varchar(32) NOT NULL DEFAULT '',
"url" varchar(100) NOT NULL DEFAULT '',
"display_name" varchar(250) NOT NULL DEFAULT '',
+ "avatar" varchar(250) NOT NULL DEFAULT '',
+ "bio" varchar(250) NOT NULL DEFAULT '',
"role_id" int check ("role_id" > 0) DEFAULT NULL,
"status" int check ("status" >= 0) NOT NULL DEFAULT 0,
"token" varchar(32) NOT NULL DEFAULT '',
diff --git a/install/sql/pgsql/schema/product/product.sql b/install/sql/pgsql/schema/product/product.sql
index 15066d0..d7a694f 100755
--- a/install/sql/pgsql/schema/product/product.sql
+++ b/install/sql/pgsql/schema/product/product.sql
@@ -6,6 +6,7 @@ CREATE SEQUENCE product_seq;
CREATE TABLE product (
"product_id" int check ("product_id" > 0) NOT NULL DEFAULT NEXTVAL ('product_seq'),
+ "admin_id" int check ("admin_id" >= 0) NOT NULL DEFAULT 0,
"model" varchar(64) NOT NULL,
"sku" varchar(64) NOT NULL,
"upc" varchar(12) NOT NULL,
diff --git a/install/sql/pgsql/schema/product/vendor.sql b/install/sql/pgsql/schema/product/vendor.sql
index 8ecaf60..ea0da33 100755
--- a/install/sql/pgsql/schema/product/vendor.sql
+++ b/install/sql/pgsql/schema/product/vendor.sql
@@ -6,6 +6,7 @@ CREATE SEQUENCE vendor_seq;
CREATE TABLE vendor (
"vendor_id" int check ("vendor_id" > 0) NOT NULL DEFAULT NEXTVAL ('vendor_seq'),
+ "admin_id" int check ("admin_id" >= 0) NOT NULL DEFAULT 0,
"name" varchar(191) NOT NULL DEFAULT '',
"slug" varchar(191) NOT NULL DEFAULT '',
"image" varchar(191) NOT NULL,
diff --git a/install/sql/pgsql/schema/user/user.sql b/install/sql/pgsql/schema/user/user.sql
index 962577f..e5988e8 100755
--- a/install/sql/pgsql/schema/user/user.sql
+++ b/install/sql/pgsql/schema/user/user.sql
@@ -16,6 +16,8 @@ CREATE TABLE "user" (
"url" varchar(100) NOT NULL DEFAULT '',
"status" int check ("status" >= 0) NOT NULL DEFAULT 0,
"display_name" varchar(250) NOT NULL DEFAULT '',
+ "avatar" varchar(250) NOT NULL DEFAULT '',
+ "bio" varchar(250) NOT NULL DEFAULT '',
"token" varchar(32) NOT NULL DEFAULT '',
"created_at" timestamp(0) NOT NULL DEFAULT '2022-05-01 00:00:00',
"updated_at" timestamp(0) NOT NULL DEFAULT '2022-05-01 00:00:00',
diff --git a/install/sql/sqlite/schema/admin/admin.sql b/install/sql/sqlite/schema/admin/admin.sql
index 87e1b24..93b45b6 100755
--- a/install/sql/sqlite/schema/admin/admin.sql
+++ b/install/sql/sqlite/schema/admin/admin.sql
@@ -15,6 +15,8 @@ CREATE TABLE `admin` (
`phone_number` TEXT NOT NULL DEFAULT '',
`url` TEXT NOT NULL DEFAULT '',
`display_name` TEXT NOT NULL DEFAULT '',
+`avatar` TEXT NOT NULL DEFAULT '',
+`bio` TEXT NOT NULL DEFAULT '',
`role_id` INT DEFAULT NULL,
`status` INT NOT NULL DEFAULT '0',
`token` TEXT NOT NULL DEFAULT '',
@@ -24,4 +26,4 @@ CREATE TABLE `admin` (
);
CREATE INDEX `admin_user` ON `admin` (`username`);
-CREATE INDEX `admin_email` ON `admin` (`email`);
\ No newline at end of file
+CREATE INDEX `admin_email` ON `admin` (`email`);
diff --git a/install/sql/sqlite/schema/product/product.sql b/install/sql/sqlite/schema/product/product.sql
index e74285b..b38e8a4 100755
--- a/install/sql/sqlite/schema/product/product.sql
+++ b/install/sql/sqlite/schema/product/product.sql
@@ -2,6 +2,7 @@ DROP TABLE IF EXISTS `product`;
CREATE TABLE `product` (
`product_id` INTEGER PRIMARY KEY AUTOINCREMENT,
+`admin_id` INT NOT NULL DEFAULT 0,
`model` TEXT NOT NULL,
`sku` TEXT NOT NULL,
`upc` TEXT NOT NULL,
diff --git a/install/sql/sqlite/schema/product/vendor.sql b/install/sql/sqlite/schema/product/vendor.sql
index 90ddae7..a2929e5 100755
--- a/install/sql/sqlite/schema/product/vendor.sql
+++ b/install/sql/sqlite/schema/product/vendor.sql
@@ -2,6 +2,7 @@ DROP TABLE IF EXISTS `vendor`;
CREATE TABLE `vendor` (
`vendor_id` INTEGER PRIMARY KEY AUTOINCREMENT,
+`admin_id` INT NOT NULL DEFAULT 0,
`name` TEXT NOT NULL DEFAULT "",
`slug` TEXT NOT NULL DEFAULT "",
`image` TEXT NOT NULL,
diff --git a/install/sql/sqlite/schema/user/user.sql b/install/sql/sqlite/schema/user/user.sql
index 779bd64..d7e440f 100755
--- a/install/sql/sqlite/schema/user/user.sql
+++ b/install/sql/sqlite/schema/user/user.sql
@@ -12,6 +12,8 @@ CREATE TABLE `user` (
`url` TEXT NOT NULL DEFAULT '',
`status` INT NOT NULL DEFAULT 0,
`display_name` TEXT NOT NULL DEFAULT '',
+`avatar` TEXT NOT NULL DEFAULT '',
+`bio` TEXT NOT NULL DEFAULT '',
`token` TEXT NOT NULL DEFAULT '',
`subscribe` INT NOT NULL DEFAULT 0,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
diff --git a/public/media/vvveb.svg b/public/media/vvveb.svg
new file mode 100644
index 0000000..192be61
--- /dev/null
+++ b/public/media/vvveb.svg
@@ -0,0 +1 @@
+<svg width="48" height="48" xmlns="http://www.w3.org/2000/svg"><path d="M38.34 34.409h-2.225l-9.876-19.751h3.035l7.893 16.19 7.325-16.19h2.914l-9.066 19.75" style="fill:#50b450;fill-opacity:1;stroke:none;stroke-width:1.26145"/><path d="M25.577 34.64h-2.224l-9.878-19.75h3.035l7.893 16.188s1.8 3.212 1.174 3.563m-12.805.14h-2.226L.67 15.03h3.037l7.891 16.19s1.8 3.21 1.174 3.56" style="fill:#50b450;stroke-width:1.26145"/></svg>
\ No newline at end of file
diff --git a/system/data/capabilities.php b/system/data/capabilities.php
new file mode 100644
index 0000000..cc9c5fe
--- /dev/null
+++ b/system/data/capabilities.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+use function Vvveb\__;
+
+return [
+ 'view_other_posts' => __('View other users posts'),
+ 'edit_other_posts' => __('Edit other users posts'),
+ 'view_other_products' => __('View other users products'),
+ 'edit_other_products' => __('Edit other users products'),
+];
diff --git a/system/extensions/themes.php b/system/extensions/themes.php
index 7f8b444..ee6c616 100755
--- a/system/extensions/themes.php
+++ b/system/extensions/themes.php
@@ -51,6 +51,7 @@ class Themes extends Extensions {
$activeTheme = Sites::getTheme() ?? 'default';
$list = glob(DIR_ROOT . '/public/themes/*/index.html');
+ $themes = [];
foreach ($list as $file) {
$folder = Str::match('@/([^/]+)/[a-z]+.\w+$@', $file);
$dir = Str::match('@(.+)/[a-z]+.\w+$@', $file);
diff --git a/system/session/php.php b/system/session/php.php
index 0cdf0e2..92b4947 100755
--- a/system/session/php.php
+++ b/system/session/php.php
@@ -55,9 +55,13 @@ class Php {
if (! V_SUBDIR_INSTALL && V_SHARED_SESSION) {
//try to set cookie for all subdomains
$domain = preg_replace('/^[^\.]*\./', '', $host);
- @ini_set('session.cookie_domain', ".$domain");
- session_set_cookie_params(0, '/', ".$domain");
- $sessionName = session_name(str_replace('.', '', $domain));
+ $name = str_replace('.', '', $domain);
+ // skip if ip number
+ if (! is_numeric($name)) {
+ @ini_set('session.cookie_domain', ".$domain");
+ session_set_cookie_params(0, '/', ".$domain");
+ $sessionName = session_name($name);
+ }
}
return session_start();
diff --git a/system/sites.php b/system/sites.php
index a3627b9..5084a30 100755
--- a/system/sites.php
+++ b/system/sites.php
@@ -146,7 +146,10 @@ class Sites {
}
public static function url($url, $host = null) {
- $host = $host ?? self :: getHost();
+ $host = $host ?? self :: getHost();
+ $hasPort = strpos($host, ':') ?: null;
+ $hostWp = substr($host, 0, strpos($host, ':') ?: null);
+
$host_matches = self :: $host_matches[$host] ?? [];
if (preg_match(self :: HOST_REGEX, $url, $matches)) {
@@ -169,8 +172,8 @@ class Sites {
return $host;
}
- if ($host == 'localhost') {
- $matches['domain'] = 'localhost';
+ if ($hostWp == 'localhost') {
+ $matches['domain'] = $host;
$matches['subdomain'] = $matches['tld'] = $matches['prefix'] = '';
}
@@ -246,12 +249,6 @@ class Sites {
public static function getHost() {
$host =$_SERVER['HTTP_HOST'] ?? 'localhost';
- $hasPort = strpos($host, ':') ?: null;
-
- if ($hasPort) {
- $host = substr($host, 0, $hasPort);
- }
-
return $host;
}
diff --git a/system/user/admin.php b/system/user/admin.php
index 181705c..8e49cd3 100755
--- a/system/user/admin.php
+++ b/system/user/admin.php
@@ -40,6 +40,13 @@ class Admin extends Auth {
return $admin->add(['admin' => $data]);
}
+ public static function hasCapability($capability) {
+ $admin = \Vvveb\session('admin', false);
+ $capabilities = $admin['permissions']['capabilities'] ?? [];
+
+ return in_array($capability, $capabilities);
+ }
+
public static function hasPermission($permission) {
$admin = \Vvveb\session('admin', false);
$permissions = $admin['permissions'] ?: [];
diff --git a/system/user/role.php b/system/user/role.php
index c3883ce..dd45816 100755
--- a/system/user/role.php
+++ b/system/user/role.php
@@ -24,6 +24,7 @@ namespace Vvveb\System\User;
use function Vvveb\pregMatch;
use function Vvveb\pregMatchAll;
+use Vvveb\System\Event;
class Role {
static private $data = null;
@@ -214,4 +215,11 @@ class Role {
return $data;
}
+
+ public static function getCapabilitiesList() {
+ $capabilities = include DIR_SYSTEM . 'data' . DS . 'capabilities.php';
+ list($capabilities) = Event :: trigger(__CLASS__,__FUNCTION__, $capabilities);
+
+ return $capabilities;
+ }
}