Skip to content

Commit

Permalink
Enhancements #563
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Nov 30, 2014
1 parent 4f53d15 commit 135f8ac
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 10 deletions.
4 changes: 4 additions & 0 deletions lhc_web/design/defaulttheme/tpl/lhform/collected.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<thead>
<tr>
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('form/collected','Name');?></th>
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('form/collected','Identifier');?></th>
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('form/collected','Intro');?></th>
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('form/collected','Time');?></th>
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('form/collected','IP');?></th>
Expand All @@ -30,6 +31,9 @@
<?php foreach ($items as $item) : ?>
<tr>
<td><?php echo htmlspecialchars($item->getAttrValue($form->name_attr))?></td>
<td>
<div class="page-url"><span><?php echo htmlspecialchars($item->identifier)?></span></div>
</td>
<td><?php echo htmlspecialchars($item->getAttrValue($form->intro_attr))?></td>
<td><?php echo $item->ctime_front?></td>
<td><?php echo htmlspecialchars($item->ip)?></td>
Expand Down
4 changes: 4 additions & 0 deletions lhc_web/design/defaulttheme/tpl/lhform/viewcollected.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

<?php echo $content?>

<hr>
<h3><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('form/viewcollected','Identifier');?></h3>
<?php echo htmlspecialchars($collected->identifier)?>
<hr>
<a class="small radius button" href="<?php echo erLhcoreClassDesign::baseurl('form/downloaditem')?>/<?php echo $collected->id?>"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('form/viewcollected','Download');?></a>
10 changes: 10 additions & 0 deletions lhc_web/doc/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2.14v

This release is maintenence release with few enhancements

1. Option to pass identifier. It can be either some specific value or if not provided it will be referer URL.
Also new variable in template can be used {url_view} it will be link to filled form view instead of download link.
https://github.com/LiveHelperChat/livehelperchat/issues/563

execute doc/update_db/update_92.sql for update

2.13v

This realease is maintenence release with a lot of small changes.
Expand Down
14 changes: 13 additions & 1 deletion lhc_web/doc/translation_default/translation_web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4630,6 +4630,10 @@
<source>Name</source>
<translation type="unfinished"/>
</message>
<message>
<source>Identifier</source>
<translation type="unfinished"/>
</message>
<message>
<source>Intro</source>
<translation type="unfinished"/>
Expand Down Expand Up @@ -4696,13 +4700,21 @@
<source>Date</source>
<translation type="unfinished"/>
</message>
<message>
<source>Identifier</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>form/viewcollected</name>
<message>
<source>collected information</source>
<translation type="unfinished"/>
</message>
<message>
<source>Identifier</source>
<translation type="unfinished"/>
</message>
<message>
<source>Download</source>
<translation type="unfinished"/>
Expand Down Expand Up @@ -6246,7 +6258,7 @@
<name>file/configurations</name>
<message>
<source>Please enter valid file type!</source>
<translation type="unfinished"></translation>
<translation type="unfinished"/>
</message>
</context>
<context>
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 @@ -433,6 +433,14 @@
"default": null,
"extra": ""
},
{
"field": "identifier",
"type": "varchar(250)",
"null": "NO",
"key": "",
"default": null,
"extra": ""
},
{
"field": "content",
"type": "longtext",
Expand Down
3 changes: 3 additions & 0 deletions lhc_web/doc/update_db/update_92.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE `lh_abstract_form_collected`
ADD `identifier` varchar(250) COLLATE 'utf8_general_ci' NOT NULL,
COMMENT='';
2 changes: 1 addition & 1 deletion lhc_web/lib/core/lhchat/lhchatmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public static function informFormFilled($formCollected) {

$mail->FromName = $sendMail->from_name;
$mail->Subject = str_replace(array('{form_name}'),array($formCollected->form),$sendMail->subject);
$mail->Body = str_replace(array('{form_name}','{ip}','{url_download}'), array((string)$formCollected->form,$formCollected->ip,erLhcoreClassXMP::getBaseHost() . $_SERVER['HTTP_HOST'] . erLhcoreClassDesign::baseurldirect('user/login').'/(r)/'.rawurlencode(base64_encode('form/downloaditem/'.$formCollected->id))), $sendMail->content);
$mail->Body = str_replace(array('{form_name}','{ip}','{url_download}','{url_view}'), array((string)$formCollected->form, $formCollected->ip, erLhcoreClassXMP::getBaseHost() . $_SERVER['HTTP_HOST'] . erLhcoreClassDesign::baseurldirect('user/login').'/(r)/'.rawurlencode(base64_encode('form/downloaditem/'.$formCollected->id)), erLhcoreClassXMP::getBaseHost() . $_SERVER['HTTP_HOST'] . erLhcoreClassDesign::baseurldirect('user/login').'/(r)/'.rawurlencode(base64_encode('form/viewcollected/'.$formCollected->id))), $sendMail->content);

$emailRecipient = array();
if ($formCollected->form->recipient != '') {
Expand Down
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 = 91;
const LHC_RELEASE = 213;
const DB_VERSION = 92;
const LHC_RELEASE = 214;

public static function doTablesUpdate($definition){
$updateInformation = self::getTablesStatus($definition);
Expand Down
11 changes: 10 additions & 1 deletion lhc_web/lib/core/lhform/lhformrenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ public static function renderForm($form) {
$contentForm = str_replace($inputDefinition,$content,$contentForm);
};

if (isset($_GET['identifier']) && !empty($_GET['identifier'])) {
$contentForm .= "<input type=\"hidden\" name=\"identifier\" value=\"".htmlspecialchars(rawurldecode($_GET['identifier']))."\" />";
} elseif (isset($_POST['identifier']) && !empty($_POST['identifier'])) {
$contentForm .= "<input type=\"hidden\" name=\"identifier\" value=\"".htmlspecialchars($_POST['identifier'])."\" />";
} elseif (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) {
$contentForm .= "<input type=\"hidden\" name=\"identifier\" value=\"".htmlspecialchars($_SERVER['HTTP_REFERER'])."\" />";
}

if ( empty(self::$errors) && ezcInputForm::hasPostData()) {
self::$isCollected = true;
}
Expand Down Expand Up @@ -504,7 +512,8 @@ public static function storeCollectedInformation($form, $collectedInformation) {
$formCollected = new erLhAbstractModelFormCollected();
$formCollected->ip = erLhcoreClassIPDetect::getIP();
$formCollected->ctime = time();
$formCollected->form_id = $form->id;
$formCollected->form_id = $form->id;
$formCollected->identifier = isset($_POST['identifier']) ? $_POST['identifier'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
$formCollected->saveThis();

// Finish collect information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public function getState()
'form_id' => $this->form_id,
'ctime' => $this->ctime,
'ip' => $this->ip,
'content' => $this->content
'content' => $this->content,
'identifier' => $this->identifier
);

return $stateArray;
Expand Down Expand Up @@ -185,6 +186,7 @@ public static function getList($paramsSearch = array())
public $ctime = null;
public $ip = '';
public $content = '';
public $identifier = '';

}

Expand Down
2 changes: 1 addition & 1 deletion lhc_web/modules/lhform/collected.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

$items = array();
if ($pages->items_total > 0) {
$items = erLhAbstractModelFormCollected::getList(array('filter' => array('form_id' => $form->id),'offset' => $pages->low, 'limit' => $pages->items_per_page,'sort' => 'id ASC'));
$items = erLhAbstractModelFormCollected::getList(array('filter' => array('form_id' => $form->id),'offset' => $pages->low, 'limit' => $pages->items_per_page,'sort' => 'id DESC'));
}

$tpl->set('items',$items);
Expand Down
9 changes: 8 additions & 1 deletion lhc_web/modules/lhform/downloadcollected.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@
}

$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, 1, erTranslationClassLhTranslation::getInstance()->getTranslation('form/index','Date'));

$i++;
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, 1, 'IP');

$i++;
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, 1, erTranslationClassLhTranslation::getInstance()->getTranslation('form/index','Identifier'));

// Set data
$i = 2;
foreach ($items as $item) {
Expand All @@ -54,7 +58,10 @@
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($y, $i, $item->ctime_full_front);
$y++;
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($y, $i, $item->ip);


$y++;
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($y, $i, $item->identifier);

$i++;
}

Expand Down
8 changes: 8 additions & 0 deletions lhc_web/modules/lhform/downloaditem.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, 1, erTranslationClassLhTranslation::getInstance()->getTranslation('form/index','Date'));
$i++;
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, 1, 'IP');

$i++;
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, 1, erTranslationClassLhTranslation::getInstance()->getTranslation('form/index','Identifier'));

// Set data
$i = 2;
Expand All @@ -53,9 +56,14 @@

$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($y, $i, $item->ctime_full_front);
$y++;

$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($y, $i, $item->ip);
$i++;

$y++;
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($y, $i, $item->identifier);
$i++;

$objPHPExcel->getActiveSheet()->setTitle('Report');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');

Expand Down
5 changes: 3 additions & 2 deletions lhc_web/modules/lhinstall/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@
(5, 'Chat was closed', 'Live Helper Chat', 0, '', 0, 'Hello,\r\n\r\n{operator} has closed a chat\r\nName: {name}\r\nEmail: {email}\r\nPhone: {phone}\r\nDepartment: {department}\r\nCountry: {country}\r\nCity: {city}\r\nIP: {ip}\r\n\r\nMessage:\r\n{message}\r\n\r\nAdditional data, if any:\r\n{additional_data}\r\n\r\nURL of page from which user has send request:\r\n{url_request}\r\n\r\nSincerely,\r\nLive Support Team', 'Chat was closed', 0, '', 0, '',''),
(6, 'New FAQ question', 'Live Helper Chat', 0, '', 0, 'Hello,\r\n\r\nNew FAQ question\r\nEmail: {email}\r\n\r\nQuestion:\r\n{question}\r\n\r\nQuestion URL:\r\n{url_question}\r\n\r\nURL to answer a question:\r\n{url_request}\r\n\r\nSincerely,\r\nLive Support Team', 'New FAQ question', 0, '', 0, '', ''),
(7, 'New unread message', 'Live Helper Chat', 0, '', 0, 'Hello,\r\n\r\nUser request data:\r\nName: {name}\r\nEmail: {email}\r\nPhone: {phone}\r\nDepartment: {department}\r\nCountry: {country}\r\nCity: {city}\r\nIP: {ip}\r\n\r\nMessage:\r\n{message}\r\n\r\nURL of page from which user has send request:\r\n{url_request}\r\n\r\nClick to accept chat automatically\r\n{url_accept}\r\n\r\nSincerely,\r\nLive Support Team', 'New chat request', 0, '', 0, '{$adminEmail}',''),
(8, 'Filled form', 'Live Helper Chat', 0, '', 0, 'Hello,\r\n\r\nUser has filled a form\r\nForm name - {form_name}\r\nUser IP - {ip}\r\nDownload filled data - {url_download}\r\n\r\nSincerely,\r\nLive Support Team','Filled form - {form_name}', 0, '', 0, '{$adminEmail}',''),
(8, 'Filled form', 'Live Helper Chat', 0, '', 0, 'Hello,\r\n\r\nUser has filled a form\r\nForm name - {form_name}\r\nUser IP - {ip}\r\nDownload filled data - {url_download}\r\nView filled data - {url_view}\r\n\r\nSincerely,\r\nLive Support Team','Filled form - {form_name}', 0, '', 0, '{$adminEmail}',''),
(9, 'Chat was accepted', 'Live Helper Chat', 0, '', 0, 'Hello,\r\n\r\nOperator {user_name} has accepted a chat [{chat_id}]\r\n\r\nUser request data:\r\nName: {name}\r\nEmail: {email}\r\nPhone: {phone}\r\nDepartment: {department}\r\nCountry: {country}\r\nCity: {city}\r\nIP: {ip}\r\n\r\nMessage:\r\n{message}\r\n\r\nURL of page from which user has send request:\r\n{url_request}\r\n\r\nClick to accept chat automatically\r\n{url_accept}\r\n\r\nSincerely,\r\nLive Support Team', 'Chat was accepted [{chat_id}]', 0, '', 0, '{$adminEmail}','');");

$db->query("CREATE TABLE IF NOT EXISTS `lh_question` (
Expand Down Expand Up @@ -542,7 +542,7 @@

$db->query("CREATE TABLE IF NOT EXISTS `lh_abstract_form` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`name` varchar(100) NOT NULL,
`content` longtext NOT NULL,
`recipient` varchar(250) NOT NULL,
`active` int(11) NOT NULL,
Expand All @@ -559,6 +559,7 @@
`form_id` int(11) NOT NULL,
`ctime` int(11) NOT NULL,
`ip` varchar(250) NOT NULL,
`identifier` varchar(250) NOT NULL,
`content` longtext NOT NULL,
PRIMARY KEY (`id`),
KEY `form_id` (`form_id`)
Expand Down
5 changes: 5 additions & 0 deletions lhc_web/pos/lhabstract/erlhabstractmodelformcollected.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
$def->properties['content']->propertyName = 'content';
$def->properties['content']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_STRING;

$def->properties['identifier'] = new ezcPersistentObjectProperty();
$def->properties['identifier']->columnName = 'identifier';
$def->properties['identifier']->propertyName = 'identifier';
$def->properties['identifier']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_STRING;

return $def;

?>

0 comments on commit 135f8ac

Please sign in to comment.