diff --git a/src/mibew/js/source/users/model_views/visitor.js b/src/mibew/js/source/users/model_views/visitor.js index db09c3f7..928a0993 100644 --- a/src/mibew/js/source/users/model_views/visitor.js +++ b/src/mibew/js/source/users/model_views/visitor.js @@ -76,14 +76,22 @@ var visitorId = this.model.id; var page = Mibew.Objects.Models.page; - // Open invite window - Mibew.Popup.open( - page.get('inviteLink') - + '?visitor=' - + visitorId, - 'ImCenter' + visitorId, - Mibew.Utils.buildWindowParams(page.get('inviteWindowParams')) - ); + // Check whether operator could actually chat + // (see libs/operator.php, has_online_operators function for details) + if (page.get('operatorCouldNotInvite')) { + Mibew.Utils.alert(Mibew.Localization.trans('Unable to invite user: groups are enabled, and you don\'t belong to any of them.')); + } + else { + + // Open invite window + Mibew.Popup.open( + page.get('inviteLink') + + '?visitor=' + + visitorId, + 'ImCenter' + visitorId, + Mibew.Utils.buildWindowParams(page.get('inviteWindowParams')) + ); + } } }, diff --git a/src/mibew/libs/classes/Mibew/Controller/UsersController.php b/src/mibew/libs/classes/Mibew/Controller/UsersController.php index ff47c8b2..5bf30008 100644 --- a/src/mibew/libs/classes/Mibew/Controller/UsersController.php +++ b/src/mibew/libs/classes/Mibew/Controller/UsersController.php @@ -124,6 +124,8 @@ class UsersController extends AbstractController 'banLink' => $request->getBaseUrl() . '/operator/ban', 'inviteLink' => $request->getBaseUrl() . '/operator/invite', + 'operatorCouldNotInvite' => (Settings::get('enablegroups') == 1) && !count(get_operator_group_ids($operator['operatorid'])), + 'chatWindowParams' => $chat_style_config['chat']['window'], 'trackedUserWindowParams' => $page_style_config['tracked']['user_window'], 'trackedVisitorWindowParams' => $page_style_config['tracked']['visitor_window'],