Skip to content

Commit

Permalink
Enchancement #547
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Dec 14, 2014
1 parent 040ef0d commit 0319831
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 7 deletions.
5 changes: 5 additions & 0 deletions lhc_web/doc/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.15v

1. Option to choose auto responder for specific department.
https://github.com/LiveHelperChat/livehelperchat/issues/547

2.14v

This release is maintenence release with few enhancements
Expand Down
8 changes: 8 additions & 0 deletions lhc_web/doc/update_db/structure.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
"default": null,
"extra": ""
},
{
"field": "dep_id",
"type": "int(11)",
"null": "NO",
"key": "",
"default": null,
"extra": ""
},
{
"field": "timeout_message",
"type": "varchar(250)",
Expand Down
3 changes: 3 additions & 0 deletions lhc_web/doc/update_db/update_93.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE `lh_abstract_auto_responder`
ADD `dep_id` int NOT NULL,
COMMENT='';
4 changes: 2 additions & 2 deletions lhc_web/lib/core/lhcore/lhupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

class erLhcoreClassUpdate
{
const DB_VERSION = 92;
const LHC_RELEASE = 214;
const DB_VERSION = 93;
const LHC_RELEASE = 215;

public static function doTablesUpdate($definition){
$updateInformation = self::getTablesStatus($definition);
Expand Down
17 changes: 15 additions & 2 deletions lhc_web/lib/models/lhabstract/erlhabstractmodelautoresponder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public function getState()
'wait_message' => $this->wait_message,
'timeout_message' => $this->timeout_message,
'wait_timeout' => $this->wait_timeout,
'dep_id' => $this->dep_id,
'position' => $this->position
);

Expand Down Expand Up @@ -48,6 +49,17 @@ public function getFields()
'validation_definition' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'
)),
'dep_id' => array (
'type' => 'combobox',
'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation','Department'),
'required' => false,
'hidden' => true,
'source' => 'erLhcoreClassModelDepartament::getList',
'hide_optional' => false,
'params_call' => array(),
'validation_definition' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::OPTIONAL, 'int'
)),
'wait_message' => array(
'type' => 'text',
'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/proactivechatinvitation','Wait message. Visible when users starts chat and is waiting for someone to accept a chat.'),
Expand Down Expand Up @@ -193,11 +205,11 @@ public static function getList($paramsSearch = array())
return $objects;
}

public static function processAutoResponder() {
public static function processAutoResponder(erLhcoreClassModelChat $chat) {

$session = erLhcoreClassAbstract::getSession();
$q = $session->createFindQuery( 'erLhAbstractModelAutoResponder' );
$q->where( $q->expr->eq( 'siteaccess', $q->bindValue( erLhcoreClassSystem::instance()->SiteAccess ) ).' OR siteaccess = \'\'')
$q->where( '('.$q->expr->eq( 'siteaccess', $q->bindValue( erLhcoreClassSystem::instance()->SiteAccess ) ).' OR siteaccess = \'\') AND ('.$q->expr->eq( 'dep_id', $q->bindValue( $chat->dep_id ) ).' OR dep_id = 0)')
->orderBy('position ASC')
->limit( 1 );

Expand All @@ -221,6 +233,7 @@ public function updateThis(){
public $wait_message = '';
public $wait_timeout = 0;
public $timeout_message = '';
public $dep_id = 0;

public $hide_add = false;
public $hide_delete = false;
Expand Down
2 changes: 1 addition & 1 deletion lhc_web/modules/lhchat/chatwidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
}

// Auto responder
$responder = erLhAbstractModelAutoResponder::processAutoResponder();
$responder = erLhAbstractModelAutoResponder::processAutoResponder($chat);

if ($responder instanceof erLhAbstractModelAutoResponder) {
$chat->wait_timeout = $responder->wait_timeout;
Expand Down
2 changes: 1 addition & 1 deletion lhc_web/modules/lhchat/readoperatormessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
} else {

// Default auto responder
$responder = erLhAbstractModelAutoResponder::processAutoResponder();
$responder = erLhAbstractModelAutoResponder::processAutoResponder($chat);

if ($responder instanceof erLhAbstractModelAutoResponder) {
$chat->wait_timeout = $responder->wait_timeout;
Expand Down
2 changes: 1 addition & 1 deletion lhc_web/modules/lhchat/startchat.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
}

// Auto responder
$responder = erLhAbstractModelAutoResponder::processAutoResponder();
$responder = erLhAbstractModelAutoResponder::processAutoResponder($chat);

if ($responder instanceof erLhAbstractModelAutoResponder) {
$chat->wait_timeout = $responder->wait_timeout;
Expand Down
1 change: 1 addition & 0 deletions lhc_web/modules/lhinstall/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@
`wait_message` varchar(250) NOT NULL,
`wait_timeout` int(11) NOT NULL,
`position` int(11) NOT NULL,
`dep_id` int(11) NOT NULL,
`timeout_message` varchar(250) NOT NULL,
PRIMARY KEY (`id`),
KEY `siteaccess_position` (`siteaccess`,`position`)
Expand Down
6 changes: 6 additions & 0 deletions lhc_web/pos/lhabstract/erlhabstractmodelautoresponder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
$def->properties['wait_timeout']->propertyName = 'wait_timeout';
$def->properties['wait_timeout']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

// Department ID
$def->properties['dep_id'] = new ezcPersistentObjectProperty();
$def->properties['dep_id']->columnName = 'dep_id';
$def->properties['dep_id']->propertyName = 'dep_id';
$def->properties['dep_id']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

// Position
$def->properties['position'] = new ezcPersistentObjectProperty();
$def->properties['position']->columnName = 'position';
Expand Down

0 comments on commit 0319831

Please sign in to comment.