27 Commits

Author SHA1 Message Date
Almira Krdzic
4ee63b053c test 2018-10-21 02:40:58 +02:00
Almira Krdzic
bfc216b0fe test 2018-10-21 02:19:10 +02:00
Almira Krdzic
5cbdb482f2 test 2018-10-21 02:13:57 +02:00
Almira Krdzic
a61edbc984 test' 2018-10-20 14:02:06 +02:00
Almira Krdzic
70d16f95c5 test' 2018-10-20 13:46:02 +02:00
Almira Krdzic
5a42777500 test 2018-10-20 00:47:04 +02:00
Almira Krdzic
95318ff1c4 test 2018-10-20 00:42:03 +02:00
Almira Krdzic
88c5ae5eb1 test 2018-10-20 00:30:10 +02:00
Almira Krdzic
e618484725 test 2018-10-20 00:25:29 +02:00
Almira Krdzic
4d87551fef test 2018-10-20 00:08:48 +02:00
Almira Krdzic
52fb6dc5d9 test 2018-10-19 23:43:05 +02:00
Almira Krdzic
cfd602bef7 test 2018-10-19 23:30:03 +02:00
Almira Krdzic
6b3964c2ca test 2018-10-19 23:22:11 +02:00
Almira Krdzic
dc5461f616 test 2018-10-19 23:08:31 +02:00
Almira Krdzic
eecbeed2b8 test 2018-10-19 22:36:39 +02:00
Almira Krdzic
f21e1d90b5 test 2018-10-19 22:23:57 +02:00
Almira Krdzic
e323b597b1 test 2018-10-19 21:11:12 +02:00
Almira Krdzic
3d4c3c40c1 test 2018-10-19 20:55:33 +02:00
Almira Krdzic
c3b665cd51 test 2018-10-19 20:50:55 +02:00
Almira Krdzic
84f7974050 test 2018-10-19 20:44:30 +02:00
Almira Krdzic
bde4a9a91f test 2018-10-19 20:37:10 +02:00
Almira Krdzic
05863b4114 test 2018-10-19 20:32:42 +02:00
Almira Krdzic
fd2f01197e test 2018-10-19 20:20:19 +02:00
Almira Krdzic
30a51dae8c test 2018-10-19 20:16:05 +02:00
Almira Krdzic
b5b8a72eaf test 2018-10-19 20:10:20 +02:00
Almira Krdzic
5d8e759e80 Remove shop on org delete 2018-10-19 20:00:40 +02:00
Almira Krdzic
a5a795af93 Authenticate by role on frontend 2018-10-19 17:57:27 +02:00
30 changed files with 283 additions and 323 deletions

View File

@@ -51,7 +51,9 @@ COPY docker/php/setup.sh /init-scripts/
RUN chmod +x /init-scripts/setup.sh
RUN docker-php-ext-install pdo pdo_mysql mysqli
RUN a2enmod rewrite ssl
RUN a2enmod rewrite
RUN a2enmod headers
COPY docker/php/000-default.conf /etc/apache2/sites-available
COPY backend /home/wiaas/backend
@@ -65,8 +67,8 @@ RUN cp -r backend/* /var/www/html/
WORKDIR /var/www/html
RUN ln -s ../html api
COPY docker/php/.htaccess /var/www/html/
RUN chown -R www-data:www-data /var/www/html
#RUN chown -R www-data:www-data /var/www/html
CMD /init-scripts/setup.sh

View File

@@ -1,13 +0,0 @@
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
</IfModule>
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# END WordPress

View File

@@ -18,7 +18,7 @@ class Wiaas_Admin_Organization {
add_filter('woocommerce_customer_meta_fields', array(__CLASS__, 'hide_woocommerce_customer_fields'));
// save related customers when organization form data has been saved by acf
add_action('acf/save_post', array(__CLASS__, 'maybe_save_related_customers'), 11);
add_action('acf/save_post', array(__CLASS__, 'maybe_save_related_customers'), 999);
// load related customers for organization form
add_filter('acf/load_value/name=_wiaas_organization_customers', array(__CLASS__, 'load_related_customer_organizations'), 10, 3);
@@ -64,6 +64,10 @@ class Wiaas_Admin_Organization {
//get organization id
$id = absint(str_replace('term_', '', $id));
if (!$id) {
return;
}
$customer_organization_ids = $_POST['acf'][$field['key']];
$customer_organization_ids = is_array($customer_organization_ids) ?

View File

@@ -107,9 +107,6 @@ class Wiaas_Admin_Product {
$value = get_field('_wiaas_product_country', $post_id, true);
$type = get_field('_wiaas_product_type', $post_id, true);
error_log($status);
error_log($value);
if (!empty($value) && $status === '_wiaas_no_country' ) {

View File

@@ -73,7 +73,7 @@ class Wiaas_REST_Customer_API {
$customer_shops = array_map(function($customer_shop) {
return array(
'id' => $customer_shop['owner_id'],
'id' => absint($customer_shop['owner_id']),
'type' => $customer_shop['order_type'],
'name' => wiaas_get_organization_name($customer_shop['owner_id'])
);

View File

@@ -93,7 +93,29 @@ class Wiass_REST_Delivery_Process_API {
);
}
return rest_ensure_response($data);
global $wpdb;
$data = array();
$total = 0;
$queries =$wpdb->queries;
foreach ($queries as $query) {
$data[] = array(
$query[0],
$query[1]
);
$total += $query[1];
}
global $wp_timer;
return rest_ensure_response(array(
'data' => $queries,
'total' => $total * 1000,
'start' => (microtime() - $wp_timer) * 1000
));
}
public static function get_customer_acceptance(WP_REST_Request $request){

View File

@@ -13,19 +13,16 @@ class Wiaas_Authentication {
public static function init() {
// authenticate current user
add_action('determine_current_user', array(__CLASS__, 'authenticate_current_user'), 999);
# add_action('determine_current_user', array(__CLASS__, 'authenticate_current_user'), 999);
// authenticates user on login
add_filter( 'authenticate', array( __CLASS__, 'authenticate_user_on_login' ), 999, 3);
# add_filter( 'authenticate', array( __CLASS__, 'authenticate_user_on_login' ), 999, 3);
// retrieve preferred user role for user
add_filter('get_user_metadata', array(__CLASS__, 'maybe_filter_user_roles'), 10, 3);
// redirect to dashboard after login
add_filter( 'login_redirect', array( __CLASS__, 'login_redirect' ) );
// add role selector to login form
add_action('login_form', array(__CLASS__, 'pick_role_on_login'));
# add_filter( 'login_redirect', array( __CLASS__, 'login_redirect' ) );
}
/**
@@ -37,26 +34,18 @@ class Wiaas_Authentication {
return admin_url('index.php') ;
}
/**
* Add role selector to login form
*/
public static function pick_role_on_login() {
?>
<p>
<label for="user_role"><?php esc_html_e( 'Role' , 'wiaas'); ?><br />
<select id="user_role" class="input" name="role">
<option value="administrator"><?php esc_html_e('Administrator', 'wiaas') ?></option>
<option value="supplier"><?php esc_html_e('Supplier', 'wiaas') ?></option>
<option value="commercial_lead"><?php esc_html_e('Commercial Lead', 'wiaas') ?></option>
</select>
</p>
<?php
}
/**
* Authenticate current user based on roles assigned to organization
*
* User role will be determined in `maybe_filter_user_roles` based on his organization roles
*
* If this is REST API request user will be only authenticated with customer role if his organization has
* customer role assigned to it.
*
* If this is backend request user will be authenticated with previously selected or first available role
* from his organization roles.
*
* @param int|false $user_id
* @return int|false|WP_Error
*/
@@ -66,17 +55,11 @@ class Wiaas_Authentication {
return $user_id;
}
$is_rest_api = strpos($_SERVER['REQUEST_URI'], rest_get_url_prefix());
$user = new WP_User($user_id);
$role = $is_rest_api ?
'customer' :
get_user_meta($user_id, '_wiaas_current_user_admin_role', true);
$result = self::_can_user_have_role($user_id, $role, $is_rest_api);
if (is_wp_error($result)) {
return false;
}
if (empty($user->roles)) {
return new WP_Error('wiaas_authentication_error', 'No permissions!');
}
return $user_id;
}
@@ -84,36 +67,27 @@ class Wiaas_Authentication {
/**
* Authenticate wiaas user on login based on roles assigned to organization
*
* User role will be determined in `maybe_filter_user_roles` based on his organization roles
*
* If this is REST API login request user will be only authenticated with customer role if his organization his
* customer role assigned to it.
*
* If this is backend login request user will be authenticated with previously selected or first available role
* from his organization roles.
*
* @param WP_User $user
* @return WP_User|WP_Error
*/
public static function authenticate_user_on_login($user) {
// check if rest request
$is_rest_api = strpos($_SERVER['REQUEST_URI'], rest_get_url_prefix());
// do nothing if there is an error already,
// user is super admin or
// this is rest request
if (is_wp_error($user) || $user->ID === 1 || $is_rest_api) {
// user is super admin
if (is_wp_error($user) || $user->ID === self::SUPER_ADMIN_USER_ID) {
return $user;
}
if (empty($_POST['role'])) {
return new WP_Error('error', 'You must selected role to login!');
}
// get selected role
$requested_role = sanitize_key($_POST['role']);
// validate can user have requested role
$result = self::_can_user_have_role($user->ID, $requested_role, false);
// if user organization has no requested role prevent access
if (is_wp_error($result)) {
return $result;
}
// remember role for user and continue
update_user_meta($user->ID, '_wiaas_current_user_admin_role', $requested_role);
if (empty($user->roles)) {
return new WP_Error('wiaas_authentication_error', 'No permissions!');
}
return $user;
}
@@ -121,8 +95,12 @@ class Wiaas_Authentication {
/**
*
* Filters user roles retrieval so that selected user role is retrieved for admin panel
* and customer role is retrieved for JSON API request
* Override default user roles with only his organization roles.
*
* If this is REST API request retrieve customer role if organization has that role.
*
* If this is backend request retrieve previously selected role or first available organization role with
* backend access.
*
* @param $null
* @param int $user_id
@@ -135,66 +113,67 @@ class Wiaas_Authentication {
if ($user_id !== 0 && $user_id !== self::SUPER_ADMIN_USER_ID && $meta_key === $wpdb->get_blog_prefix() . 'capabilities') {
$is_rest_api = strpos($_SERVER['REQUEST_URI'], rest_get_url_prefix());
return array( array( 'administrator' => true ) );
$role = $is_rest_api ?
'customer' :
get_user_meta($user_id, '_wiaas_current_user_admin_role', true);
// import organization functions (during user authentication it is not yet loaded)
require_once dirname( __FILE__ ) . '/user/wiaas-organization-functions.php';
// get user organization
$organization_id = wiaas_get_user_organization_id($user_id);
// validate if user has organization
if ( empty( $organization_id) ) {
return array();
}
// get organization roles
$roles = wiaas_get_organization_roles($organization_id);
// if organization has no roles assigned to it user will have no roles
if ( empty($roles) ) {
return array();
}
/**
* REST API access
*/
// for REST API access allow only customer role for user
if ( $is_rest_api = strpos($_SERVER['REQUEST_URI'], rest_get_url_prefix()) ) {
return in_array('customer', $roles) ? array( array( 'customer' => true ) ) : array();
}
/**
* BACKEND ACCESS
*/
// remove customer role
$roles = array_diff($roles, array( 'customer'));
// not available backend roles for user
if ( empty($roles) ) {
return array();
}
// retrieve selected role for user
$role = get_user_meta($user_id, '_wiaas_current_user_admin_role', true);
// if user has no selected role, selected role in invalid (deleted) or organization has no selected role
// assign first available role to user
if ( empty($role) ||
! wp_roles()->is_role($role) ||
! in_array($role, $roles) ) {
// pick first role
$role = $roles[0];
update_user_meta($user_id, '_wiaas_current_user_admin_role', $role);
}
return array( array ( "$role" => true ));
}
return null;
}
// PRIVATE
/**
* Determines if user can have requested role based on his organization roles
*
* @param int $user_id
* @param string $user_role
* @param bool $is_rest_api
* @return bool|WP_Error
*/
private static function _can_user_have_role($user_id, $user_role, $is_rest_api) {
// check if role valid for access
if (! wp_roles()->is_role($user_role)) {
return new WP_Error('error', 'Role is not valid!');
}
// only customer role can access API
if ($is_rest_api && $user_role !== 'customer') {
return new WP_Error('error', 'No access!');
}
// customer role cannot access admin backend
if (! $is_rest_api && $user_role === 'customer') {
return new WP_Error('error', 'No access!');
}
// import organization functions (during user authentication it is not yet loaded)
require_once dirname( __FILE__ ) . '/user/wiaas-organization-functions.php';
// get user organization
$organization_id = wiaas_get_user_organization_id($user_id);
// validate if user has organization
if (empty( $organization_id)) {
return new WP_Error('error', 'Account not completed!');
}
// get organization roles
$roles = wiaas_get_organization_roles($organization_id);
// validate if user has organization roles
if (!in_array($user_role, $roles)) {
return new WP_Error( 'error', 'Your account is not authorized for requested role. Please contact us for help.' );
}
return true;
}
}
Wiaas_Authentication::init();

View File

@@ -94,7 +94,7 @@ class Wiaas_Countries {
register_taxonomy( 'product_country', array( 'product' ), $args );
foreach (self::$available_countries as $available_country) {
wp_insert_term($available_country['name'], 'product_country');
wp_update_term($available_country['name'], 'product_country');
}
}

View File

@@ -21,7 +21,9 @@ class Wiaas_Shop {
// create new shop if organization was assigned commercial lead role
// or remove shop if commercial lead role was removed for organization
add_action('wiaas_organization_roles_updated', array(__CLASS__, 'maybe_manage_shop_for_commercial_lead'), 10, 2);
add_action('wiaas_organization_roles_updated', array(__CLASS__, 'remove_deactivated_shop'));
add_action('wiaas_organization_deleted', array(__CLASS__, 'remove_shop'));
}
public static function get_shop_customers($owner_id) {
@@ -86,18 +88,25 @@ class Wiaas_Shop {
}
/**
* Creates shop for new shop owner (organization with commercial lead role) or
* deletes existing shop if that role has been removed
* Remove shop for organization that is no longer commercial lead
*
* @param int $owner_id
* @param array $roles
*/
public static function maybe_manage_shop_for_commercial_lead($owner_id, $roles) {
$is_commercial_lead = in_array('commercial_lead', $roles);
public static function remove_deactivated_shop($owner_id) {
$roles = wiaas_get_organization_roles($owner_id);
$is_commercial_lead ?
self::_maybe_create_shop($owner_id) :
self::_maybe_remove_shop($owner_id);
if (! in_array('commercial_lead', $roles)) {
self::remove_shop($owner_id);
}
}
/**
* Remove shop
*
* @param int $owner_id
*/
public static function remove_shop($owner_id) {
Wiaas_Shop_DB::remove_shop($owner_id);
}
/**
@@ -156,49 +165,6 @@ class Wiaas_Shop {
// PRIVATE
/**
* Each shop will be registered as product attribute.
* This will persist shops information into database.
* Also every attribute has taxonomy associated with it which will enable us to have multiple
* catalogues in one shop
*
* @param int $owner_id
*/
private static function _maybe_create_shop($owner_id) {
$shop_name = 'wiaas_shop_' . $owner_id;
$attribute_id = wc_attribute_taxonomy_id_by_name($shop_name);
if ($attribute_id === 0) {
// create shop attribute
wc_create_attribute(array( 'slug' => $shop_name, 'name' => 'Shop' ));
$taxonomy_name = wc_attribute_taxonomy_name($shop_name);
// since attribute taxonomies are registered once on load
// we will register new attribute taxonomy here so default catalogue can be added
register_taxonomy($taxonomy_name, array('product'));
// add default catalogue option to shop
wp_insert_term( 'Default Catalogue', $taxonomy_name);
}
}
/**
* Deleted associated attribute for shop. This will effectively remove shop and all of its potential catalogues
*
* @param int $owner_id
*/
private static function _maybe_remove_shop($owner_id) {
// get corresponding attribute for shop
$attribute_id = wc_attribute_taxonomy_id_by_name('wiaas_shop_' . $owner_id);
// if shop attribute exists then remove it
if ($attribute_id > 0) {
wc_delete_attribute($attribute_id);
}
}
/**
* Generate search terms from cl extras
*

View File

@@ -154,4 +154,15 @@ class Wiaas_Shop_DB {
return $shops;
}
public static function remove_shop($owner_id) {
global $wpdb;
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->prefix}wiaas_shop_customer_relationships
WHERE shop_owner_id = %d",
$owner_id )
);
}
}

View File

@@ -303,11 +303,11 @@ class Wiaas_Document {
return;
}
foreach (self::$available_doc_types as $key => $available_doc_type) {
wp_insert_term($available_doc_type['name'], 'wpdmcategory', array(
'slug' => $key
));
}
// foreach (self::$available_doc_types as $key => $available_doc_type) {
// wp_insert_term($available_doc_type['name'], 'wpdmcategory', array(
// 'slug' => $key
// ));
// }
}
public static function register_wiaas_document() {
@@ -388,6 +388,7 @@ class Wiaas_Document {
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'wiaas_doc_type' ),
'show_in_rest' => false,
'capabilities' => array(
'manage_terms' => 'manage_wiaas_doc_terms',
'edit_terms' => 'edit_wiaas_doc_terms',
@@ -399,9 +400,11 @@ class Wiaas_Document {
register_taxonomy( 'wiaas_doc_type', array( 'wiaas_doc' ), $args );
foreach (self::$available_doc_types as $key => $available_doc_type) {
wp_insert_term($available_doc_type['name'], 'wiaas_doc_type', array(
'slug' => $key
));
// if (! has_term($available_doc_type['name'], 'wiaas_doc_type')) {
// wp_insert_term($available_doc_type['name'], 'wiaas_doc_type', array(
// 'slug' => $key
// ));
// }
}
}

View File

@@ -55,25 +55,21 @@ class Wiaas_Order_Project {
public static function get_available_order_projects() {
$all_terms = get_terms(array(
'taxonomy' => 'shop_order_project',
'hide_empty' => false
'hide_empty' => false,
'meta_key' => '_wiaas_is_available',
'meta_value' => 'yes'
));
if (is_wp_error($all_terms)) {
return array();
}
$available_terms = array();
foreach ($all_terms as $term) {
if (self::is_order_project_available($term->term_id)) {
$available_terms[] = array(
'id' => $term->term_id,
'name' => $term->name
);
}
}
return $available_terms;
return array_map(function($term) {
return array(
'id' => $term->term_id,
'name' => $term->name
);
}, $all_terms);
}
/**

View File

@@ -54,7 +54,7 @@ class Wiaas_Package_Type {
$types = apply_filters('wiaas_package_types', array('standard'));
foreach ($types as $type) {
wp_insert_term($type, 'package_type');
wp_update_term($type, 'package_type');
}
}

View File

@@ -47,7 +47,7 @@ class Wiaas_Product_Category {
foreach (self::$available_product_categories as $key => $available_product_category) {
if (! has_term_meta($key)) {
wp_insert_term($key, 'product_cat');
wp_update_term($key, 'product_cat');
}
}
}

View File

@@ -15,8 +15,7 @@ class Wiaas_User_Organization extends WP_User_Taxonomy {
'plural' => __('Organizations', 'wiaas'),
'exclusive' => true,
'public' => true,
'show_in_rest' => true,
'rest_base' => 'organization'
'show_in_rest' => false,
);
$labels = array();
$caps = array();
@@ -38,7 +37,7 @@ class Wiaas_User_Organization extends WP_User_Taxonomy {
add_action( 'pre_delete_term', array( __CLASS__, 'on_taxonomy_term_will_be_deleted' ), 10, 2);
add_action( 'delete_' . self::TAXONOMY_NAME, array( __CLASS__, 'on_organization_deleted' ));
add_action('acf/save_post', array(__CLASS__, 'on_organization_roles_maybe_updated'));
add_action('acf/save_post', array(__CLASS__, 'on_organization_roles_maybe_updated'), 20);
add_action('set_object_terms', array( __CLASS__, 'on_taxonomy_term_assigned' ), 10, 4);
add_action('deleted_term_relationships', array( __CLASS__, 'on_taxonomy_term_unassigned' ), 10, 3);
@@ -104,7 +103,9 @@ class Wiaas_User_Organization extends WP_User_Taxonomy {
//get organization id
$id = absint(str_replace('term_', '', $id));
do_action('wiaas_organization_roles_updated', $id, $roles);
if ($id) {
do_action('wiaas_organization_roles_updated', $id, $roles);
}
}
}

View File

@@ -73,9 +73,7 @@ class Wiaas_Measurement_Units {
register_taxonomy('wiaas_units', array('product'), $args);
foreach (self::$available_units as $available_unit) {
if (!term_exists($available_unit, 'wiaas_units')) {
wp_insert_term($available_unit['unit'], 'wiaas_units');
}
wp_update_term($available_unit['unit'], 'wiaas_units');
}
}
}

View File

@@ -51,15 +51,11 @@
"roots/wp-password-bcrypt": "1.0.0",
"wpackagist-plugin/akismet": "4.0.3",
"wpackagist-plugin/hello-dolly": "1.6",
"woocommerce/woocommerce": "3.4.4",
"wpackagist-plugin/woocommerce-jetpack": "3.7.0",
"wpackagist-plugin/groups": "2.3.1",
"wpackagist-plugin/klarna-checkout-for-woocommerce": "1.5.2",
"wpackagist-plugin/mailchimp-for-woocommerce": "2.1.7",
"wpackagist-plugin/woocommerce-gateway-paypal-express-checkout": "1.5.6",
"wpackagist-plugin/jwt-authentication-for-wp-rest-api": "1.2.4",
"wpackagist-plugin/capability-manager-enhanced": "1.5.9",
"wpackagist-plugin/wp-user-groups": "2.2.0",
"wpackagist-plugin/radio-buttons-for-taxonomies": "1.8.3",
"wpackagist-plugin/advanced-access-manager": "5.4.3.2",
@@ -94,10 +90,8 @@
"wp plugin activate jwt-authentication-for-wp-rest-api",
"wp plugin activate gravityforms",
"wp plugin activate gravityflow",
"wp plugin activate capability-manager-enhanced",
"wp plugin activate groups",
"wp plugin activate wp-user-groups",
"wp plugin activate radio-buttons-for-taxonomies",
"wp plugin activate advanced-access-manager",
"wp plugin activate advanced-custom-fields",
"wp plugin activate wiaas"

82
backend/composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "da3d7fa874b9a31355d3c3d4df50ae94",
"content-hash": "9380f64d0712c55d18f8120b57c5fe50",
"packages": [
{
"name": "3rdparty/gravityflow",
@@ -488,26 +488,6 @@
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/akismet/"
},
{
"name": "wpackagist-plugin/capability-manager-enhanced",
"version": "1.5.9",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/capability-manager-enhanced/",
"reference": "trunk"
},
"dist": {
"type": "zip",
"url": "https://downloads.wordpress.org/plugin/capability-manager-enhanced.zip?timestamp=1532180189",
"reference": null,
"shasum": null
},
"require": {
"composer/installers": "~1.0"
},
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/capability-manager-enhanced/"
},
{
"name": "wpackagist-plugin/groups",
"version": "2.3.1",
@@ -528,26 +508,6 @@
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/groups/"
},
{
"name": "wpackagist-plugin/hello-dolly",
"version": "1.6",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/hello-dolly/",
"reference": "tags/1.6"
},
"dist": {
"type": "zip",
"url": "https://downloads.wordpress.org/plugin/hello-dolly.1.6.zip",
"reference": null,
"shasum": null
},
"require": {
"composer/installers": "~1.0"
},
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/hello-dolly/"
},
{
"name": "wpackagist-plugin/jwt-authentication-for-wp-rest-api",
"version": "1.2.4",
@@ -568,26 +528,6 @@
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/"
},
{
"name": "wpackagist-plugin/klarna-checkout-for-woocommerce",
"version": "1.5.2",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/klarna-checkout-for-woocommerce/",
"reference": "tags/1.5.2"
},
"dist": {
"type": "zip",
"url": "https://downloads.wordpress.org/plugin/klarna-checkout-for-woocommerce.1.5.2.zip",
"reference": null,
"shasum": null
},
"require": {
"composer/installers": "~1.0"
},
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/klarna-checkout-for-woocommerce/"
},
{
"name": "wpackagist-plugin/mailchimp-for-woocommerce",
"version": "2.1.7",
@@ -628,26 +568,6 @@
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/radio-buttons-for-taxonomies/"
},
{
"name": "wpackagist-plugin/woocommerce-gateway-paypal-express-checkout",
"version": "1.5.6",
"source": {
"type": "svn",
"url": "https://plugins.svn.wordpress.org/woocommerce-gateway-paypal-express-checkout/",
"reference": "tags/1.5.6"
},
"dist": {
"type": "zip",
"url": "https://downloads.wordpress.org/plugin/woocommerce-gateway-paypal-express-checkout.1.5.6.zip",
"reference": null,
"shasum": null
},
"require": {
"composer/installers": "~1.0"
},
"type": "wordpress-plugin",
"homepage": "https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/"
},
{
"name": "wpackagist-plugin/woocommerce-jetpack",
"version": "3.7.0",

View File

@@ -1,8 +1,16 @@
<?php
/** Development */
define('SAVEQUERIES', true);
define('WP_DEBUG', true);
define('SCRIPT_DEBUG', true);
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', false);
define('SCRIPT_DEBUG', false);
define('DISABLE_WP_CRON', true);
ini_set('display_errors',0);
ini_set('error_reporting', 0 );
/**
* Use Dotenv to set required environment variables and load .local.env file

View File

@@ -1,10 +1,14 @@
<?php
/** Development */
ini_set('display_errors', 0);
define('SAVEQUERIES', true);
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', false);
define('SCRIPT_DEBUG', false);
/** Disable all file modifications including updates and update notifications */
define('DISALLOW_FILE_MODS', true);
ini_set('display_errors',EP_NONE);
ini_set('error_reporting', EP_NONE );
/**
* Stops redirect loop on login page

View File

@@ -1,8 +1,18 @@
<?php
/** Development */
define('SAVEQUERIES', true);
define('WP_DEBUG', true);
define('SCRIPT_DEBUG', true);
define('SAVEQUERIES', false);
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', false);
define('SCRIPT_DEBUG', false);
ini_set('display_errors',0);
ini_set('error_reporting', 0 );
/** Disable all file modifications including updates and update notifications */
define('DISALLOW_FILE_MODS', true);
/**
* Use Dotenv to set required environment variables and load .local.env file

View File

@@ -6,4 +6,8 @@
*/
require_once(__DIR__ . '/vendor/autoload.php');
require_once(__DIR__ . '/config/application.php');
global $wp_timer;
$wp_timer = microtime();
require_once(ABSPATH . 'wp-settings.php');

View File

@@ -23,6 +23,7 @@ services:
- WP_JWT_AUTH_SECRET_KEY
volumes:
- ./log/backend/:/var/log/apache2/
restart: always
ports:
- '8081:80'
depends_on:
@@ -39,6 +40,7 @@ services:
- API_URL
volumes:
- ./log/frontend/:/var/log/apache2/
restart: always
ports:
- '8080:80'
@@ -53,6 +55,7 @@ services:
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
restart: always
ports:
- '23306:3306'
volumes:

View File

@@ -25,10 +25,10 @@
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
LogLevel emerg
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
CustomLog /dev/null combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to

View File

@@ -0,0 +1,50 @@
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory "/var/www/html">
Options FollowSymLinks Indexes
AllowOverride None
Header always set Access-Control-Max-Age "86400"
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
LogLevel emerg
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog /dev/null combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

View File

@@ -74,7 +74,6 @@ export const fetchShops = (userId) => {
if (shopOptions.length) {
dispatch(selectShop(shopOptions[0]));
dispatch(fetchShopPackages(shopOptions[0]));
}
}
})

View File

@@ -4,13 +4,9 @@ import {Link} from 'react-router-dom';
import {Row, Col, Container, NavLink} from 'reactstrap';
import CartStepsContainer from './CartStepsContainer.jsx';
import CartItemsContainer from './CartItemsContainer.jsx';
import {fetchCartCount} from '../../actions/cart/cartActions';
import {cartTexts} from '../../constants/cartConstants';
class CartContainer extends Component {
componentDidMount() {
this.props.dispatch(fetchCartCount());
}
render() {
const {cartSteps, currentStep, cartCount} = this.props;

View File

@@ -42,7 +42,6 @@ class CartCustomerDetailsContainer extends Component {
componentDidMount() {
this.props.dispatch(getCustomerDetails());
this.props.dispatch(fetchCartItems());
this.props.dispatch(setNextActionFct(this.handleNextAction));
this.props.dispatch(setPrevActionFct(this.handlePrevAction));
this.props.dispatch(fetchProfileInfo(this.props.userInfo.wiaas_id_user));

View File

@@ -8,7 +8,7 @@ import {
import ShopItem from './components/ShopItem.jsx';
import WiaasBox from '../../mainComponents/box/WiaasBox.jsx';
import CoMarketNavContainer from './CoMarketNavContainer.jsx';
import {fetchShopPackages} from '../../actions/coMarket/coMarketPackagesActions';
import {fetchShopPackages, selectShop} from '../../actions/coMarket/coMarketPackagesActions';
class CoMarketPackagesContainer extends Component {
componentDidMount() {
@@ -17,6 +17,13 @@ class CoMarketPackagesContainer extends Component {
}
}
componentWillReceiveProps(nextProps){
if (nextProps.selectedShop &&
(!this.props.selectedShop || this.props.selectedShop.id !== nextProps.selectedShop.id)) {
this.props.dispatch(fetchShopPackages(nextProps.selectedShop));
}
}
render() {
const {shopPackages, selectedShop, isLoading} = this.props;

View File

@@ -25,10 +25,10 @@ class CoMarketCatalogSelect extends Component {
}
componentWillReceiveProps(nextProps){
// if(nextProps.activeModule==='cart' && nextProps.shops && nextProps.cartItems && nextProps.cartItems.length > 0){
// const cartShop = this.props.shops.find( shop => { return shop.id === this.props.cartItems[0].idCommercialLead });
// nextProps.dispatch(selectShop(cartShop));
// }
if(nextProps.activeModule==='cart' && nextProps.shops && nextProps.cartItems && nextProps.cartItems.length > 0){
const cartShop = nextProps.shops.find( shop => { return shop.id === nextProps.cartItems[0].idCommercialLead });
nextProps.dispatch(selectShop(cartShop));
}
if(nextProps.shops && nextProps.idCommercialLead && nextProps.activeModule === 'co-market'){
const shop = nextProps.shops.find( shop => {return shop.id === nextProps.idCommercialLead });