From cabdaed21d37cf2301deb7246bb7b96ca3ebd4ea Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Tue, 5 Aug 2014 12:50:09 +0000 Subject: [PATCH] A user cannot start chat if all groups offline Revert changes made in 324f5bf94e1def0b75d7a92b368d43babf7c5b31 --- src/mibew/libs/operator.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mibew/libs/operator.php b/src/mibew/libs/operator.php index cac04a21..813ddf59 100644 --- a/src/mibew/libs/operator.php +++ b/src/mibew/libs/operator.php @@ -473,7 +473,19 @@ function has_online_operators($group_id = "") . "AND istatus = 0"; $values[':groupid'] = $group_id; } else { - $query .= " WHERE istatus = 0"; + if (Settings::get('enablegroups') == 1) { + // If the groups and prechat survey are enabled and a button was + // generated not for concrete group a user must select a group to + // chat with. All groups will be checked for online operators. If + // only operators, who do not related with groups, are online a user + // cannot complete prechat survey because there will be no online + // groups. The following code fixes this strange behaviour. + $query .= ", {operatortoopgroup} " + . "WHERE {operator}.operatorid = {operatortoopgroup}.operatorid " + . "AND istatus = 0"; + } else { + $query .= " WHERE istatus = 0"; + } } $row = $db->query(