From 21cdcedd567b05f14d2b3061f205d0195c0e0282 Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 01:39:39 -0200 Subject: [PATCH 01/25] add magento1 first draft --- .../community/Werules/Chatbot/Block/Index.php | 25 +++++ .../community/Werules/Chatbot/Helper/Data.php | 25 +++++ .../Werules/Chatbot/Model/Chatbotapi.php | 30 +++++ .../Werules/Chatbot/Model/Chatbotuser.php | 30 +++++ .../community/Werules/Chatbot/Model/Cron.php | 27 +++++ .../Werules/Chatbot/Model/Message.php | 30 +++++ .../Chatbot/Model/Mysql4/Chatbotapi.php | 28 +++++ .../Model/Mysql4/Chatbotapi/Collection.php | 27 +++++ .../Chatbot/Model/Mysql4/Chatbotuser.php | 28 +++++ .../Model/Mysql4/Chatbotuser/Collection.php | 27 +++++ .../Werules/Chatbot/Model/Mysql4/Message.php | 28 +++++ .../Model/Mysql4/Message/Collection.php | 27 +++++ .../Chatbot/controllers/IndexController.php | 42 +++++++ .../Werules/Chatbot/etc/adminhtml.xml | 31 ++++++ .../community/Werules/Chatbot/etc/config.xml | 86 +++++++++++++++ .../community/Werules/Chatbot/etc/system.xml | 104 ++++++++++++++++++ .../frontend/base/default/layout/chatbot.xml | 11 ++ .../base/default/template/chatbot/index.phtml | 1 + Magento1/app/etc/modules/Werules_Chatbot.xml | 10 ++ 19 files changed, 617 insertions(+) create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Index.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Helper/Data.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Cron.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Message.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi/Collection.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser/Collection.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message/Collection.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/controllers/IndexController.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml create mode 100644 Magento1/app/code/community/Werules/Chatbot/etc/config.xml create mode 100644 Magento1/app/code/community/Werules/Chatbot/etc/system.xml create mode 100644 Magento1/app/design/frontend/base/default/layout/chatbot.xml create mode 100644 Magento1/app/design/frontend/base/default/template/chatbot/index.phtml create mode 100644 Magento1/app/etc/modules/Werules_Chatbot.xml diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Index.php b/Magento1/app/code/community/Werules/Chatbot/Block/Index.php new file mode 100644 index 0000000..b1dae3b --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Index.php @@ -0,0 +1,25 @@ +. + */ + +class Werules_Chatbot_Block_Index extends Mage_Core_Block_Template +{ + +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php b/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php new file mode 100644 index 0000000..ccfa037 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php @@ -0,0 +1,25 @@ +. + */ + +class Werules_Chatbot_Helper_Data extends Mage_Core_Helper_Abstract +{ + +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php new file mode 100644 index 0000000..63ec50c --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php @@ -0,0 +1,30 @@ +. + */ + +class Werules_Chatbot_Model_Chatbotapi extends Mage_Core_Model_Abstract +{ + protected function _construct(){ + + $this->_init("chatbot/chatbotapi"); + + } + +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php new file mode 100644 index 0000000..88fe3bd --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php @@ -0,0 +1,30 @@ +. + */ + +class Werules_Chatbot_Model_Chatbotuser extends Mage_Core_Model_Abstract +{ + protected function _construct(){ + + $this->_init("chatbot/chatbotuser"); + + } + +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Cron.php b/Magento1/app/code/community/Werules/Chatbot/Model/Cron.php new file mode 100644 index 0000000..537bf7e --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Cron.php @@ -0,0 +1,27 @@ +. + */ + +class Werules_Chatbot_Model_Cron +{ + public function execute(){ + //do something + } +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Message.php b/Magento1/app/code/community/Werules/Chatbot/Model/Message.php new file mode 100644 index 0000000..1dbe478 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Message.php @@ -0,0 +1,30 @@ +. + */ + +class Werules_Chatbot_Model_Message extends Mage_Core_Model_Abstract +{ + protected function _construct(){ + + $this->_init("chatbot/message"); + + } + +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi.php new file mode 100644 index 0000000..0dce816 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi.php @@ -0,0 +1,28 @@ +. + */ + +class Werules_Chatbot_Model_Mysql4_Chatbotapi extends Mage_Core_Model_Mysql4_Abstract +{ + protected function _construct() + { + $this->_init("chatbot/chatbotapi", "chatbotapi_id"); + } +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi/Collection.php new file mode 100644 index 0000000..a7c05ed --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi/Collection.php @@ -0,0 +1,27 @@ +. + */ + +class Werules_Chatbot_Model_Mysql4_Chatbotapi_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract +{ + public function _construct(){ + $this->_init("chatbot/chatbotapi"); + } +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser.php new file mode 100644 index 0000000..faeb33e --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser.php @@ -0,0 +1,28 @@ +. + */ + +class Werules_Chatbot_Model_Mysql4_Chatbotuser extends Mage_Core_Model_Mysql4_Abstract +{ + protected function _construct() + { + $this->_init("chatbot/chatbotuser", "chatbotuser_id"); + } +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser/Collection.php new file mode 100644 index 0000000..9b27637 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser/Collection.php @@ -0,0 +1,27 @@ +. + */ + +class Werules_Chatbot_Model_Mysql4_Chatbotuser_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract +{ + public function _construct(){ + $this->_init("chatbot/chatbotuser"); + } +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message.php new file mode 100644 index 0000000..5022a8a --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message.php @@ -0,0 +1,28 @@ +. + */ + +class Werules_Chatbot_Model_Mysql4_Message extends Mage_Core_Model_Mysql4_Abstract +{ + protected function _construct() + { + $this->_init("chatbot/message", "message_id"); + } +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message/Collection.php new file mode 100644 index 0000000..ed344d5 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message/Collection.php @@ -0,0 +1,27 @@ +. + */ + +class Werules_Chatbot_Model_Mysql4_Message_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract +{ + public function _construct(){ + $this->_init("chatbot/message"); + } +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/IndexController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/IndexController.php new file mode 100644 index 0000000..3df6854 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/controllers/IndexController.php @@ -0,0 +1,42 @@ +. + */ + +class Werules_Chatbot_IndexController extends Mage_Core_Controller_Front_Action{ + public function IndexAction() { + + $this->loadLayout(); + $this->getLayout()->getBlock("head")->setTitle($this->__("Titlename")); + $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs"); + $breadcrumbs->addCrumb("home", array( + "label" => $this->__("Home Page"), + "title" => $this->__("Home Page"), + "link" => Mage::getBaseUrl() + )); + + $breadcrumbs->addCrumb("titlename", array( + "label" => $this->__("Titlename"), + "title" => $this->__("Titlename") + )); + + $this->renderLayout(); + + } +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml new file mode 100644 index 0000000..9121caf --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + General Settings Section + 0 + + + Messenger Settings Section + 1 + + + Danger Zone Section + 2 + + + + + + + + + + \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/config.xml b/Magento1/app/code/community/Werules/Chatbot/etc/config.xml new file mode 100644 index 0000000..cb51465 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/etc/config.xml @@ -0,0 +1,86 @@ + + + + + 1.0.0 + + + + + + standard + + Werules_Chatbot + chatbot + + + + + + + chatbot.xml + + + + + + + + Werules_Chatbot_Helper + + + + + Werules_Chatbot_Block + + + + + Werules_Chatbot_Model + chatbot_mysql4 + + + Werules_Chatbot_Model_Mysql4 + + + werules_chatbot_message
+
+ + werules_chatbot_chatbotuser
+
+ + werules_chatbot_chatbotapi
+
+
+
+
+ + + + Werules_Chatbot + + + core_setup + + + + + core_write + + + + + core_read + + + +
+ + + + */1 * * * * + chatbot/cron::execute + + + +
\ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml new file mode 100644 index 0000000..2f8738e --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml @@ -0,0 +1,104 @@ + + + + + + 0 + + + + + + werules_chatbot + text + 2 + 1 + 1 + 1 + + + + text + 2 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_enabledisable + 0 + 1 + 1 + 1 + Clear message pending list. After changing this value and saving, a process to clear message pending list will be schedule for the next minute. + + + + + + + + werules_chatbot + text + 0 + 1 + 1 + 1 + + + + text + 0 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_enabledisable + 0 + 1 + 1 + 1 + Enable module. + + + + + + + + werules_chatbot + text + 1 + 1 + 1 + 1 + + + + text + 1 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_enabledisable + 0 + 1 + 1 + 1 + Enable Messenger bot. + + + + + + + diff --git a/Magento1/app/design/frontend/base/default/layout/chatbot.xml b/Magento1/app/design/frontend/base/default/layout/chatbot.xml new file mode 100644 index 0000000..27e5cff --- /dev/null +++ b/Magento1/app/design/frontend/base/default/layout/chatbot.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml new file mode 100644 index 0000000..c776ee6 --- /dev/null +++ b/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml @@ -0,0 +1 @@ +Chatbot_Demo_Page \ No newline at end of file diff --git a/Magento1/app/etc/modules/Werules_Chatbot.xml b/Magento1/app/etc/modules/Werules_Chatbot.xml new file mode 100644 index 0000000..e6b69f3 --- /dev/null +++ b/Magento1/app/etc/modules/Werules_Chatbot.xml @@ -0,0 +1,10 @@ + + + + + true + community + 1.0.0 + + + \ No newline at end of file From cedd2dccf7bd47f5232b2ce1ed5a85a94d5428ea Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 01:47:05 -0200 Subject: [PATCH 02/25] add translations --- Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv b/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv index c30a7e0..cb0b2ed 100644 --- a/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv +++ b/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv @@ -1 +1 @@ -"Cancel","Cancelar" \ No newline at end of file +"Cancel","Cancelar" From 9b5cf109a78d84e29bca13bf767a062d17895e99 Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 01:48:33 -0200 Subject: [PATCH 03/25] add m1 translations --- Magento1/app/locale/en_US/Werules_Chatbot.csv | 83 +++++++++++++++++++ Magento1/app/locale/pt_BR/Werules_Chatbot.csv | 1 + Magento1/app/locale/zh_CN/Werules_Chatbot.csv | 1 + Magento1/app/locale/zh_HK/Werules_Chatbot.csv | 1 + Magento1/app/locale/zh_TW/Werules_Chatbot.csv | 1 + 5 files changed, 87 insertions(+) create mode 100644 Magento1/app/locale/en_US/Werules_Chatbot.csv create mode 100644 Magento1/app/locale/pt_BR/Werules_Chatbot.csv create mode 100644 Magento1/app/locale/zh_CN/Werules_Chatbot.csv create mode 100644 Magento1/app/locale/zh_HK/Werules_Chatbot.csv create mode 100644 Magento1/app/locale/zh_TW/Werules_Chatbot.csv diff --git a/Magento1/app/locale/en_US/Werules_Chatbot.csv b/Magento1/app/locale/en_US/Werules_Chatbot.csv new file mode 100644 index 0000000..b923d3b --- /dev/null +++ b/Magento1/app/locale/en_US/Werules_Chatbot.csv @@ -0,0 +1,83 @@ +"Cancel","Cancel" +"Sorry, no products found for this criteria.","Sorry, no products found for this criteria." +"Sorry, no products found in this category.","Sorry, no products found in this category." +"Please select a category.","Please select a category." +"Sure, send me the name of the product you're looking for.","Sure, send me the name of the product you're looking for" +"Add to cart","Add to cart" +"Visit product's page","Visit product's page" +"Command","Command" +"Enable Command","Enable Command" +"Command Code","Command Code" +"Command Alias (Separated by Comma)","Command Alias (Separated by Comma)" +"Add","Add" +"Enable","Enable" +"List Categories","List Categories" +"List More","List More" +"Search For Product","Search For Product" +"Login","Login" +"List Orders","List Orders" +"Reorder","Reorder" +"Add Product to Cart","Add Product to Cart" +"Checkout on Website","Checkout on Website" +"Clear Cart","Clear Cart" +"Track Order Status","Track Order Status" +"Talk to Support","Talk to Support" +"Send Email","Send Email" +"Help","Help" +"About","About" +"Logout","Logout" +"Register","Register" +"Enable Reply","Enable Reply" +"wit.ai entity","wit.ai entity" +"Acceptable Confidence (%)","Acceptable Confidence (%)" +"Stop Processing","Stop Processing" +"Reply Mode","Reply Mode" +"Reply Text","Reply Text" +"No Reply","No Reply" +"Text Only","Text Only" +"Command Only","Command Only" +"Text and Command","Text and Command" +"Please check your Hub Verify Token.","Please check your Hub Verify Token." +"Mapped Command","Mapped Command" +"Ok, canceled.","Ok, canceled." +"Access %1 to register a new account on our shop.","Access %1 to register a new account on our shop." +"Not informed","Not informed" +"Message from chatbot customer","Message from chatbot customer" +"Customer name","Customer name" +"Message","Message" +"Contacts","Contacts" +"Chatbot","Chatbot" +"Email","Email" +"Contact from chatbot","Contact from chatbot" +"Sure, send me the email content.","Sure, send me the email content." +"Sorry, I wasn't able to send an email this time. Please try again later.","Sorry, I wasn't able to send an email this time. Please try again later." +"Email sent.","Email sent." +"Sorry, I didn't understand that.","Sorry, I didn't understand that." +"You are already logged.","You are already logged." +"You are already registered.","You are already registered." +"Receive Promotional Messages?","Receive Promotional Messages?" +"Enable Messenger?","Enable Messenger?" +"Chatbot Settings","Chatbot Settings" +"Chatbot settings saved successfully.","Chatbot settings saved successfully." +"Something went wrong, please try again.","Something went wrong, please try again." +"You still haven't chat with our Chatbot.","You still haven't chat with our Chatbot." +"You haven't changed any data in the settings.","You haven't changed any data in the settings." +"Invalid URL hash, please try again.","Invalid URL hash, please try again." +"Ok, you're logged out.","Ok, you're logged out." +"This account has no orders.","This account has no orders." +"Ok, send me the order number you're looking for.","Ok, send me the order number you're looking for." +"Sorry, we couldn't find any order with this information.","Sorry, we couldn't find any order with this information." +"Ok, I just add the product to your cart, to checkout send '%1'.","Ok, I just add the product to your cart, to checkout send '%1'." +"Cart cleared.","Cart cleared." +"If you want to reorder one of these orders choose it below.","If you want to reorder one of these orders choose it below." +"All products from order %1 that are in stock were added to your cart.","All products from order %1 that are in stock were added to your cart." +"Your cart is empty.","Your cart is empty." +"Product:","Product:" +"Price:","Price:" +"Quantity:","Quantity:" +"Subtotal:","Subtotal:" +"Subtotal (Tax Incl.):","Subtotal (Tax Incl.):" +"To chat with me, please enable Messenger on your account chatbot settings.","To chat with me, please enable Messenger on your account chatbot settings." +"To list more send '%1'.","To list more send '%1'." +"No more items to list.","No more items to list." +"This category doesn't seems to exist. Please try again.","This category doesn't seems to exist. Please try again." diff --git a/Magento1/app/locale/pt_BR/Werules_Chatbot.csv b/Magento1/app/locale/pt_BR/Werules_Chatbot.csv new file mode 100644 index 0000000..a276ac2 --- /dev/null +++ b/Magento1/app/locale/pt_BR/Werules_Chatbot.csv @@ -0,0 +1 @@ +"Cancel.","Cancelar." \ No newline at end of file diff --git a/Magento1/app/locale/zh_CN/Werules_Chatbot.csv b/Magento1/app/locale/zh_CN/Werules_Chatbot.csv new file mode 100644 index 0000000..0b573fa --- /dev/null +++ b/Magento1/app/locale/zh_CN/Werules_Chatbot.csv @@ -0,0 +1 @@ +"Cancel.","取消。" \ No newline at end of file diff --git a/Magento1/app/locale/zh_HK/Werules_Chatbot.csv b/Magento1/app/locale/zh_HK/Werules_Chatbot.csv new file mode 100644 index 0000000..0b573fa --- /dev/null +++ b/Magento1/app/locale/zh_HK/Werules_Chatbot.csv @@ -0,0 +1 @@ +"Cancel.","取消。" \ No newline at end of file diff --git a/Magento1/app/locale/zh_TW/Werules_Chatbot.csv b/Magento1/app/locale/zh_TW/Werules_Chatbot.csv new file mode 100644 index 0000000..0b573fa --- /dev/null +++ b/Magento1/app/locale/zh_TW/Werules_Chatbot.csv @@ -0,0 +1 @@ +"Cancel.","取消。" \ No newline at end of file From f55e7be67239eebd2d9ccd2998ff5fa75a4edb9f Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 01:58:52 -0200 Subject: [PATCH 04/25] add installation file --- .../Chatbot/Model/Adminhtml/Serialized.php | 35 ++++++++++ .../community/Werules/Chatbot/etc/config.xml | 12 ++-- .../chatbot_setup/mysql4-install-1.0.0.php | 67 +++++++++++++++++++ Magento1/app/etc/modules/Werules_Chatbot.xml | 2 +- 4 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Adminhtml/Serialized.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Adminhtml/Serialized.php b/Magento1/app/code/community/Werules/Chatbot/Model/Adminhtml/Serialized.php new file mode 100644 index 0000000..e0b9ad5 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Adminhtml/Serialized.php @@ -0,0 +1,35 @@ +getValue())) { + $serializedValue = $this->getValue(); + $unserializedValue = false; + if ($serializedValue) { + try { + $unserializedValue = Mage::helper('core/unserializeArray') + ->unserialize((string)$serializedValue); // fix magento unserializing bug + } catch (Exception $e) { + Mage::logException($e); + } + } + $this->setValue($unserializedValue); + } + } + + protected function _beforeSave() + { + $value = $this->getValue(); + if (is_array($value)) { + unset($value['__empty']); + } + $this->setValue($value); + + if (is_array($this->getValue())) + { + $this->setValue(serialize($this->getValue())); + } + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/config.xml b/Magento1/app/code/community/Werules/Chatbot/etc/config.xml index cb51465..5dec362 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/config.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/config.xml @@ -77,10 +77,14 @@ - - */1 * * * * - chatbot/cron::execute - + + + */1 * * * * + + + chatbot/cron::execute + + \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php b/Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php new file mode 100644 index 0000000..9c0f65b --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php @@ -0,0 +1,67 @@ +startSetup(); //db installation + +$installer->run(" + -- DROP TABLE IF EXISTS {$this->getTable($table)}; + CREATE TABLE {$this->getTable($table)} ( + `entity_id` int(11) unsigned NOT NULL auto_increment, + `created_at` timestamp NULL, + `updated_at` timestamp NULL, + `customer_id` int(11) NULL, + `session_id` varchar(150) NULL, + `quote_id` varchar(20) NULL, + `hash_key` varchar(150) NULL, + `is_admin` smallint(1) NOT NULL default '0', + `is_logged` smallint(1) NOT NULL default '0', + `enable_promotional_messages` smallint(1) NOT NULL default '1', + `enable_support` smallint(1) NOT NULL default '1', + `last_support_message_id` varchar(50) NULL, + `last_support_chat` varchar(20) NULL, + `enable_telegram_admin` smallint(1) NOT NULL default '1', + `enable_telegram` smallint(1) NOT NULL default '1', + `telegram_processing_request` smallint(1) NOT NULL default '0', + `telegram_chat_id` varchar(50) NULL, + `telegram_message_id` varchar(50) NULL, + `telegram_conv_state` int(10) NOT NULL default '0', + `telegram_support_reply_chat_id` varchar(50) NULL, + `telegram_fallback_qty` int(10) NOT NULL default '0', + `enable_facebook_admin` smallint(1) NOT NULL default '1', + `enable_facebook` smallint(1) NOT NULL default '1', + `facebook_processing_request` smallint(1) NOT NULL default '0', + `facebook_chat_id` varchar(50) NULL, + `facebook_message_id` varchar(50) NULL, + `facebook_conv_state` int(10) NOT NULL default '0', + `facebook_support_reply_chat_id` varchar(50) NULL, + `facebook_fallback_qty` int(10) NOT NULL default '0', + `enable_whatsapp_admin` smallint(1) NOT NULL default '1', + `enable_whatsapp` smallint(1) NOT NULL default '1', + `whatsapp_processing_request` smallint(1) NOT NULL default '0', + `whatsapp_chat_id` varchar(50) NULL, + `whatsapp_message_id` varchar(50) NULL, + `whatsapp_conv_state` int(10) NOT NULL default '0', + `whatsapp_support_reply_chat_id` varchar(50) NULL, + `whatsapp_fallback_qty` int(10) NOT NULL default '0', + `enable_wechat_admin` smallint(1) NOT NULL default '1', + `enable_wechat` smallint(1) NOT NULL default '1', + `wechat_processing_request` smallint(1) NOT NULL default '0', + `wechat_chat_id` varchar(50) NULL, + `wechat_message_id` varchar(50) NULL, + `wechat_conv_state` int(10) NOT NULL default '0', + `wechat_support_reply_chat_id` varchar(50) NULL, + `wechat_fallback_qty` int(10) NOT NULL default '0', + `enable_skype_admin` smallint(1) NOT NULL default '1', + `enable_skype` smallint(1) NOT NULL default '1', + `skype_processing_request` smallint(1) NOT NULL default '0', + `skype_chat_id` varchar(50) NULL, + `skype_message_id` varchar(50) NULL, + `skype_conv_state` int(10) NOT NULL default '0', + `skype_support_reply_chat_id` varchar(50) NULL, + `skype_fallback_qty` int(10) NOT NULL default '0', + PRIMARY KEY (entity_id) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + "); + +$installer->endSetup(); diff --git a/Magento1/app/etc/modules/Werules_Chatbot.xml b/Magento1/app/etc/modules/Werules_Chatbot.xml index e6b69f3..debcd90 100644 --- a/Magento1/app/etc/modules/Werules_Chatbot.xml +++ b/Magento1/app/etc/modules/Werules_Chatbot.xml @@ -1,4 +1,4 @@ - + From d772d4f2919bf20e9b555ffcb719c7db725628d4 Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 02:19:12 -0200 Subject: [PATCH 05/25] add new files --- .../Werules/Chatbot/Block/Messenger.php | 25 ++++++ .../Werules/Chatbot/Block/Telegram.php | 25 ++++++ .../Chatbot/Model/Adminhtml/Serialized.php | 76 ++++++++++++------- .../controllers/MessengerController.php | 42 ++++++++++ .../controllers/TelegramController.php | 42 ++++++++++ .../Werules/Chatbot/etc/adminhtml.xml | 60 +++++++-------- .../community/Werules/Chatbot/etc/config.xml | 38 ++++++++-- .../chatbot_setup/mysql4-install-1.0.0.php | 19 +++++ .../frontend/base/default/layout/chatbot.xml | 11 --- .../default/layout/chatbot_customer_index.xml | 18 +++++ .../default/layout/chatbot_webhook_index.xml | 16 ++++ .../layout/chatbot_webhook_messenger.xml | 16 ++++ .../layout/chatbot_webhook_telegram.xml | 16 ++++ .../default/template/chatbot/messenger.phtml | 1 + .../default/template/chatbot/settings.phtml | 1 + .../default/template/chatbot/telegram.phtml | 1 + 16 files changed, 331 insertions(+), 76 deletions(-) create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Messenger.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Telegram.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/controllers/MessengerController.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/controllers/TelegramController.php delete mode 100644 Magento1/app/design/frontend/base/default/layout/chatbot.xml create mode 100644 Magento1/app/design/frontend/base/default/layout/chatbot_customer_index.xml create mode 100644 Magento1/app/design/frontend/base/default/layout/chatbot_webhook_index.xml create mode 100644 Magento1/app/design/frontend/base/default/layout/chatbot_webhook_messenger.xml create mode 100644 Magento1/app/design/frontend/base/default/layout/chatbot_webhook_telegram.xml create mode 100644 Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml create mode 100644 Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml create mode 100644 Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Messenger.php b/Magento1/app/code/community/Werules/Chatbot/Block/Messenger.php new file mode 100644 index 0000000..88d4855 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Messenger.php @@ -0,0 +1,25 @@ +. + */ + +class Werules_Chatbot_Block_Messenger extends Mage_Core_Block_Template +{ + +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Telegram.php b/Magento1/app/code/community/Werules/Chatbot/Block/Telegram.php new file mode 100644 index 0000000..3d0f396 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Telegram.php @@ -0,0 +1,25 @@ +. + */ + +class Werules_Chatbot_Block_Telegram extends Mage_Core_Block_Template +{ + +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Adminhtml/Serialized.php b/Magento1/app/code/community/Werules/Chatbot/Model/Adminhtml/Serialized.php index e0b9ad5..5f8478f 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Adminhtml/Serialized.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Adminhtml/Serialized.php @@ -1,35 +1,55 @@ . + */ + // this class is used to replace Magento own class that contains a glitch class Werules_Chatbot_Model_Adminhtml_Serialized extends Mage_Adminhtml_Model_System_Config_Backend_Serialized { - protected function _afterLoad() - { - if (!is_array($this->getValue())) { - $serializedValue = $this->getValue(); - $unserializedValue = false; - if ($serializedValue) { - try { - $unserializedValue = Mage::helper('core/unserializeArray') - ->unserialize((string)$serializedValue); // fix magento unserializing bug - } catch (Exception $e) { - Mage::logException($e); - } - } - $this->setValue($unserializedValue); - } - } + protected function _afterLoad() + { + if (!is_array($this->getValue())) { + $serializedValue = $this->getValue(); + $unserializedValue = false; + if ($serializedValue) { + try { + $unserializedValue = Mage::helper('core/unserializeArray') + ->unserialize((string)$serializedValue); // fix magento unserializing bug + } catch (Exception $e) { + Mage::logException($e); + } + } + $this->setValue($unserializedValue); + } + } - protected function _beforeSave() - { - $value = $this->getValue(); - if (is_array($value)) { - unset($value['__empty']); - } - $this->setValue($value); + protected function _beforeSave() + { + $value = $this->getValue(); + if (is_array($value)) { + unset($value['__empty']); + } + $this->setValue($value); - if (is_array($this->getValue())) - { - $this->setValue(serialize($this->getValue())); - } - } + if (is_array($this->getValue())) + { + $this->setValue(serialize($this->getValue())); + } + } } diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/MessengerController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/MessengerController.php new file mode 100644 index 0000000..3df6854 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/controllers/MessengerController.php @@ -0,0 +1,42 @@ +. + */ + +class Werules_Chatbot_IndexController extends Mage_Core_Controller_Front_Action{ + public function IndexAction() { + + $this->loadLayout(); + $this->getLayout()->getBlock("head")->setTitle($this->__("Titlename")); + $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs"); + $breadcrumbs->addCrumb("home", array( + "label" => $this->__("Home Page"), + "title" => $this->__("Home Page"), + "link" => Mage::getBaseUrl() + )); + + $breadcrumbs->addCrumb("titlename", array( + "label" => $this->__("Titlename"), + "title" => $this->__("Titlename") + )); + + $this->renderLayout(); + + } +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/TelegramController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/TelegramController.php new file mode 100644 index 0000000..3df6854 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/controllers/TelegramController.php @@ -0,0 +1,42 @@ +. + */ + +class Werules_Chatbot_IndexController extends Mage_Core_Controller_Front_Action{ + public function IndexAction() { + + $this->loadLayout(); + $this->getLayout()->getBlock("head")->setTitle($this->__("Titlename")); + $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs"); + $breadcrumbs->addCrumb("home", array( + "label" => $this->__("Home Page"), + "title" => $this->__("Home Page"), + "link" => Mage::getBaseUrl() + )); + + $breadcrumbs->addCrumb("titlename", array( + "label" => $this->__("Titlename"), + "title" => $this->__("Titlename") + )); + + $this->renderLayout(); + + } +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml index 9121caf..d33da68 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml @@ -1,31 +1,31 @@ - - - - - - - - - - - General Settings Section - 0 - - - Messenger Settings Section - 1 - - - Danger Zone Section - 2 - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + General Settings + 0 + + + Messenger Settings + 1 + + + Danger Zone + 2 + + + + + + + + + + \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/config.xml b/Magento1/app/code/community/Werules/Chatbot/etc/config.xml index 5dec362..90f0b07 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/config.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/config.xml @@ -6,6 +6,37 @@ + + + + + Werules_Chatbot.csv + + + + + + + + chatbot_customer_index.xml + + + + + chatbot_webhook_index.xml + + + + + chatbot_webhook_messenger.xml + + + + + chatbot_webhook_telegram.xml + + + standard @@ -15,13 +46,6 @@ - - - - chatbot.xml - - - diff --git a/Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php b/Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php index 9c0f65b..88a832f 100644 --- a/Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php +++ b/Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php @@ -1,4 +1,23 @@ . + */ $table = 'wr_chatbot'; $installer = $this; diff --git a/Magento1/app/design/frontend/base/default/layout/chatbot.xml b/Magento1/app/design/frontend/base/default/layout/chatbot.xml deleted file mode 100644 index 27e5cff..0000000 --- a/Magento1/app/design/frontend/base/default/layout/chatbot.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/layout/chatbot_customer_index.xml b/Magento1/app/design/frontend/base/default/layout/chatbot_customer_index.xml new file mode 100644 index 0000000..0d72252 --- /dev/null +++ b/Magento1/app/design/frontend/base/default/layout/chatbot_customer_index.xml @@ -0,0 +1,18 @@ + + + + + + chatbot_settings + chatbot/customer/index + + + + + + + + + + + \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/layout/chatbot_webhook_index.xml b/Magento1/app/design/frontend/base/default/layout/chatbot_webhook_index.xml new file mode 100644 index 0000000..af508f5 --- /dev/null +++ b/Magento1/app/design/frontend/base/default/layout/chatbot_webhook_index.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/layout/chatbot_webhook_messenger.xml b/Magento1/app/design/frontend/base/default/layout/chatbot_webhook_messenger.xml new file mode 100644 index 0000000..4a0f504 --- /dev/null +++ b/Magento1/app/design/frontend/base/default/layout/chatbot_webhook_messenger.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/layout/chatbot_webhook_telegram.xml b/Magento1/app/design/frontend/base/default/layout/chatbot_webhook_telegram.xml new file mode 100644 index 0000000..c76d547 --- /dev/null +++ b/Magento1/app/design/frontend/base/default/layout/chatbot_webhook_telegram.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml new file mode 100644 index 0000000..c776ee6 --- /dev/null +++ b/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml @@ -0,0 +1 @@ +Chatbot_Demo_Page \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml new file mode 100644 index 0000000..c776ee6 --- /dev/null +++ b/Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml @@ -0,0 +1 @@ +Chatbot_Demo_Page \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml new file mode 100644 index 0000000..c776ee6 --- /dev/null +++ b/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml @@ -0,0 +1 @@ +Chatbot_Demo_Page \ No newline at end of file From 7b63cdfa826b927c86035482febdaaca84ebe839 Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 02:25:11 -0200 Subject: [PATCH 06/25] add api files --- .../Werules/Chatbot/Helper/Define.php | 99 ++++ .../Werules/Chatbot/Model/Api/Messenger.php | 442 ++++++++++++++++++ .../Werules/Chatbot/Model/Api/witAI.php | 67 +++ 3 files changed, 608 insertions(+) create mode 100644 Magento1/app/code/community/Werules/Chatbot/Helper/Define.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Api/Messenger.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Api/witAI.php diff --git a/Magento1/app/code/community/Werules/Chatbot/Helper/Define.php b/Magento1/app/code/community/Werules/Chatbot/Helper/Define.php new file mode 100644 index 0000000..65b1341 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Helper/Define.php @@ -0,0 +1,99 @@ +. + */ + +class Define +{ + const MESSENGER_INT = 0; + const TELEGRAM_INT = 1; + const NOT_PROCESSED = 0; + const PROCESSING = 1; + const PROCESSED = 2; + const INCOMING = 0; + const OUTGOING = 1; + const DISABLED = 0; + const ENABLED = 1; + const NOT_LOGGED = 0; + const NOT_ADMIN = 0; + const ADMIN = 1; + const LOGGED = 1; + const SECONDS_IN_HOUR = 3600; + const SECONDS_IN_MINUTE = 60; + const DEFAULT_MIN_CONFIDENCE = 0.7; + const BREAK_LINE = '\n'; // chr(10) + const QUEUE_PROCESSING_LIMIT = self::SECONDS_IN_MINUTE * 3; + + // commands + const START_COMMAND_ID = 0; + const LIST_CATEGORIES_COMMAND_ID = 1; + const SEARCH_COMMAND_ID = 2; + const LOGIN_COMMAND_ID = 3; + const LIST_ORDERS_COMMAND_ID = 4; + const REORDER_COMMAND_ID = 5; + const ADD_TO_CART_COMMAND_ID = 6; + const CHECKOUT_COMMAND_ID = 7; + const CLEAR_CART_COMMAND_ID = 8; + const TRACK_ORDER_COMMAND_ID = 9; + const SUPPORT_COMMAND_ID = 10; + const SEND_EMAIL_COMMAND_ID = 11; + const CANCEL_COMMAND_ID = 12; + const HELP_COMMAND_ID = 13; + const ABOUT_COMMAND_ID = 14; + const LOGOUT_COMMAND_ID = 15; + const REGISTER_COMMAND_ID = 16; + const LIST_MORE_COMMAND_ID = 17; + const LAST_COMMAND_DETAILS_DEFAULT = '{"last_command_parameter":"","last_command_text":"","last_conversation_state":0,"last_listed_quantity":0}'; +// array( +// 'last_command_parameter' => '', +// 'last_command_text' => '', +// 'last_conversation_state' => 0, +// 'last_listed_quantity' => 0, +// ); + const CURRENT_COMMAND_DETAILS_DEFAULT = '[]'; +// json_encode(array()) + + // message content types + const CONTENT_TEXT = 0; + const QUICK_REPLY = 1; + const IMAGE_WITH_TEXT = 2; + const IMAGE_WITH_OPTIONS = 3; + const RECEIPT_LAYOUT = 4; + const LIST_WITH_IMAGE = 5; + const TEXT_WITH_OPTIONS = 6; + + // conversation states + const CONVERSATION_STARTED = 0; + const CONVERSATION_LIST_CATEGORIES = 1; + const CONVERSATION_SEARCH = 2; + const CONVERSATION_EMAIL = 3; + const CONVERSATION_TRACK_ORDER = 4; + + // API + const MAX_MESSAGE_ELEMENTS = 7; + + // MESSAGE QUEUE MODES + const QUEUE_NONE = 0; + const QUEUE_SIMPLE_RESTRICTIVE = 1; + const QUEUE_RESTRICTIVE = 2; + const QUEUE_NON_RESTRICTIVE = 3; + + const DONT_CLEAR_MESSAGE_QUEUE = 0; + const CLEAR_MESSAGE_QUEUE = 1; +} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Api/Messenger.php b/Magento1/app/code/community/Werules/Chatbot/Model/Api/Messenger.php new file mode 100644 index 0000000..3122aa1 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Api/Messenger.php @@ -0,0 +1,442 @@ + + * TODO: + * https://developers.facebook.com/docs/messenger-platform/send-api-reference/buy-button + * https://developers.facebook.com/docs/messenger-platform/send-api-reference/url-button + * https://developers.facebook.com/docs/messenger-platform/send-api-reference/image-attachment + * https://developers.facebook.com/docs/messenger-platform/send-api-reference/sender-actions + * https://developers.facebook.com/docs/messenger-platform/send-api-reference/errors + */ + +/** + * Magento Chatbot Integration + * Copyright (C) 2017 + * + * This file is part of Werules/Chatbot. + * + * Werules/Chatbot is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +class Werules_Chatbot_Model_Api_Messenger extends Mage_Core_Model_Mysql4_Abstract { + + private $bot_token; + private $api_version = "v2.11"; + private $data; + + /// Class constructor + public function __construct($bot_token) { + $this->bot_token = $bot_token; + $this->data = $this->getPostData(); + } + + /// Verify webhook + public function verifyWebhook($hub_token) { + if (isset($this->data['hub_verify_token'])) + { + if ($this->data['hub_verify_token'] == $hub_token) { + if (isset($this->data['hub_challenge'])) + return $this->data['hub_challenge']; + } + } + + return ''; + } + + /// Do requests to Messenger Bot API + public function endpoint($api, array $content, $post = true) { + $url = 'https://graph.facebook.com/' . $this->api_version . '/' . $api . '?access_token=' . $this->bot_token; + if ($post) + $reply = $this->sendAPIRequest($url, $content); + else + $reply = $this->sendAPIRequest($url, array(), false); + return json_decode($reply, true); + } + + public function respondSuccess() { + http_response_code(200); + return json_encode(array("status" => "success")); + } + + // send chat action + // sender_action: + // mark_seen + // typing_on + // typing_off + public function sendChatAction($chat_id, $action) { + return $this->endpoint("me/messages", array( + 'recipient' => array( + 'id' => $chat_id + ), + 'sender_action' => $action + ) + ); + } + + // send message +// https://developers.facebook.com/docs/messenger-platform/send-api-reference#request + public function sendMessage($chat_id, $text) { + return $this->endpoint("me/messages", array( + 'recipient' => array( + 'id' => $chat_id + ), + 'message' => array( + 'text' => $text + ) + ) + ); + } + +// sendGenericTemplate +// $button = array( +// array( +// 'type' => 'web_url', +// 'url' => 'URL_HERE', +// 'title' => 'TITLE_HERE' +// ), +// array( +// 'type' => 'web_url', +// 'url' => 'URL_HERE', +// 'title' => 'TITLE_HERE' +// ), +// ... +// ); +// $elements = array( +// array( +// 'title' => 'TITLE_TEXT_HERE', +// 'item_url' => 'ITEM_URL_HERE', +// 'image_url' => 'IMAGE_URL_HERE', +// 'subtitle' => 'SUBTITLE_HERE', +// 'buttons' => $buttons +// ) +// ); +// https://developers.facebook.com/docs/messenger-platform/send-api-reference#request + public function sendGenericTemplate($chat_id, array $elements) { + return $this->endpoint("me/messages", array( + 'recipient' => array( + 'id' => $chat_id + ), + 'message' => array( + 'attachment' => array( + 'type' => 'template', + 'payload' => array( + 'template_type' => 'generic', + 'elements' => $elements + ) + ) + ) + ) + ); + } + +// https://developers.facebook.com/docs/messenger-platform/send-messages/template/list#example_request +// $elements = array( +// array( +// 'title' => 'Classic T-Shirt Collection', +// 'subtitle' => 'See all our colors 1', +// 'image_url' => 'https://mysite.com/image/toy_1.jpg', +// 'buttons' => array( +// array( +// 'title' => 'View', +// 'type' => 'web_url', +// 'url' => 'https://mysite.com/' +// ) +// ) +// ), +// array( +// 'title' => 'Classic White T-Shirt', +// 'subtitle' => 'See all our colors', +// 'default_action' => array( +// 'type' => 'web_url', +// 'url' => 'https://mysite.com/' +// ) +// ), +// array( +// 'title' => 'Classic Blue T-Shirt', +// 'image_url' => 'https://mysite.com/image/toy_1.jpg', +// 'subtitle' => '100% Cotton, 200% Comfortable', +// 'default_action' => array( +// 'type' => 'web_url', +// 'url' => 'https://mysite.com/' +// ), +// 'buttons' => array( +// array( +// 'title' => 'Shop Now', +// 'type' => 'web_url', +// 'url' => 'https://mysite.com/' +// ) +// ) +// ) +// ); +// $buttons = array( +// array( +// 'title' => 'View More', +// 'type' => 'postback', +// 'payload' => 'payload', +// ) + +// ); + + public function sendListTemplate($chat_id, array $elements, array $buttons = array(), $top_element = 'compact') { + return $this->endpoint("me/messages", array( + 'recipient' => array( + 'id' => $chat_id + ), + 'message' => array( + 'attachment' => array( + 'type' => 'template', + 'payload' => array( + 'template_type' => 'list', + 'top_element_style' => $top_element, + 'elements' => $elements, + 'buttons' => $buttons + ) + ) + ) + ) + ); + } + + // send quick reply +// $replies = array( +// array( +// 'content_type' => 'text', +// 'title' => 'TITLE_HERE', +// 'payload' => 'DEVELOPER_CUSTOM_PAYLOAD_HERE' +// ), +// array( +// 'content_type' => 'text', +// 'title' => 'TITLE_HERE', +// 'payload' => 'DEVELOPER_CUSTOM_PAYLOAD_HERE' +// ), +// ... +// ); +// https://developers.facebook.com/docs/messenger-platform/send-api-reference/quick-replies + public function sendQuickReply($chat_id, $text, array $replies) { + return $this->endpoint("me/messages", array( + 'recipient' => array( + 'id' => $chat_id + ), + 'message' => array( + 'text' => $text, + 'quick_replies' => $replies + ) + ) + ); + } + + // send button +// $buttons = array( +// array( +// 'type' => 'web_url', +// 'url' => 'URL_HERE', +// 'title' => 'TITLE_HERE' +// ), +// array( +// 'type' => 'web_url', +// 'url' => 'URL_HERE', +// 'title' => 'TITLE_HERE' +// ), +// ... +// ); +// https://developers.facebook.com/docs/messenger-platform/send-api-reference/button-template +// https://developers.facebook.com/docs/messenger-platform/send-api-reference/share-button <- works only with sendGenericTemplate + public function sendButtonTemplate($chat_id, $text, array $buttons) { + return $this->endpoint("me/messages", + array( + 'recipient' => array( + 'id' => $chat_id + ), + 'message' => array( + 'attachment' => array( + 'type' => 'template', + 'payload' => array( + 'template_type' => 'button', + 'text' => $text, + 'buttons' => $buttons + ) + ) + ) + ) + ); + } + + // send elements +// $elements = array( +// array( +// 'title' => 'TITLE_TEXT_HERE', +// 'item_url' => 'ITEM_URL_HERE', +// 'image_url' => 'IMAGE_URL_HERE', +// 'subtitle' => 'SUBTITLE_HERE', +// 'buttons' => $buttons +// ) +// ); +// https://developers.facebook.com/docs/messenger-platform/send-api-reference/receipt-template + public function sendReceiptTemplate($chat_id, array $payload) { + return $this->endpoint("me/messages", + array( + 'recipient' => array( + 'id' => $chat_id + ), + 'message' => array( + 'attachment' => array( + 'type' => 'template', + 'payload' => $payload + ) + ) + ) + ); + } + + /// Get the text of the current message + public function Text() { + if (isset($this->data["entry"][0]["messaging"][0]["message"]["text"])) + return $this->data["entry"][0]["messaging"][0]["message"]["text"]; + + return ''; + } + + /// Get the userdata who sent the message + public function UserData($chat_id) { + return $this->endpoint($chat_id, array(), false); + } + + /// Get the chat_id of the current message + public function ChatID() { + if (isset($this->data["entry"][0]['messaging'][0]['sender']['id'])) + return $this->data['entry'][0]['messaging'][0]['sender']['id']; + + return ''; + } + + /// Get the recipient_id of the current message + public function RecipientID() { + if (isset($this->data["entry"][0]['messaging'][0]['recipient']['id'])) + return $this->data['entry'][0]['messaging'][0]['recipient']['id']; + + return ''; + } + + /// Get m.me ref type + public function getReferralType() { + if (isset($this->data["entry"][0]["messaging"][0]["referral"]["type"])) + return $this->data["entry"][0]["messaging"][0]["referral"]["type"]; + + return ''; + } + + /// Get m.me ref data + public function getReferralRef() { + if (isset($this->data["entry"][0]["messaging"][0]["referral"]["ref"])) + return $this->data["entry"][0]["messaging"][0]["referral"]["ref"]; + + return ''; + } + + /// Get postback payload + public function getPostbackPayload() { + if (isset($this->data["entry"][0]["messaging"][0]["postback"]["payload"])) + return $this->data["entry"][0]["messaging"][0]["postback"]["payload"]; + + return ''; + } + + /// Get postback title + public function getPostbackTitle() { + if (isset($this->data["entry"][0]["messaging"][0]["postback"]["title"])) + return $this->data["entry"][0]["messaging"][0]["postback"]["title"]; + + return ''; + } + + /// Get quickreply payload + public function getQuickReplyPayload() { + if (isset($this->data["entry"][0]["messaging"][0]["message"]["quick_reply"]["payload"])) + return $this->data["entry"][0]["messaging"][0]["message"]["quick_reply"]["payload"]; + + return ''; + } + + /// Get message timestamp + public function getMessageTimestamp() { + if (isset($this->data["entry"][0]["time"])) + return $this->data["entry"][0]["time"]; + + return ''; + } + + /// Get the message_id of the current message + public function MessageID() { + if (isset($this->data["entry"][0]["messaging"][0]["message"]["mid"])) + return $this->data["entry"][0]["messaging"][0]["message"]["mid"]; + + return ''; + } + + /// Get the is_echo of the current message + public function getEcho() { + if (isset($this->data["entry"][0]["messaging"][0]["message"]["is_echo"])) + return $this->data["entry"][0]["messaging"][0]["message"]["is_echo"]; + + return ''; + } + + /// Get the app_id of the current message + public function getAppId() { + if (isset($this->data["entry"][0]["messaging"][0]["message"]["app_id"])) + return $this->data["entry"][0]["messaging"][0]["message"]["app_id"]; + + return ''; + } + + private function sendAPIRequest($url, array $content, $post = true, $response = true) { + $ch = curl_init($url); + if ($post) { + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($content)); + } + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + if ($response) + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + $result = curl_exec($ch); + curl_close($ch); + return $result; + } + + /// Get the data of the current message + public function getPostData() { + if (!($this->data)) { + $rawData = file_get_contents("php://input"); + if ($rawData) + return json_decode($rawData, true); + else + return $_REQUEST; + } else { + return $this->data; + } + } +} + +// Helper for Uploading file using CURL +if (!function_exists('curl_file_create')) { + + function curl_file_create($filename, $mimetype = '', $postname = '') { + return "@$filename;filename=" + . ($postname ? : basename($filename)) + . ($mimetype ? ";type=$mimetype" : ''); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Api/witAI.php b/Magento1/app/code/community/Werules/Chatbot/Model/Api/witAI.php new file mode 100644 index 0000000..d975a72 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Api/witAI.php @@ -0,0 +1,67 @@ +. +*/ + +class Werules_Chatbot_Model_Api_witAI extends Mage_Core_Model_Mysql4_Abstract { + + protected $_token; + protected $_version = '11/12/2017'; + //protected $_data; + + /// Class constructor + public function __construct($token) { + $this->_token = $token; + } + + function getTextResponse($query) { + $options = array( + 'http' => array( + 'method' => 'GET', + 'header' => "Authorization: Bearer " . $this->_token . "\r\n" + ) + ); + $content = "&q=" . urlencode($query); + return $this->getWitAIResponse("message", $content, $options); + } + + function getAudioResponse($audioFile) { + $options = array( + 'http' => array( + 'method' => 'POST', + 'header' => "Authorization: Bearer " . $this->_token . "\n" . + "Content-Type: audio/mpeg3" . "\r\n", + 'content' => file_get_contents($audioFile) + ) + ); + return $this->getWitAIResponse("speech", "", $options); + } + + function getWitAIResponse($endPoint, $content, $options) { + $context = stream_context_create($options); + $url = 'https://api.wit.ai/' . $endPoint . '?v=' . $this->_version . $content; + $result = file_get_contents($url, false, $context); + $result = json_decode($result, true); + + if ($result) + return $result; + + return null; + } +} From 914a99aa85a626b45366534bc2addf7690d02652 Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 02:37:15 -0200 Subject: [PATCH 07/25] add static files --- ...rController.php => CustomerController.php} | 2 +- .../controllers/TelegramController.php | 42 --------------- ...exController.php => WebhookController.php} | 0 .../default/layout/werules_chatbot.xml | 9 ++++ .../base/default/template/chatbot/index.phtml | 2 +- .../default/template/chatbot/messenger.phtml | 2 +- .../default/template/chatbot/settings.phtml | 2 +- .../default/template/chatbot/telegram.phtml | 2 +- Magento1/js/werules/chatbot/chatbot.js | 50 ++++++++++++++++++ .../default/css/werules_chatbot/chatbot.css | 12 +++++ .../images/werules_chatbot/messenger-icon.png | Bin 0 -> 6248 bytes 11 files changed, 76 insertions(+), 47 deletions(-) rename Magento1/app/code/community/Werules/Chatbot/controllers/{MessengerController.php => CustomerController.php} (94%) delete mode 100644 Magento1/app/code/community/Werules/Chatbot/controllers/TelegramController.php rename Magento1/app/code/community/Werules/Chatbot/controllers/{IndexController.php => WebhookController.php} (100%) create mode 100644 Magento1/app/design/adminhtml/default/default/layout/werules_chatbot.xml create mode 100644 Magento1/js/werules/chatbot/chatbot.js create mode 100644 Magento1/skin/adminhtml/base/default/css/werules_chatbot/chatbot.css create mode 100644 Magento1/skin/frontend/base/default/images/werules_chatbot/messenger-icon.png diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/MessengerController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/CustomerController.php similarity index 94% rename from Magento1/app/code/community/Werules/Chatbot/controllers/MessengerController.php rename to Magento1/app/code/community/Werules/Chatbot/controllers/CustomerController.php index 3df6854..11eb4c1 100644 --- a/Magento1/app/code/community/Werules/Chatbot/controllers/MessengerController.php +++ b/Magento1/app/code/community/Werules/Chatbot/controllers/CustomerController.php @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -class Werules_Chatbot_IndexController extends Mage_Core_Controller_Front_Action{ +class Werules_Chatbot_CustomerController extends Mage_Core_Controller_Front_Action{ public function IndexAction() { $this->loadLayout(); diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/TelegramController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/TelegramController.php deleted file mode 100644 index 3df6854..0000000 --- a/Magento1/app/code/community/Werules/Chatbot/controllers/TelegramController.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -class Werules_Chatbot_IndexController extends Mage_Core_Controller_Front_Action{ - public function IndexAction() { - - $this->loadLayout(); - $this->getLayout()->getBlock("head")->setTitle($this->__("Titlename")); - $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs"); - $breadcrumbs->addCrumb("home", array( - "label" => $this->__("Home Page"), - "title" => $this->__("Home Page"), - "link" => Mage::getBaseUrl() - )); - - $breadcrumbs->addCrumb("titlename", array( - "label" => $this->__("Titlename"), - "title" => $this->__("Titlename") - )); - - $this->renderLayout(); - - } -} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/IndexController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/WebhookController.php similarity index 100% rename from Magento1/app/code/community/Werules/Chatbot/controllers/IndexController.php rename to Magento1/app/code/community/Werules/Chatbot/controllers/WebhookController.php diff --git a/Magento1/app/design/adminhtml/default/default/layout/werules_chatbot.xml b/Magento1/app/design/adminhtml/default/default/layout/werules_chatbot.xml new file mode 100644 index 0000000..ec25dd6 --- /dev/null +++ b/Magento1/app/design/adminhtml/default/default/layout/werules_chatbot.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml index c776ee6..bd022a0 100644 --- a/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml +++ b/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml @@ -1 +1 @@ -Chatbot_Demo_Page \ No newline at end of file +Index Page \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml index c776ee6..ef74fc6 100644 --- a/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml +++ b/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml @@ -1 +1 @@ -Chatbot_Demo_Page \ No newline at end of file +Messenger Page \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml index c776ee6..20d839c 100644 --- a/Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml +++ b/Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml @@ -1 +1 @@ -Chatbot_Demo_Page \ No newline at end of file +Settings Page \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml index c776ee6..6d6cbfa 100644 --- a/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml +++ b/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml @@ -1 +1 @@ -Chatbot_Demo_Page \ No newline at end of file +Telegram Page \ No newline at end of file diff --git a/Magento1/js/werules/chatbot/chatbot.js b/Magento1/js/werules/chatbot/chatbot.js new file mode 100644 index 0000000..d78765f --- /dev/null +++ b/Magento1/js/werules/chatbot/chatbot.js @@ -0,0 +1,50 @@ +// display/hide match mode +function werulesTogleMatchMode(element) +{ + //debugger; + var val = element.value; + var name = element.name; + name = name.substr(0, name.lastIndexOf("[")) + "[similarity]"; + var target = document.getElementsByName(name); + if (val === 0) + target[0].disabled = false; + else + target[0].disabled = true; +} + +function werulesTogleEnable(element) +{ + //debugger; + // var val = element.value; + // var name = element.name; + // if (val == 0) + // { + // name = name.substr(0, name.lastIndexOf("[")) + "[similarity]"; + // var target = document.getElementsByName(name); + // target[0].disabled = false; + // } + // else + // { + // name = name.substr(0, name.lastIndexOf("[")) + "[similarity]"; + // var target = document.getElementsByName(name); + // target[0].disabled = true; + // } +} + +// display/hide reply mode +function werulesTogleReplyMode(element) +{ + //debugger; + var val = element.value; + var name = element.name; + name = name.substr(0, name.lastIndexOf("[")) + "[command_id]"; + var target = document.getElementsByName(name); + if (val === 0) + target[0].disabled = true; + else + { + //target[0].classList.remove("werules-disabled"); + //target[0].style = ""; + target[0].disabled = false; + } +} \ No newline at end of file diff --git a/Magento1/skin/adminhtml/base/default/css/werules_chatbot/chatbot.css b/Magento1/skin/adminhtml/base/default/css/werules_chatbot/chatbot.css new file mode 100644 index 0000000..2b3e611 --- /dev/null +++ b/Magento1/skin/adminhtml/base/default/css/werules_chatbot/chatbot.css @@ -0,0 +1,12 @@ +/*backend css*/ +.werules-disabled-input{ + pointer-events: none; + background-color: #ebebe4; + color: #545454; +} + +.werules-disabled-select{ + pointer-events: none; + background-color: #FFFFFF; + color: #808080; +} \ No newline at end of file diff --git a/Magento1/skin/frontend/base/default/images/werules_chatbot/messenger-icon.png b/Magento1/skin/frontend/base/default/images/werules_chatbot/messenger-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..611e6d4c85e649b7745b5c980085d5ad1c1b20b8 GIT binary patch literal 6248 zcmds5`p?*YR*@NElxT?2Jp)9=_mCyftsJ3E}WHdd#A zAMXt&v-Nft#Q5I9dU5?~5TMGbNPN%uGmHa*XdE<@6^wm;ZO^{-rc$AY_6kSGL!BB0 zRTL0Diy<5s%%aS~(6{-Yq#D0|MGu;XgfbT@D!^z~59Awhl~s^(+Nmsr>nD%t7g3Q|}9ptc=GN77v|te=au- zmL7a`;|kqPib;PW{^#>}6|vfIMIiEA+RXCq%cW_$|F%ktgj4xWCt4VcX!Wwpq*(5y zHDZsh?}%SBl4z9;s_LRMv{QXX5^Ztiidn3hNSI5_j^up}$lt8n>Xf28YiqyM)qNq6 zrB0swPS{&q;P8!JJ=f_fgr`BZPwf4j^xuWP!!ye6t#ge0s2E;j0fy>|Vm49!js z5`QWhq**;Ep~bhes=2r@N{REt4Skvrl~-yJkt-VUw4{{R@GdjSYt|VsL!MpkqNN!t zEOQyEFHp)o60ZEG{j}=OD>l1GyA7C%f<3P$+w*W02fT+u!Jc+BxBcwK5^dB8#XZ&( zTc)ypTh;3%lzOf5YH7-wme4oNdA_!^v{6ho5u~p5C6`M%%?8Kg=3!A05zM0;eBuvJ zJe@;)sQw_lKh@?4$gbBrUpQoHs8}iZ>c38ic;^Iog4ia%-5DZP9Ol3rj?9yjIN%Wu zGL40b`TVY*L#`Kgr4#+;%vnfgbukmmL#|ThZA><`wi2An{43U1AM8`imI#)qm|%;Z zS5dxO>{e7maW4HxG8=VHxl!Y=OT#!tcmRzFG@Tjh&GPcnAv(t!8rz=+hi`?m#UUy4 zzHa_oaqlE~+MpvCCL1YB^(dB2k3y%gOzJ{ns8X7nq->A~IWcu6T!&Q1;_T1kZwtO< zlSMB`l5MN1SZQsluE5gvkMM3m#O@5+%j?%qQ)d_CPE9A+*zGn@VV^g`pXiZm#p=r< zY-G)O%)fPe%Ob9Kv?4urX(DE=kTuuj1}eCu4-~tOK2;z^Z7~E2!@P?YL6aq+V^}tX z_{kTX`d8`_c=;Eqz~N_)-Si?lpwNXyfHq=qo2x_o38kR+sB4#kpCgwm=Pp%*vL~J^ z6XSEz{HLnaC1*%i(Z~X6AE@C(%f@xOJ5KOzy%*d&WwDViM9Q@gy1ohwLmlETs`|_d zGfJ>Fm#%;$jte%OAFDw2ewin z4D1cglp_3c@#-O8UAkW%K0v7=ge>7hXD_SRB7=p?Rb>g*N_<1pzrqh24KSO+cWFvZ zL(+sBHn>oqOI1Vq;*e9D;wbJWSs)RW5E{qI&ip>PIfEc8rdRKn1H;Px>Le&cQg_$imxRs^BBy(Yg*}gs%lOw9nBG_OU`% z5ci1D2j7;fW2YXz(o>2q)l=zqi=>66C1uR7MsvaHn^N+%pmHq5fh)O4z5Q5k9Fmsl zl>LCCv&uhY^L?~PP&l@hEY&0fMQG1W1GPqW~fLqvBb{POfqC^hfwxwpRZhkx?M zZx+=VTp;@1I_PURyJy)U+1P88Go2R>%GJ!t2PcpDb(EF^`<6{0#SPzNupIZE#lsA4 z9gnDkrE;mvuarO7<6VGl_NGIUd6ofkN7#6#Al##O#;g0B;k`N?t6p}JY4y-5#~iGO z^MDA$n0|rS`}mp88;-&-$fg`>VuysO*n%jBsH;u-{N;mEA%ojftbG6Z5${P(|B^+V zqu_f!35;@r)Lfj zn=*%{rHK;ijvPT!0Ii&&*)?@uX-yNM-;@hZ2kjY_D_Zoh&j&xJKN!;^(L-GAgMU=h zo(#Rim8zD!mp!1T7+6QJ!D)pzbNW-!FK$mKXQLa2MiL$VUEI*N&1F>!FvjaK>XO;6 z6*FQu`U0lp-}OXwF(^Ka?wlIGr6Bu)Z@c&J2gQdTfz9~t%57h>n27C%(8UW^Y4Ef? zi552cZQ0ARB0VEiBJJ$G>8nm6l;zG3>i&tvne77CEjH0bCYm#|J#OW>%pj(guaoh8 zn4N(TeuL`Mny6!~^S^t%*jpz7_^AAu*MJyllO~ZQu-4&;)ls)5y#CDL^0cXBAM>Zu z*;V~v>q*Spd(}Y^#f6*mJ>m}B2h_AojQKx=s6%JNa14v7uCe+rKepk&8Y%LpKF*Ai ze)D}T2{psh{0|SSSfN$f6_l1EFj}|C@+cNIb0?}LygS#bLu>%kaI8eRtS1BQR-cMe z{me}J_4>`I4vsG&L6{}`%U~HdoiUR)RNH=m}cV_MkNgEq>?7TB>Z(L%sBfPz!#8)`*f0 z)3N95@n6|(X@d-u9TyleOmr1^MX>@<<1$LN*GEutI4@P@{oA6KRp(QEty7AH2 zt(lyW2LzRkBtg<5LT4uOj*;(X`xZVIcuS{V(SN0|Kc*XXDGXx>*S_>~f3`=F{67Az zG`f&UPy{1ali53+DElx28zm+=ko$3fG0by7j{JMRV}GF8<1wvy5=G5^Wr7$g zlC(4K{L7pted{GTrxDH5dB0kDL&B5Y5g)VD=d!uZMr=)Xj)(o`Zk=~^&mCimL$ja0 zR7g{P9Qi*}a52+@-G7Pd)m_kNsi` z&gO>t=S`pH82KJea!7obCzl?aQJ_d!As-8iulrEqV3Ak6RUsI^DtOY!j0ikE?{K$6 zOwVsm&BZPxp2(Bwa(Rjqe%WZ6i{B`LR{0^sec-@^bpsu$m?N&DLC1Ag*9+pyI=s@e^FM zxr_>+bf@_-(}(!}!980`&NgpT2IcR!sOlQcApiM3#4IVeG9S30SH@PjV$v4(pss&E zL@*(x^UL7mV*zw?$J^wQ+cAVhWioazDFBg4v$vN9&X1n!`@)xfVK6mH5@OMu}6~bfx=u3e&a+J zoCYEmO-9=m1wMekK@p*m^Jog#FUSN&{)X!%JG&3lXhs&iiA5id;tTJ>wa`9{`&ek+ zdy;&TBYz2HjJ;Ik#frYC2xlFY_O^Mfe@Ed47@0)51Xr-t=p@^au(J0bV&}wAJW3JpZYx7R^$?*ri=f>kSS{nS026R4ZCiUoJfA5JekA4NbC}2{|bCIt13fZkmKQ-@z@R@ zXVLVI^I_dL!&2F9XV=Y=kUgc@lOKD;=seXgD&uXy(T_Mi_^TKZ4?l5dm3&qq4xQ}c zYs0aRIV+bxnX(WQ2-56%R=y8VScs(`SB>0ESX4{9P2S<{cYi=sVkvh~9EPRU6g`RN zE&u+tr!H>!b=pWtcZW|5B$kouEqAm~(2Sv3rWs+7MZK`FUN&CC7#@>YEJ3p210_IJ&PW(b#$4wj$UvbyI zQLR?Iszmf_3Qh@UdS3r$`q6n8p`%|FrwbRA{8HNy8PaJ`GlTpc!WhEO;bsc6c6Vv9 zLj{-AM#leFQ9FW*zG~I5Gj)Bxsxogye95wPa{jmIm#qdAj{7v$u{D9FMp|qjP2%Qs z)Phjm+iX)i&y+HbXVP+r(Ad%A5&@>fILfI|KBSu9o)nba`pLP{yS(#mvnCy5_yWEh zJ?3CMJ7!5;Ce2z`%jQMqc4{C`&khZnG*i*^>{w7jVbowRiTU)vH+fsf zRICK7-Sa7 zMA1z?&;Rzmcb5d28T|4k+{z#}_C7-|jg$}d1vJR%UHhl!UQh2e1?rkPwGK)V!`-52 z*QKe0D{BplSwV5l^>TE_J5C&0(e=Os#kqhnjrU&g!xObSSr5Ri_9WMesh0R)v+vSQ8|w@*??g zUi5V?>qCdpw(vrB1m0^9{$%(iimNRPrGNioc9@`CD+9hC7@*^4XFw= zt_@V|(y;x6=E9@Qfm?FPbVWdA<0nMP>*SMU9YF@sQ`>Psq{-Z>iKlCByt+33Ew=*Q8x1==S z&s?c(@Fdb7Ov%|RhGK>(W^|&HhGbBQ3c2^DYr_+Mjl@2(|0;?SQ)8dNRM@UHZlFJO zB@-2${fSWg6x4&;Q7!35CsInLvLwoD0beX|bs`X9%n4RV<0V3S+8;QhUJveG^_oLn z`z17v=rI?BDUJp{bs*l#YS`L1RoR0!_NP*ZLM^c#DQR8NOIs zY|TQ<9cY=?j#PrFTQIjT6Q|XwWu?oX58B071;Og}I_QEwi zk-WNv`nP#eiXg)_ylS5NaO5KjGV2S%_F@a12kb0xq&Syd8ST3e>%`rt3em5PuKSJ}8F_4qfu0~iml6esK;BTZbGNk9F)bqaGm#9;2Df1i}d zT0i2wKP0h+%A+IW^yXZBn=@8vbUfRMR4DFkZPGON$qQZa)hWS{ZIBsFHUG4)%*pgs z(mIKXK4k=-$Cv)nEPWqYnf3GQGqoJ*M|@wD0V@w2sXNdz80f|$*m`6)3lmCT^5rUI zXyWrItc?$ruFt*lap&TfGjH5HI}+FbSVUuSByZ611Pa|uM)5!UvHQ#4cQ(W$(pa#B z7XfZ5EC%QBYUs$l-su?B@%I+aM$k6Zx{Tqf;4;C?a@q*4yL#@5W)HX5y6x^$kxK-w zFTGviln_d7513EYh>z3#U23X&Bfp{Yb^NX0{8N8OWH%<8eTONj1qI+{_Y30iJ`~AC z9nD!93mef%kJefoIve==Fu^cGJoQ3&A0E=ouzz5wU^J;TDI}9DbZ%U;vQ%Bm_vVIX z;@h_B`=&a^3#<&wR1eROuS=EY+Ky+uD;`TRuFV%hlKkJMucY*aGYSRlzZYB1bbh~( zD7G$o+!}PXl~iWZu6VH(HY4_GQu3GHwJ8kCF7zaosko0W8XEemW6grY?KzVp`HTkL zAF%a{LS*wNd+8MaZ5ZLFfOJz^9GiG|k*UXGB#_?Xc=;I~CaVdz8%r<>p(XsE#Sh9_ zMNmLFFv#hIWjYzLi?tJtA%w^wa=G0c6Q7ac(TJzvkR5~`lr11$wmPC$MWAufa)WsL zYbGR|1ZW)8pR`07jN3!Ehy>j2&Xk-l+?+b2F#?P5eF+hQB6)}OtLud zUHyXoEgEMla7{tnSVM0SVqW=Bz5a~8QT~a!s=dh2SWKva2tpNB2tjunUHk8dMC{-E PaUl&AUFFY;sL=lblMGrF literal 0 HcmV?d00001 From cffb3737b1f32415a8c1f09b46666925f35037c3 Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 03:06:33 -0200 Subject: [PATCH 08/25] remove line break --- Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv b/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv index cb0b2ed..c30a7e0 100644 --- a/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv +++ b/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv @@ -1 +1 @@ -"Cancel","Cancelar" +"Cancel","Cancelar" \ No newline at end of file From 3a12f299fed41b3cb302f9c35dc2665efa2c0e7c Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 13:23:08 -0200 Subject: [PATCH 09/25] tabing --- .../community/Werules/Chatbot/etc/config.xml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/config.xml b/Magento1/app/code/community/Werules/Chatbot/etc/config.xml index 90f0b07..268c155 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/config.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/config.xml @@ -38,25 +38,25 @@ - - standard - - Werules_Chatbot - chatbot - - + + standard + + Werules_Chatbot + chatbot + + - - Werules_Chatbot_Helper - + + Werules_Chatbot_Helper + - - Werules_Chatbot_Block - + + Werules_Chatbot_Block + From 98f605e3fbc57893dbe7ffebd04268aca70dfcd9 Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 13:57:01 -0200 Subject: [PATCH 10/25] adding files from module creator --- .../community/Werules/Chatbot/Helper/Data.php | 20 +- .../Werules/Chatbot/Model/Chatbotapi.php | 78 ++- .../Werules/Chatbot/Model/Chatbotuser.php | 78 ++- .../Werules/Chatbot/Model/Message.php | 78 ++- .../Chatbot/Model/Mysql4/Chatbotapi.php | 28 - .../Model/Mysql4/Chatbotapi/Collection.php | 27 - .../Chatbot/Model/Mysql4/Chatbotuser.php | 28 - .../Model/Mysql4/Chatbotuser/Collection.php | 27 - .../Werules/Chatbot/Model/Mysql4/Message.php | 28 - .../Model/Mysql4/Message/Collection.php | 27 - .../Chatbot/Model/Resource/Chatbotapi.php | 132 +++++ .../Model/Resource/Chatbotapi/Collection.php | 134 +++++ .../Chatbot/Model/Resource/Chatbotuser.php | 132 +++++ .../Model/Resource/Chatbotuser/Collection.php | 134 +++++ .../Chatbot/Model/Resource/Message.php | 132 +++++ .../Model/Resource/Message/Collection.php | 134 +++++ .../Werules/Chatbot/etc/adminhtml.xml | 75 ++- .../community/Werules/Chatbot/etc/config.xml | 120 +++-- .../chatbot_setup/mysql4-install-1.0.0.php | 86 --- .../werules_chatbot_setup/install-1.0.0.php | 510 ++++++++++++++++++ .../default/layout/werules_chatbot.xml | 95 ++++ Magento1/app/etc/modules/Werules_Chatbot.xml | 3 + Magento1/app/locale/en_US/Werules_Chatbot.csv | 122 +++++ 23 files changed, 1907 insertions(+), 321 deletions(-) delete mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi.php delete mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi/Collection.php delete mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser.php delete mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser/Collection.php delete mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message.php delete mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message/Collection.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi/Collection.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser/Collection.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message/Collection.php delete mode 100644 Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/sql/werules_chatbot_setup/install-1.0.0.php diff --git a/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php b/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php index ccfa037..e4ae5c8 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php +++ b/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php @@ -21,5 +21,23 @@ class Werules_Chatbot_Helper_Data extends Mage_Core_Helper_Abstract { - + /** + * convert array to options + * + * @access public + * @param $options + * @return array + * @author Ultimate Module Creator + */ + public function convertOptions($options) + { + $converted = array(); + foreach ($options as $option) { + if (isset($option['value']) && !is_array($option['value']) && + isset($option['label']) && !is_array($option['label'])) { + $converted[$option['value']] = $option['label']; + } + } + return $converted; + } } \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php index 63ec50c..d1fd6b4 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php @@ -21,10 +21,82 @@ class Werules_Chatbot_Model_Chatbotapi extends Mage_Core_Model_Abstract { - protected function _construct(){ + /** + * Entity code. + * Can be used as part of method name for entity processing + */ + const ENTITY = 'werules_chatbot_chatbotapi'; + const CACHE_TAG = 'werules_chatbot_chatbotapi'; - $this->_init("chatbot/chatbotapi"); + /** + * Prefix of model events names + * + * @var string + */ + protected $_eventPrefix = 'werules_chatbot_chatbotapi'; + /** + * Parameter name in event + * + * @var string + */ + protected $_eventObject = 'chatbotapi'; + + /** + * constructor + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function _construct() + { + parent::_construct(); + $this->_init('werules_chatbot/chatbotapi'); + } + + /** + * before save chatbotapi + * + * @access protected + * @return Werules_Chatbot_Model_Chatbotapi + * @author Ultimate Module Creator + */ + protected function _beforeSave() + { + parent::_beforeSave(); + $now = Mage::getSingleton('core/date')->gmtDate(); + if ($this->isObjectNew()) { + $this->setCreatedAt($now); + } + $this->setUpdatedAt($now); + return $this; } -} \ No newline at end of file + /** + * save chatbotapi relation + * + * @access public + * @return Werules_Chatbot_Model_Chatbotapi + * @author Ultimate Module Creator + */ + protected function _afterSave() + { + return parent::_afterSave(); + } + + /** + * get default values + * + * @access public + * @return array + * @author Ultimate Module Creator + */ + public function getDefaultValues() + { + $values = array(); + $values['status'] = 1; + return $values; + } + +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php index 88fe3bd..b9c5a8e 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php @@ -21,10 +21,82 @@ class Werules_Chatbot_Model_Chatbotuser extends Mage_Core_Model_Abstract { - protected function _construct(){ + /** + * Entity code. + * Can be used as part of method name for entity processing + */ + const ENTITY = 'werules_chatbot_chatbotuser'; + const CACHE_TAG = 'werules_chatbot_chatbotuser'; - $this->_init("chatbot/chatbotuser"); + /** + * Prefix of model events names + * + * @var string + */ + protected $_eventPrefix = 'werules_chatbot_chatbotuser'; + /** + * Parameter name in event + * + * @var string + */ + protected $_eventObject = 'chatbotuser'; + + /** + * constructor + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function _construct() + { + parent::_construct(); + $this->_init('werules_chatbot/chatbotuser'); + } + + /** + * before save chatbotuser + * + * @access protected + * @return Werules_Chatbot_Model_Chatbotuser + * @author Ultimate Module Creator + */ + protected function _beforeSave() + { + parent::_beforeSave(); + $now = Mage::getSingleton('core/date')->gmtDate(); + if ($this->isObjectNew()) { + $this->setCreatedAt($now); + } + $this->setUpdatedAt($now); + return $this; } -} \ No newline at end of file + /** + * save chatbotuser relation + * + * @access public + * @return Werules_Chatbot_Model_Chatbotuser + * @author Ultimate Module Creator + */ + protected function _afterSave() + { + return parent::_afterSave(); + } + + /** + * get default values + * + * @access public + * @return array + * @author Ultimate Module Creator + */ + public function getDefaultValues() + { + $values = array(); + $values['status'] = 1; + return $values; + } + +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Message.php b/Magento1/app/code/community/Werules/Chatbot/Model/Message.php index 1dbe478..c1815cd 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Message.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Message.php @@ -21,10 +21,82 @@ class Werules_Chatbot_Model_Message extends Mage_Core_Model_Abstract { - protected function _construct(){ + /** + * Entity code. + * Can be used as part of method name for entity processing + */ + const ENTITY = 'werules_chatbot_message'; + const CACHE_TAG = 'werules_chatbot_message'; - $this->_init("chatbot/message"); + /** + * Prefix of model events names + * + * @var string + */ + protected $_eventPrefix = 'werules_chatbot_message'; + /** + * Parameter name in event + * + * @var string + */ + protected $_eventObject = 'message'; + + /** + * constructor + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function _construct() + { + parent::_construct(); + $this->_init('werules_chatbot/message'); + } + + /** + * before save message + * + * @access protected + * @return Werules_Chatbot_Model_Message + * @author Ultimate Module Creator + */ + protected function _beforeSave() + { + parent::_beforeSave(); + $now = Mage::getSingleton('core/date')->gmtDate(); + if ($this->isObjectNew()) { + $this->setCreatedAt($now); + } + $this->setUpdatedAt($now); + return $this; } -} \ No newline at end of file + /** + * save message relation + * + * @access public + * @return Werules_Chatbot_Model_Message + * @author Ultimate Module Creator + */ + protected function _afterSave() + { + return parent::_afterSave(); + } + + /** + * get default values + * + * @access public + * @return array + * @author Ultimate Module Creator + */ + public function getDefaultValues() + { + $values = array(); + $values['status'] = 1; + return $values; + } + +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi.php deleted file mode 100644 index 0dce816..0000000 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -class Werules_Chatbot_Model_Mysql4_Chatbotapi extends Mage_Core_Model_Mysql4_Abstract -{ - protected function _construct() - { - $this->_init("chatbot/chatbotapi", "chatbotapi_id"); - } -} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi/Collection.php deleted file mode 100644 index a7c05ed..0000000 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotapi/Collection.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -class Werules_Chatbot_Model_Mysql4_Chatbotapi_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract -{ - public function _construct(){ - $this->_init("chatbot/chatbotapi"); - } -} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser.php deleted file mode 100644 index faeb33e..0000000 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -class Werules_Chatbot_Model_Mysql4_Chatbotuser extends Mage_Core_Model_Mysql4_Abstract -{ - protected function _construct() - { - $this->_init("chatbot/chatbotuser", "chatbotuser_id"); - } -} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser/Collection.php deleted file mode 100644 index 9b27637..0000000 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Chatbotuser/Collection.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -class Werules_Chatbot_Model_Mysql4_Chatbotuser_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract -{ - public function _construct(){ - $this->_init("chatbot/chatbotuser"); - } -} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message.php deleted file mode 100644 index 5022a8a..0000000 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -class Werules_Chatbot_Model_Mysql4_Message extends Mage_Core_Model_Mysql4_Abstract -{ - protected function _construct() - { - $this->_init("chatbot/message", "message_id"); - } -} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message/Collection.php deleted file mode 100644 index ed344d5..0000000 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Mysql4/Message/Collection.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -class Werules_Chatbot_Model_Mysql4_Message_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract -{ - public function _construct(){ - $this->_init("chatbot/message"); - } -} \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi.php new file mode 100644 index 0000000..bef30b2 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi.php @@ -0,0 +1,132 @@ +. + */ + +class Werules_Chatbot_Model_Resource_Chatbotapi extends Mage_Core_Model_Resource_Db_Abstract +{ + + /** + * constructor + * + * @access public + * @author Ultimate Module Creator + */ + public function _construct() + { + $this->_init('werules_chatbot/chatbotapi', 'entity_id'); + } + + /** + * Get store ids to which specified item is assigned + * + * @access public + * @param int $chatbotapiId + * @return array + * @author Ultimate Module Creator + */ + public function lookupStoreIds($chatbotapiId) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getTable('werules_chatbot/chatbotapi_store'), 'store_id') + ->where('chatbotapi_id = ?', (int)$chatbotapiId); + return $adapter->fetchCol($select); + } + + /** + * Perform operations after object load + * + * @access public + * @param Mage_Core_Model_Abstract $object + * @return Werules_Chatbot_Model_Resource_Chatbotapi + * @author Ultimate Module Creator + */ + protected function _afterLoad(Mage_Core_Model_Abstract $object) + { + if ($object->getId()) { + $stores = $this->lookupStoreIds($object->getId()); + $object->setData('store_id', $stores); + } + return parent::_afterLoad($object); + } + + /** + * Retrieve select object for load object data + * + * @param string $field + * @param mixed $value + * @param Werules_Chatbot_Model_Chatbotapi $object + * @return Zend_Db_Select + */ + protected function _getLoadSelect($field, $value, $object) + { + $select = parent::_getLoadSelect($field, $value, $object); + if ($object->getStoreId()) { + $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId()); + $select->join( + array('chatbot_chatbotapi_store' => $this->getTable('werules_chatbot/chatbotapi_store')), + $this->getMainTable() . '.entity_id = chatbot_chatbotapi_store.chatbotapi_id', + array() + ) + ->where('chatbot_chatbotapi_store.store_id IN (?)', $storeIds) + ->order('chatbot_chatbotapi_store.store_id DESC') + ->limit(1); + } + return $select; + } + + /** + * Assign chatbotapi to store views + * + * @access protected + * @param Mage_Core_Model_Abstract $object + * @return Werules_Chatbot_Model_Resource_Chatbotapi + * @author Ultimate Module Creator + */ + protected function _afterSave(Mage_Core_Model_Abstract $object) + { + $oldStores = $this->lookupStoreIds($object->getId()); + $newStores = (array)$object->getStores(); + if (empty($newStores)) { + $newStores = (array)$object->getStoreId(); + } + $table = $this->getTable('werules_chatbot/chatbotapi_store'); + $insert = array_diff($newStores, $oldStores); + $delete = array_diff($oldStores, $newStores); + if ($delete) { + $where = array( + 'chatbotapi_id = ?' => (int) $object->getId(), + 'store_id IN (?)' => $delete + ); + $this->_getWriteAdapter()->delete($table, $where); + } + if ($insert) { + $data = array(); + foreach ($insert as $storeId) { + $data[] = array( + 'chatbotapi_id' => (int) $object->getId(), + 'store_id' => (int) $storeId + ); + } + $this->_getWriteAdapter()->insertMultiple($table, $data); + } + return parent::_afterSave($object); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi/Collection.php new file mode 100644 index 0000000..0418d7c --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi/Collection.php @@ -0,0 +1,134 @@ +. + */ + +class Werules_Chatbot_Model_Resource_Chatbotapi_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract +{ + protected $_joinedFields = array(); + + /** + * constructor + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + protected function _construct() + { + parent::_construct(); + $this->_init('werules_chatbot/chatbotapi'); + $this->_map['fields']['store'] = 'store_table.store_id'; + } + + /** + * Add filter by store + * + * @access public + * @param int|Mage_Core_Model_Store $store + * @param bool $withAdmin + * @return Werules_Chatbot_Model_Resource_Chatbotapi_Collection + * @author Ultimate Module Creator + */ + public function addStoreFilter($store, $withAdmin = true) + { + if (!isset($this->_joinedFields['store'])) { + if ($store instanceof Mage_Core_Model_Store) { + $store = array($store->getId()); + } + if (!is_array($store)) { + $store = array($store); + } + if ($withAdmin) { + $store[] = Mage_Core_Model_App::ADMIN_STORE_ID; + } + $this->addFilter('store', array('in' => $store), 'public'); + $this->_joinedFields['store'] = true; + } + return $this; + } + + /** + * Join store relation table if there is store filter + * + * @access protected + * @return Werules_Chatbot_Model_Resource_Chatbotapi_Collection + * @author Ultimate Module Creator + */ + protected function _renderFiltersBefore() + { + if ($this->getFilter('store')) { + $this->getSelect()->join( + array('store_table' => $this->getTable('werules_chatbot/chatbotapi_store')), + 'main_table.entity_id = store_table.chatbotapi_id', + array() + ) + ->group('main_table.entity_id'); + /* + * Allow analytic functions usage because of one field grouping + */ + $this->_useAnalyticFunction = true; + } + return parent::_renderFiltersBefore(); + } + + /** + * get chatbotapis as array + * + * @access protected + * @param string $valueField + * @param string $labelField + * @param array $additional + * @return array + * @author Ultimate Module Creator + */ + protected function _toOptionArray($valueField='entity_id', $labelField='chatbotapi_id', $additional=array()) + { + return parent::_toOptionArray($valueField, $labelField, $additional); + } + + /** + * get options hash + * + * @access protected + * @param string $valueField + * @param string $labelField + * @return array + * @author Ultimate Module Creator + */ + protected function _toOptionHash($valueField='entity_id', $labelField='chatbotapi_id') + { + return parent::_toOptionHash($valueField, $labelField); + } + + /** + * Get SQL for get record count. + * Extra GROUP BY strip added. + * + * @access public + * @return Varien_Db_Select + * @author Ultimate Module Creator + */ + public function getSelectCountSql() + { + $countSelect = parent::getSelectCountSql(); + $countSelect->reset(Zend_Db_Select::GROUP); + return $countSelect; + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser.php new file mode 100644 index 0000000..c9bcf38 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser.php @@ -0,0 +1,132 @@ +. + */ + +class Werules_Chatbot_Model_Resource_Chatbotuser extends Mage_Core_Model_Resource_Db_Abstract +{ + + /** + * constructor + * + * @access public + * @author Ultimate Module Creator + */ + public function _construct() + { + $this->_init('werules_chatbot/chatbotuser', 'entity_id'); + } + + /** + * Get store ids to which specified item is assigned + * + * @access public + * @param int $chatbotuserId + * @return array + * @author Ultimate Module Creator + */ + public function lookupStoreIds($chatbotuserId) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getTable('werules_chatbot/chatbotuser_store'), 'store_id') + ->where('chatbotuser_id = ?', (int)$chatbotuserId); + return $adapter->fetchCol($select); + } + + /** + * Perform operations after object load + * + * @access public + * @param Mage_Core_Model_Abstract $object + * @return Werules_Chatbot_Model_Resource_Chatbotuser + * @author Ultimate Module Creator + */ + protected function _afterLoad(Mage_Core_Model_Abstract $object) + { + if ($object->getId()) { + $stores = $this->lookupStoreIds($object->getId()); + $object->setData('store_id', $stores); + } + return parent::_afterLoad($object); + } + + /** + * Retrieve select object for load object data + * + * @param string $field + * @param mixed $value + * @param Werules_Chatbot_Model_Chatbotuser $object + * @return Zend_Db_Select + */ + protected function _getLoadSelect($field, $value, $object) + { + $select = parent::_getLoadSelect($field, $value, $object); + if ($object->getStoreId()) { + $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId()); + $select->join( + array('chatbot_chatbotuser_store' => $this->getTable('werules_chatbot/chatbotuser_store')), + $this->getMainTable() . '.entity_id = chatbot_chatbotuser_store.chatbotuser_id', + array() + ) + ->where('chatbot_chatbotuser_store.store_id IN (?)', $storeIds) + ->order('chatbot_chatbotuser_store.store_id DESC') + ->limit(1); + } + return $select; + } + + /** + * Assign chatbotuser to store views + * + * @access protected + * @param Mage_Core_Model_Abstract $object + * @return Werules_Chatbot_Model_Resource_Chatbotuser + * @author Ultimate Module Creator + */ + protected function _afterSave(Mage_Core_Model_Abstract $object) + { + $oldStores = $this->lookupStoreIds($object->getId()); + $newStores = (array)$object->getStores(); + if (empty($newStores)) { + $newStores = (array)$object->getStoreId(); + } + $table = $this->getTable('werules_chatbot/chatbotuser_store'); + $insert = array_diff($newStores, $oldStores); + $delete = array_diff($oldStores, $newStores); + if ($delete) { + $where = array( + 'chatbotuser_id = ?' => (int) $object->getId(), + 'store_id IN (?)' => $delete + ); + $this->_getWriteAdapter()->delete($table, $where); + } + if ($insert) { + $data = array(); + foreach ($insert as $storeId) { + $data[] = array( + 'chatbotuser_id' => (int) $object->getId(), + 'store_id' => (int) $storeId + ); + } + $this->_getWriteAdapter()->insertMultiple($table, $data); + } + return parent::_afterSave($object); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser/Collection.php new file mode 100644 index 0000000..afcf085 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser/Collection.php @@ -0,0 +1,134 @@ +. + */ + +class Werules_Chatbot_Model_Resource_Chatbotuser_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract +{ + protected $_joinedFields = array(); + + /** + * constructor + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + protected function _construct() + { + parent::_construct(); + $this->_init('werules_chatbot/chatbotuser'); + $this->_map['fields']['store'] = 'store_table.store_id'; + } + + /** + * Add filter by store + * + * @access public + * @param int|Mage_Core_Model_Store $store + * @param bool $withAdmin + * @return Werules_Chatbot_Model_Resource_Chatbotuser_Collection + * @author Ultimate Module Creator + */ + public function addStoreFilter($store, $withAdmin = true) + { + if (!isset($this->_joinedFields['store'])) { + if ($store instanceof Mage_Core_Model_Store) { + $store = array($store->getId()); + } + if (!is_array($store)) { + $store = array($store); + } + if ($withAdmin) { + $store[] = Mage_Core_Model_App::ADMIN_STORE_ID; + } + $this->addFilter('store', array('in' => $store), 'public'); + $this->_joinedFields['store'] = true; + } + return $this; + } + + /** + * Join store relation table if there is store filter + * + * @access protected + * @return Werules_Chatbot_Model_Resource_Chatbotuser_Collection + * @author Ultimate Module Creator + */ + protected function _renderFiltersBefore() + { + if ($this->getFilter('store')) { + $this->getSelect()->join( + array('store_table' => $this->getTable('werules_chatbot/chatbotuser_store')), + 'main_table.entity_id = store_table.chatbotuser_id', + array() + ) + ->group('main_table.entity_id'); + /* + * Allow analytic functions usage because of one field grouping + */ + $this->_useAnalyticFunction = true; + } + return parent::_renderFiltersBefore(); + } + + /** + * get chatbotusers as array + * + * @access protected + * @param string $valueField + * @param string $labelField + * @param array $additional + * @return array + * @author Ultimate Module Creator + */ + protected function _toOptionArray($valueField='entity_id', $labelField='chatbotuser_id', $additional=array()) + { + return parent::_toOptionArray($valueField, $labelField, $additional); + } + + /** + * get options hash + * + * @access protected + * @param string $valueField + * @param string $labelField + * @return array + * @author Ultimate Module Creator + */ + protected function _toOptionHash($valueField='entity_id', $labelField='chatbotuser_id') + { + return parent::_toOptionHash($valueField, $labelField); + } + + /** + * Get SQL for get record count. + * Extra GROUP BY strip added. + * + * @access public + * @return Varien_Db_Select + * @author Ultimate Module Creator + */ + public function getSelectCountSql() + { + $countSelect = parent::getSelectCountSql(); + $countSelect->reset(Zend_Db_Select::GROUP); + return $countSelect; + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message.php new file mode 100644 index 0000000..2b8294b --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message.php @@ -0,0 +1,132 @@ +. + */ + +class Werules_Chatbot_Model_Resource_Message extends Mage_Core_Model_Resource_Db_Abstract +{ + + /** + * constructor + * + * @access public + * @author Ultimate Module Creator + */ + public function _construct() + { + $this->_init('werules_chatbot/message', 'entity_id'); + } + + /** + * Get store ids to which specified item is assigned + * + * @access public + * @param int $messageId + * @return array + * @author Ultimate Module Creator + */ + public function lookupStoreIds($messageId) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getTable('werules_chatbot/message_store'), 'store_id') + ->where('message_id = ?', (int)$messageId); + return $adapter->fetchCol($select); + } + + /** + * Perform operations after object load + * + * @access public + * @param Mage_Core_Model_Abstract $object + * @return Werules_Chatbot_Model_Resource_Message + * @author Ultimate Module Creator + */ + protected function _afterLoad(Mage_Core_Model_Abstract $object) + { + if ($object->getId()) { + $stores = $this->lookupStoreIds($object->getId()); + $object->setData('store_id', $stores); + } + return parent::_afterLoad($object); + } + + /** + * Retrieve select object for load object data + * + * @param string $field + * @param mixed $value + * @param Werules_Chatbot_Model_Message $object + * @return Zend_Db_Select + */ + protected function _getLoadSelect($field, $value, $object) + { + $select = parent::_getLoadSelect($field, $value, $object); + if ($object->getStoreId()) { + $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId()); + $select->join( + array('chatbot_message_store' => $this->getTable('werules_chatbot/message_store')), + $this->getMainTable() . '.entity_id = chatbot_message_store.message_id', + array() + ) + ->where('chatbot_message_store.store_id IN (?)', $storeIds) + ->order('chatbot_message_store.store_id DESC') + ->limit(1); + } + return $select; + } + + /** + * Assign message to store views + * + * @access protected + * @param Mage_Core_Model_Abstract $object + * @return Werules_Chatbot_Model_Resource_Message + * @author Ultimate Module Creator + */ + protected function _afterSave(Mage_Core_Model_Abstract $object) + { + $oldStores = $this->lookupStoreIds($object->getId()); + $newStores = (array)$object->getStores(); + if (empty($newStores)) { + $newStores = (array)$object->getStoreId(); + } + $table = $this->getTable('werules_chatbot/message_store'); + $insert = array_diff($newStores, $oldStores); + $delete = array_diff($oldStores, $newStores); + if ($delete) { + $where = array( + 'message_id = ?' => (int) $object->getId(), + 'store_id IN (?)' => $delete + ); + $this->_getWriteAdapter()->delete($table, $where); + } + if ($insert) { + $data = array(); + foreach ($insert as $storeId) { + $data[] = array( + 'message_id' => (int) $object->getId(), + 'store_id' => (int) $storeId + ); + } + $this->_getWriteAdapter()->insertMultiple($table, $data); + } + return parent::_afterSave($object); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message/Collection.php new file mode 100644 index 0000000..2f2adf0 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message/Collection.php @@ -0,0 +1,134 @@ +. + */ + +class Werules_Chatbot_Model_Resource_Message_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract +{ + protected $_joinedFields = array(); + + /** + * constructor + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + protected function _construct() + { + parent::_construct(); + $this->_init('werules_chatbot/message'); + $this->_map['fields']['store'] = 'store_table.store_id'; + } + + /** + * Add filter by store + * + * @access public + * @param int|Mage_Core_Model_Store $store + * @param bool $withAdmin + * @return Werules_Chatbot_Model_Resource_Message_Collection + * @author Ultimate Module Creator + */ + public function addStoreFilter($store, $withAdmin = true) + { + if (!isset($this->_joinedFields['store'])) { + if ($store instanceof Mage_Core_Model_Store) { + $store = array($store->getId()); + } + if (!is_array($store)) { + $store = array($store); + } + if ($withAdmin) { + $store[] = Mage_Core_Model_App::ADMIN_STORE_ID; + } + $this->addFilter('store', array('in' => $store), 'public'); + $this->_joinedFields['store'] = true; + } + return $this; + } + + /** + * Join store relation table if there is store filter + * + * @access protected + * @return Werules_Chatbot_Model_Resource_Message_Collection + * @author Ultimate Module Creator + */ + protected function _renderFiltersBefore() + { + if ($this->getFilter('store')) { + $this->getSelect()->join( + array('store_table' => $this->getTable('werules_chatbot/message_store')), + 'main_table.entity_id = store_table.message_id', + array() + ) + ->group('main_table.entity_id'); + /* + * Allow analytic functions usage because of one field grouping + */ + $this->_useAnalyticFunction = true; + } + return parent::_renderFiltersBefore(); + } + + /** + * get messages as array + * + * @access protected + * @param string $valueField + * @param string $labelField + * @param array $additional + * @return array + * @author Ultimate Module Creator + */ + protected function _toOptionArray($valueField='entity_id', $labelField='message_id', $additional=array()) + { + return parent::_toOptionArray($valueField, $labelField, $additional); + } + + /** + * get options hash + * + * @access protected + * @param string $valueField + * @param string $labelField + * @return array + * @author Ultimate Module Creator + */ + protected function _toOptionHash($valueField='entity_id', $labelField='message_id') + { + return parent::_toOptionHash($valueField, $labelField); + } + + /** + * Get SQL for get record count. + * Extra GROUP BY strip added. + * + * @access public + * @return Varien_Db_Select + * @author Ultimate Module Creator + */ + public function getSelectCountSql() + { + $countSelect = parent::getSelectCountSql(); + $countSelect->reset(Zend_Db_Select::GROUP); + return $countSelect; + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml index d33da68..82c868c 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml @@ -8,24 +8,73 @@ - - General Settings - 0 - - - Messenger Settings - 1 - - - Danger Zone - 2 - + + Chatbot + + + + + + + Chatbot Settings + + + Message + 0 + + + ChatbotUser + 10 + + + ChatbotAPI + 20 + + + + + + + + - \ No newline at end of file + + + + + + + Chatbot Settings + 10 + + + Message + adminhtml/chatbot_message + 0 + + + ChatbotUser + adminhtml/chatbot_chatbotuser + 10 + + + ChatbotAPI + adminhtml/chatbot_chatbotapi + 20 + + + + + + + + + + diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/config.xml b/Magento1/app/code/community/Werules/Chatbot/etc/config.xml index 268c155..4750211 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/config.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/config.xml @@ -2,7 +2,7 @@ - 1.0.0 + 1.0.0 @@ -48,56 +48,53 @@ - - - Werules_Chatbot_Helper - - + + + + Werules_Chatbot + Werules_Chatbot_Model_Resource_Setup + + + - + Werules_Chatbot_Block - + + + + Werules_Chatbot_Helper + + - - Werules_Chatbot_Model - chatbot_mysql4 - - - Werules_Chatbot_Model_Mysql4 - - - werules_chatbot_message
-
- - werules_chatbot_chatbotuser
-
- - werules_chatbot_chatbotapi
-
-
-
+ + Werules_Chatbot_Model + werules_chatbot_resource + + + Werules_Chatbot_Model_Resource + + + werules_chatbot_message
+
+ + werules_chatbot_chatbotuser
+
+ + werules_chatbot_chatbotapi
+
+ + werules_chatbot_message_store
+
+ + werules_chatbot_chatbotuser_store
+
+ + werules_chatbot_chatbotapi_store
+
+
+
- - - - Werules_Chatbot - - - core_setup - - - - - core_write - - - - - core_read - - -
@@ -111,4 +108,33 @@ -
\ No newline at end of file + + + + + werules_chatbot.xml + + + + + + + + Werules_Chatbot.csv + + + + + + + + + + + Werules_Chatbot_Adminhtml + + + + + + diff --git a/Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php b/Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php deleted file mode 100644 index 88a832f..0000000 --- a/Magento1/app/code/community/Werules/Chatbot/sql/chatbot_setup/mysql4-install-1.0.0.php +++ /dev/null @@ -1,86 +0,0 @@ -. - */ - -$table = 'wr_chatbot'; -$installer = $this; -$installer->startSetup(); //db installation - -$installer->run(" - -- DROP TABLE IF EXISTS {$this->getTable($table)}; - CREATE TABLE {$this->getTable($table)} ( - `entity_id` int(11) unsigned NOT NULL auto_increment, - `created_at` timestamp NULL, - `updated_at` timestamp NULL, - `customer_id` int(11) NULL, - `session_id` varchar(150) NULL, - `quote_id` varchar(20) NULL, - `hash_key` varchar(150) NULL, - `is_admin` smallint(1) NOT NULL default '0', - `is_logged` smallint(1) NOT NULL default '0', - `enable_promotional_messages` smallint(1) NOT NULL default '1', - `enable_support` smallint(1) NOT NULL default '1', - `last_support_message_id` varchar(50) NULL, - `last_support_chat` varchar(20) NULL, - `enable_telegram_admin` smallint(1) NOT NULL default '1', - `enable_telegram` smallint(1) NOT NULL default '1', - `telegram_processing_request` smallint(1) NOT NULL default '0', - `telegram_chat_id` varchar(50) NULL, - `telegram_message_id` varchar(50) NULL, - `telegram_conv_state` int(10) NOT NULL default '0', - `telegram_support_reply_chat_id` varchar(50) NULL, - `telegram_fallback_qty` int(10) NOT NULL default '0', - `enable_facebook_admin` smallint(1) NOT NULL default '1', - `enable_facebook` smallint(1) NOT NULL default '1', - `facebook_processing_request` smallint(1) NOT NULL default '0', - `facebook_chat_id` varchar(50) NULL, - `facebook_message_id` varchar(50) NULL, - `facebook_conv_state` int(10) NOT NULL default '0', - `facebook_support_reply_chat_id` varchar(50) NULL, - `facebook_fallback_qty` int(10) NOT NULL default '0', - `enable_whatsapp_admin` smallint(1) NOT NULL default '1', - `enable_whatsapp` smallint(1) NOT NULL default '1', - `whatsapp_processing_request` smallint(1) NOT NULL default '0', - `whatsapp_chat_id` varchar(50) NULL, - `whatsapp_message_id` varchar(50) NULL, - `whatsapp_conv_state` int(10) NOT NULL default '0', - `whatsapp_support_reply_chat_id` varchar(50) NULL, - `whatsapp_fallback_qty` int(10) NOT NULL default '0', - `enable_wechat_admin` smallint(1) NOT NULL default '1', - `enable_wechat` smallint(1) NOT NULL default '1', - `wechat_processing_request` smallint(1) NOT NULL default '0', - `wechat_chat_id` varchar(50) NULL, - `wechat_message_id` varchar(50) NULL, - `wechat_conv_state` int(10) NOT NULL default '0', - `wechat_support_reply_chat_id` varchar(50) NULL, - `wechat_fallback_qty` int(10) NOT NULL default '0', - `enable_skype_admin` smallint(1) NOT NULL default '1', - `enable_skype` smallint(1) NOT NULL default '1', - `skype_processing_request` smallint(1) NOT NULL default '0', - `skype_chat_id` varchar(50) NULL, - `skype_message_id` varchar(50) NULL, - `skype_conv_state` int(10) NOT NULL default '0', - `skype_support_reply_chat_id` varchar(50) NULL, - `skype_fallback_qty` int(10) NOT NULL default '0', - PRIMARY KEY (entity_id) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - "); - -$installer->endSetup(); diff --git a/Magento1/app/code/community/Werules/Chatbot/sql/werules_chatbot_setup/install-1.0.0.php b/Magento1/app/code/community/Werules/Chatbot/sql/werules_chatbot_setup/install-1.0.0.php new file mode 100644 index 0000000..87c6e5e --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/sql/werules_chatbot_setup/install-1.0.0.php @@ -0,0 +1,510 @@ +. + */ + +$this->startSetup(); +$table = $this->getConnection() + ->newTable($this->getTable('werules_chatbot/message')) + ->addColumn( + 'entity_id', + Varien_Db_Ddl_Table::TYPE_INTEGER, + null, + array( + 'identity' => true, + 'nullable' => false, + 'primary' => true, + ), + 'Message ID' + ) + ->addColumn( + 'sender_id', + Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array( + 'nullable' => false, + ), + 'Sender ID' + ) + ->addColumn( + 'content', + Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array( + 'nullable' => false, + ), + 'Content' + ) + ->addColumn( + 'status', + Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array( + 'nullable' => false, + ), + 'Status' + ) + ->addColumn( + 'direction', + Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array( + 'nullable' => false, + ), + 'Direction' + ) + ->addColumn( + 'chat_message_id', + Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array( + 'nullable' => false, + ), + 'Chat Message ID' + ) + ->addColumn( + 'chatbot_type', + Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array( + 'nullable' => false, + ), + 'Chatbot Type' + ) + ->addColumn( + 'content_type', + Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array( + 'nullable' => false, + ), + 'Content Type' + ) + ->addColumn( + 'message_payload', + Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array( + 'nullable' => false, + ), + 'Message Payload' + ) + ->addColumn( + 'sent_at', + Varien_Db_Ddl_Table::TYPE_DATETIME, 255, + array( + 'nullable' => false, + ), + 'Sent At' + ) + ->addColumn( + 'current_command_details', + Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array( + 'nullable' => false, + ), + 'Current Command Details' + ) + ->addColumn( + 'message_id', + Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array( + 'nullable' => false, + ), + 'Message ID' + ) + ->addColumn( + 'status', + Varien_Db_Ddl_Table::TYPE_SMALLINT, null, + array(), + 'Enabled' + ) + ->addColumn( + 'updated_at', + Varien_Db_Ddl_Table::TYPE_TIMESTAMP, + null, + array(), + 'Message Modification Time' + ) + ->addColumn( + 'created_at', + Varien_Db_Ddl_Table::TYPE_TIMESTAMP, + null, + array(), + 'Message Creation Time' + ) + ->setComment('Message Table'); +$this->getConnection()->createTable($table); +$table = $this->getConnection() + ->newTable($this->getTable('werules_chatbot/chatbotuser')) + ->addColumn( + 'entity_id', + Varien_Db_Ddl_Table::TYPE_INTEGER, + null, + array( + 'identity' => true, + 'nullable' => false, + 'primary' => true, + ), + 'ChatbotUser ID' + ) + ->addColumn( + 'chatbotuser_id', + Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array( + 'nullable' => false, + ), + 'ChatbotUser ID' + ) + ->addColumn( + 'session_id', + Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array( + 'nullable' => false, + ), + 'Session ID' + ) + ->addColumn( + 'enable_promotional_messages', + Varien_Db_Ddl_Table::TYPE_SMALLINT, null, + array( + 'nullable' => false, + ), + 'Enable Promotional Messages' + ) + ->addColumn( + 'enable_support', + Varien_Db_Ddl_Table::TYPE_SMALLINT, null, + array( + 'nullable' => false, + ), + 'Enable Support' + ) + ->addColumn( + 'admin', + Varien_Db_Ddl_Table::TYPE_SMALLINT, null, + array( + 'nullable' => false, + ), + 'Is Admin?' + ) + ->addColumn( + 'status', + Varien_Db_Ddl_Table::TYPE_SMALLINT, null, + array(), + 'Enabled' + ) + ->addColumn( + 'updated_at', + Varien_Db_Ddl_Table::TYPE_TIMESTAMP, + null, + array(), + 'ChatbotUser Modification Time' + ) + ->addColumn( + 'created_at', + Varien_Db_Ddl_Table::TYPE_TIMESTAMP, + null, + array(), + 'ChatbotUser Creation Time' + ) + ->setComment('ChatbotUser Table'); +$this->getConnection()->createTable($table); +$table = $this->getConnection() + ->newTable($this->getTable('werules_chatbot/chatbotapi')) + ->addColumn( + 'entity_id', + Varien_Db_Ddl_Table::TYPE_INTEGER, + null, + array( + 'identity' => true, + 'nullable' => false, + 'primary' => true, + ), + 'ChatbotAPI ID' + ) + ->addColumn( + 'chatbotapi_id', + Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array( + 'nullable' => false, + ), + 'ChatbotAPI ID' + ) + ->addColumn( + 'hash_key', + Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array( + 'nullable' => false, + ), + 'Hash Key' + ) + ->addColumn( + 'logged', + Varien_Db_Ddl_Table::TYPE_SMALLINT, null, + array( + 'nullable' => false, + ), + 'Logged?' + ) + ->addColumn( + 'enabled', + Varien_Db_Ddl_Table::TYPE_SMALLINT, null, + array( + 'nullable' => false, + ), + 'Enabled?' + ) + ->addColumn( + 'chatbot_type', + Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array( + 'nullable' => false, + ), + 'Chatbot Type' + ) + ->addColumn( + 'chat_id', + Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array( + 'nullable' => false, + ), + 'Chat ID' + ) + ->addColumn( + 'conversation_state', + Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array( + 'nullable' => false, + ), + 'Conversation State' + ) + ->addColumn( + 'fallback_qty', + Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array( + 'nullable' => false, + ), + 'Fallback Quantity' + ) + ->addColumn( + 'chatbotuser_id', + Varien_Db_Ddl_Table::TYPE_INTEGER, null, + array( + 'nullable' => false, + ), + 'Chatbotuser ID' + ) + ->addColumn( + 'last_command_details', + Varien_Db_Ddl_Table::TYPE_TEXT, 255, + array( + 'nullable' => false, + ), + 'Last Command Details' + ) + ->addColumn( + 'status', + Varien_Db_Ddl_Table::TYPE_SMALLINT, null, + array(), + 'Enabled' + ) + ->addColumn( + 'updated_at', + Varien_Db_Ddl_Table::TYPE_TIMESTAMP, + null, + array(), + 'ChatbotAPI Modification Time' + ) + ->addColumn( + 'created_at', + Varien_Db_Ddl_Table::TYPE_TIMESTAMP, + null, + array(), + 'ChatbotAPI Creation Time' + ) + ->setComment('ChatbotAPI Table'); +$this->getConnection()->createTable($table); +$table = $this->getConnection() + ->newTable($this->getTable('werules_chatbot/message_store')) + ->addColumn( + 'message_id', + Varien_Db_Ddl_Table::TYPE_SMALLINT, + null, + array( + 'nullable' => false, + 'primary' => true, + ), + 'Message ID' + ) + ->addColumn( + 'store_id', + Varien_Db_Ddl_Table::TYPE_SMALLINT, + null, + array( + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), + 'Store ID' + ) + ->addIndex( + $this->getIdxName( + 'werules_chatbot/message_store', + array('store_id') + ), + array('store_id') + ) + ->addForeignKey( + $this->getFkName( + 'werules_chatbot/message_store', + 'message_id', + 'werules_chatbot/message', + 'entity_id' + ), + 'message_id', + $this->getTable('werules_chatbot/message'), + 'entity_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->addForeignKey( + $this->getFkName( + 'werules_chatbot/message_store', + 'store_id', + 'core/store', + 'store_id' + ), + 'store_id', + $this->getTable('core/store'), + 'store_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->setComment('Messages To Store Linkage Table'); +$this->getConnection()->createTable($table); +$table = $this->getConnection() + ->newTable($this->getTable('werules_chatbot/chatbotuser_store')) + ->addColumn( + 'chatbotuser_id', + Varien_Db_Ddl_Table::TYPE_SMALLINT, + null, + array( + 'nullable' => false, + 'primary' => true, + ), + 'ChatbotUser ID' + ) + ->addColumn( + 'store_id', + Varien_Db_Ddl_Table::TYPE_SMALLINT, + null, + array( + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), + 'Store ID' + ) + ->addIndex( + $this->getIdxName( + 'werules_chatbot/chatbotuser_store', + array('store_id') + ), + array('store_id') + ) + ->addForeignKey( + $this->getFkName( + 'werules_chatbot/chatbotuser_store', + 'chatbotuser_id', + 'werules_chatbot/chatbotuser', + 'entity_id' + ), + 'chatbotuser_id', + $this->getTable('werules_chatbot/chatbotuser'), + 'entity_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->addForeignKey( + $this->getFkName( + 'werules_chatbot/chatbotuser_store', + 'store_id', + 'core/store', + 'store_id' + ), + 'store_id', + $this->getTable('core/store'), + 'store_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->setComment('ChatbotUsers To Store Linkage Table'); +$this->getConnection()->createTable($table); +$table = $this->getConnection() + ->newTable($this->getTable('werules_chatbot/chatbotapi_store')) + ->addColumn( + 'chatbotapi_id', + Varien_Db_Ddl_Table::TYPE_SMALLINT, + null, + array( + 'nullable' => false, + 'primary' => true, + ), + 'ChatbotAPI ID' + ) + ->addColumn( + 'store_id', + Varien_Db_Ddl_Table::TYPE_SMALLINT, + null, + array( + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), + 'Store ID' + ) + ->addIndex( + $this->getIdxName( + 'werules_chatbot/chatbotapi_store', + array('store_id') + ), + array('store_id') + ) + ->addForeignKey( + $this->getFkName( + 'werules_chatbot/chatbotapi_store', + 'chatbotapi_id', + 'werules_chatbot/chatbotapi', + 'entity_id' + ), + 'chatbotapi_id', + $this->getTable('werules_chatbot/chatbotapi'), + 'entity_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->addForeignKey( + $this->getFkName( + 'werules_chatbot/chatbotapi_store', + 'store_id', + 'core/store', + 'store_id' + ), + 'store_id', + $this->getTable('core/store'), + 'store_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->setComment('ChatbotAPIs To Store Linkage Table'); +$this->getConnection()->createTable($table); +$this->endSetup(); diff --git a/Magento1/app/design/adminhtml/default/default/layout/werules_chatbot.xml b/Magento1/app/design/adminhtml/default/default/layout/werules_chatbot.xml index ec25dd6..2af9118 100644 --- a/Magento1/app/design/adminhtml/default/default/layout/werules_chatbot.xml +++ b/Magento1/app/design/adminhtml/default/default/layout/werules_chatbot.xml @@ -1,5 +1,100 @@ + + + + system/config/werules_chatbot/message + + + + + + + + + + + + + + + + + + system/config/werules_chatbot/message + + + + + + + + + + + + + + system/config/werules_chatbot/chatbotuser + + + + + + + + + + + + + + + + + + system/config/werules_chatbot/chatbotuser + + + + + + + + + + + + + + system/config/werules_chatbot/chatbotapi + + + + + + + + + + + + + + + + + + system/config/werules_chatbot/chatbotapi + + + + + + + + + diff --git a/Magento1/app/etc/modules/Werules_Chatbot.xml b/Magento1/app/etc/modules/Werules_Chatbot.xml index debcd90..2680f6e 100644 --- a/Magento1/app/etc/modules/Werules_Chatbot.xml +++ b/Magento1/app/etc/modules/Werules_Chatbot.xml @@ -5,6 +5,9 @@ true community 1.0.0 + + + \ No newline at end of file diff --git a/Magento1/app/locale/en_US/Werules_Chatbot.csv b/Magento1/app/locale/en_US/Werules_Chatbot.csv index b923d3b..a08fcc1 100644 --- a/Magento1/app/locale/en_US/Werules_Chatbot.csv +++ b/Magento1/app/locale/en_US/Werules_Chatbot.csv @@ -81,3 +81,125 @@ "To list more send '%1'.","To list more send '%1'." "No more items to list.","No more items to list." "This category doesn't seems to exist. Please try again.","This category doesn't seems to exist. Please try again." +"Action","Action" +"Add ChatbotAPI","Add ChatbotAPI" +"Add ChatbotUser","Add ChatbotUser" +"Add Message","Add Message" +"An error occurred while updating the chatbotapis.","An error occurred while updating the chatbotapis." +"An error occurred while updating the chatbotusers.","An error occurred while updating the chatbotusers." +"An error occurred while updating the messages.","An error occurred while updating the messages." +"Are you sure?","Are you sure?" +"CSV","CSV" +"Change Enable Promotional Messages","Change Enable Promotional Messages" +"Change Enable Support","Change Enable Support" +"Change Enabled?","Change Enabled?" +"Change Is Admin?","Change Is Admin?" +"Change Logged?","Change Logged?" +"Change status","Change status" +"Chat ID","Chat ID" +"Chat Message ID","Chat Message ID" +"Chatbot Type","Chatbot Type" +"ChatbotAPI ID","ChatbotAPI ID" +"ChatbotAPI was saved","ChatbotAPI was saved" +"ChatbotAPI was successfully deleted.","ChatbotAPI was successfully deleted." +"ChatbotAPI was successfully saved","ChatbotAPI was successfully saved" +"ChatbotAPI","ChatbotAPI" +"ChatbotAPIs","ChatbotAPIs" +"ChatbotUser ID","ChatbotUser ID" +"ChatbotUser was saved","ChatbotUser was saved" +"ChatbotUser was successfully deleted.","ChatbotUser was successfully deleted." +"ChatbotUser was successfully saved","ChatbotUser was successfully saved" +"ChatbotUser","ChatbotUser" +"ChatbotUsers","ChatbotUsers" +"Chatbotuser ID","Chatbotuser ID" +"Content Type","Content Type" +"Content","Content" +"Conversation State","Conversation State" +"Could not find chatbotapi to delete.","Could not find chatbotapi to delete." +"Could not find chatbotuser to delete.","Could not find chatbotuser to delete." +"Could not find message to delete.","Could not find message to delete." +"Created at","Created at" +"Current Command Details","Current Command Details" +"Delete ChatbotAPI","Delete ChatbotAPI" +"Delete ChatbotUser","Delete ChatbotUser" +"Delete Message","Delete Message" +"Delete","Delete" +"Direction","Direction" +"Disabled","Disabled" +"Edit ChatbotAPI '%s'","Edit ChatbotAPI '%s'" +"Edit ChatbotUser '%s'","Edit ChatbotUser '%s'" +"Edit Message '%s'","Edit Message '%s'" +"Edit","Edit" +"Enable Promotional Messages","Enable Promotional Messages" +"Enable Support","Enable Support" +"Enabled","Enabled" +"Enabled?","Enabled?" +"Error saving chatbotapi","Error saving chatbotapi" +"Error saving chatbotuser","Error saving chatbotuser" +"Error saving message","Error saving message" +"Excel","Excel" +"Fallback Quantity","Fallback Quantity" +"Hash Key","Hash Key" +"Home","Home" +"Id","Id" +"Is Admin?","Is Admin?" +"Last Command Details","Last Command Details" +"Logged?","Logged?" +"Message ID","Message ID" +"Message Payload","Message Payload" +"Message was saved","Message was saved" +"Message was successfully deleted.","Message was successfully deleted." +"Message was successfully saved","Message was successfully saved" +"Message","Message" +"Messages","Messages" +"No","No" +"None","None" +"Please select chatbotapis to delete.","Please select chatbotapis to delete." +"Please select chatbotapis.","Please select chatbotapis." +"Please select chatbotusers to delete.","Please select chatbotusers to delete." +"Please select chatbotusers.","Please select chatbotusers." +"Please select messages to delete.","Please select messages to delete." +"Please select messages.","Please select messages." +"Reset","Reset" +"Save And Continue Edit","Save And Continue Edit" +"Save ChatbotAPI","Save ChatbotAPI" +"Save ChatbotUser","Save ChatbotUser" +"Save Message","Save Message" +"Sender ID","Sender ID" +"Sent At","Sent At" +"Session ID","Session ID" +"Status","Status" +"Store views","Store views" +"The chatbotapis has been deleted.","The chatbotapis has been deleted." +"The chatbotusers has been deleted.","The chatbotusers has been deleted." +"The messages has been deleted.","The messages has been deleted." +"There was a problem saving the chatbotapi.","There was a problem saving the chatbotapi." +"There was a problem saving the chatbotuser.","There was a problem saving the chatbotuser." +"There was a problem saving the message.","There was a problem saving the message." +"There was an error deleting chatbotapi.","There was an error deleting chatbotapi." +"There was an error deleting chatbotapis.","There was an error deleting chatbotapis." +"There was an error deleting chatbotuser.","There was an error deleting chatbotuser." +"There was an error deleting chatbotusers.","There was an error deleting chatbotusers." +"There was an error deleting message.","There was an error deleting message." +"There was an error deleting messages.","There was an error deleting messages." +"There was an error updating chatbotapis.","There was an error updating chatbotapis." +"There was an error updating chatbotusers.","There was an error updating chatbotusers." +"There was an error updating messages.","There was an error updating messages." +"This chatbotapi no longer exists.","This chatbotapi no longer exists." +"This chatbotuser no longer exists.","This chatbotuser no longer exists." +"This message no longer exists.","This message no longer exists." +"Total of %d chatbotapis were successfully deleted.","Total of %d chatbotapis were successfully deleted." +"Total of %d chatbotapis were successfully updated.","Total of %d chatbotapis were successfully updated." +"Total of %d chatbotusers were successfully deleted.","Total of %d chatbotusers were successfully deleted." +"Total of %d chatbotusers were successfully updated.","Total of %d chatbotusers were successfully updated." +"Total of %d messages were successfully deleted.","Total of %d messages were successfully deleted." +"Total of %d messages were successfully updated.","Total of %d messages were successfully updated." +"Total of %d record(s) have been deleted.","Total of %d record(s) have been deleted." +"Total of %d record(s) have been updated.","Total of %d record(s) have been updated." +"Unable to find chatbotapi to save.","Unable to find chatbotapi to save." +"Unable to find chatbotuser to save.","Unable to find chatbotuser to save." +"Unable to find message to save.","Unable to find message to save." +"Updated at","Updated at" +"WYSIWYG Editor","WYSIWYG Editor" +"XML","XML" +"Yes","Yes" From c18d1b3200612461ba298bec65398a64dec83c40 Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 13:57:23 -0200 Subject: [PATCH 11/25] adding missing files from module creator --- .../Chatbot/Block/Adminhtml/Chatbotapi.php | 42 ++ .../Block/Adminhtml/Chatbotapi/Edit.php | 82 ++++ .../Block/Adminhtml/Chatbotapi/Edit/Form.php | 52 +++ .../Adminhtml/Chatbotapi/Edit/Tab/Form.php | 225 +++++++++ .../Adminhtml/Chatbotapi/Edit/Tab/Stores.php | 58 +++ .../Block/Adminhtml/Chatbotapi/Edit/Tabs.php | 87 ++++ .../Block/Adminhtml/Chatbotapi/Grid.php | 378 +++++++++++++++ .../Chatbot/Block/Adminhtml/Chatbotuser.php | 42 ++ .../Block/Adminhtml/Chatbotuser/Edit.php | 82 ++++ .../Block/Adminhtml/Chatbotuser/Edit/Form.php | 52 +++ .../Adminhtml/Chatbotuser/Edit/Tab/Form.php | 175 +++++++ .../Adminhtml/Chatbotuser/Edit/Tab/Stores.php | 58 +++ .../Block/Adminhtml/Chatbotuser/Edit/Tabs.php | 87 ++++ .../Block/Adminhtml/Chatbotuser/Grid.php | 357 ++++++++++++++ .../Chatbot/Block/Adminhtml/Message.php | 42 ++ .../Chatbot/Block/Adminhtml/Message/Edit.php | 82 ++++ .../Block/Adminhtml/Message/Edit/Form.php | 52 +++ .../Block/Adminhtml/Message/Edit/Tab/Form.php | 219 +++++++++ .../Adminhtml/Message/Edit/Tab/Stores.php | 58 +++ .../Block/Adminhtml/Message/Edit/Tabs.php | 87 ++++ .../Chatbot/Block/Adminhtml/Message/Grid.php | 339 ++++++++++++++ .../Chatbot/Controller/Adminhtml/Chatbot.php | 60 +++ .../Werules/Chatbot/Model/Resource/Setup.php | 26 ++ .../Chatbot/ChatbotapiController.php | 402 ++++++++++++++++ .../Chatbot/ChatbotuserController.php | 439 ++++++++++++++++++ .../Adminhtml/Chatbot/MessageController.php | 329 +++++++++++++ 26 files changed, 3912 insertions(+) create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Form.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Form.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Stores.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tabs.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Grid.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Form.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Form.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Stores.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tabs.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Grid.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Form.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Form.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Stores.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tabs.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Controller/Adminhtml/Chatbot.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/Model/Resource/Setup.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotapiController.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotuserController.php create mode 100644 Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/MessageController.php diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php new file mode 100644 index 0000000..227d3d3 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php @@ -0,0 +1,42 @@ +_controller = 'adminhtml_chatbotapi'; + $this->_blockGroup = 'werules_chatbot'; + parent::__construct(); + $this->_headerText = Mage::helper('werules_chatbot')->__('ChatbotAPI'); + $this->_updateButton('add', 'label', Mage::helper('werules_chatbot')->__('Add ChatbotAPI')); + + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit.php new file mode 100644 index 0000000..a62c9e7 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit.php @@ -0,0 +1,82 @@ +_blockGroup = 'werules_chatbot'; + $this->_controller = 'adminhtml_chatbotapi'; + $this->_updateButton( + 'save', + 'label', + Mage::helper('werules_chatbot')->__('Save ChatbotAPI') + ); + $this->_updateButton( + 'delete', + 'label', + Mage::helper('werules_chatbot')->__('Delete ChatbotAPI') + ); + $this->_addButton( + 'saveandcontinue', + array( + 'label' => Mage::helper('werules_chatbot')->__('Save And Continue Edit'), + 'onclick' => 'saveAndContinueEdit()', + 'class' => 'save', + ), + -100 + ); + $this->_formScripts[] = " + function saveAndContinueEdit() { + editForm.submit($('edit_form').action+'back/edit/'); + } + "; + } + + /** + * get the edit form header + * + * @access public + * @return string + * @author Ultimate Module Creator + */ + public function getHeaderText() + { + if (Mage::registry('current_chatbotapi') && Mage::registry('current_chatbotapi')->getId()) { + return Mage::helper('werules_chatbot')->__( + "Edit ChatbotAPI '%s'", + $this->escapeHtml(Mage::registry('current_chatbotapi')->getChatbotapiId()) + ); + } else { + return Mage::helper('werules_chatbot')->__('Add ChatbotAPI'); + } + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Form.php new file mode 100644 index 0000000..055238f --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Form.php @@ -0,0 +1,52 @@ + 'edit_form', + 'action' => $this->getUrl( + '*/*/save', + array( + 'id' => $this->getRequest()->getParam('id') + ) + ), + 'method' => 'post', + 'enctype' => 'multipart/form-data' + ) + ); + $form->setUseContainer(true); + $this->setForm($form); + return parent::_prepareForm(); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Form.php new file mode 100644 index 0000000..0ab33a9 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Form.php @@ -0,0 +1,225 @@ +setHtmlIdPrefix('chatbotapi_'); + $form->setFieldNameSuffix('chatbotapi'); + $this->setForm($form); + $fieldset = $form->addFieldset( + 'chatbotapi_form', + array('legend' => Mage::helper('werules_chatbot')->__('ChatbotAPI')) + ); + + $fieldset->addField( + 'chatbotapi_id', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('ChatbotAPI ID'), + 'name' => 'chatbotapi_id', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'hash_key', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Hash Key'), + 'name' => 'hash_key', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'logged', + 'select', + array( + 'label' => Mage::helper('werules_chatbot')->__('Logged?'), + 'name' => 'logged', + 'required' => true, + 'class' => 'required-entry', + + 'values'=> array( + array( + 'value' => 1, + 'label' => Mage::helper('werules_chatbot')->__('Yes'), + ), + array( + 'value' => 0, + 'label' => Mage::helper('werules_chatbot')->__('No'), + ), + ), + ) + ); + + $fieldset->addField( + 'enabled', + 'select', + array( + 'label' => Mage::helper('werules_chatbot')->__('Enabled?'), + 'name' => 'enabled', + 'required' => true, + 'class' => 'required-entry', + + 'values'=> array( + array( + 'value' => 1, + 'label' => Mage::helper('werules_chatbot')->__('Yes'), + ), + array( + 'value' => 0, + 'label' => Mage::helper('werules_chatbot')->__('No'), + ), + ), + ) + ); + + $fieldset->addField( + 'chatbot_type', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Chatbot Type'), + 'name' => 'chatbot_type', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'chat_id', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Chat ID'), + 'name' => 'chat_id', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'conversation_state', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Conversation State'), + 'name' => 'conversation_state', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'fallback_qty', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Fallback Quantity'), + 'name' => 'fallback_qty', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'chatbotuser_id', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Chatbotuser ID'), + 'name' => 'chatbotuser_id', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'last_command_details', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Last Command Details'), + 'name' => 'last_command_details', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + $fieldset->addField( + 'status', + 'select', + array( + 'label' => Mage::helper('werules_chatbot')->__('Status'), + 'name' => 'status', + 'values' => array( + array( + 'value' => 1, + 'label' => Mage::helper('werules_chatbot')->__('Enabled'), + ), + array( + 'value' => 0, + 'label' => Mage::helper('werules_chatbot')->__('Disabled'), + ), + ), + ) + ); + if (Mage::app()->isSingleStoreMode()) { + $fieldset->addField( + 'store_id', + 'hidden', + array( + 'name' => 'stores[]', + 'value' => Mage::app()->getStore(true)->getId() + ) + ); + Mage::registry('current_chatbotapi')->setStoreId(Mage::app()->getStore(true)->getId()); + } + $formValues = Mage::registry('current_chatbotapi')->getDefaultValues(); + if (!is_array($formValues)) { + $formValues = array(); + } + if (Mage::getSingleton('adminhtml/session')->getChatbotapiData()) { + $formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getChatbotapiData()); + Mage::getSingleton('adminhtml/session')->setChatbotapiData(null); + } elseif (Mage::registry('current_chatbotapi')) { + $formValues = array_merge($formValues, Mage::registry('current_chatbotapi')->getData()); + } + $form->setValues($formValues); + return parent::_prepareForm(); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Stores.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Stores.php new file mode 100644 index 0000000..526e1f3 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Stores.php @@ -0,0 +1,58 @@ +setFieldNameSuffix('chatbotapi'); + $this->setForm($form); + $fieldset = $form->addFieldset( + 'chatbotapi_stores_form', + array('legend' => Mage::helper('werules_chatbot')->__('Store views')) + ); + $field = $fieldset->addField( + 'store_id', + 'multiselect', + array( + 'name' => 'stores[]', + 'label' => Mage::helper('werules_chatbot')->__('Store Views'), + 'title' => Mage::helper('werules_chatbot')->__('Store Views'), + 'required' => true, + 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true), + ) + ); + $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element'); + $field->setRenderer($renderer); + $form->addValues(Mage::registry('current_chatbotapi')->getData()); + return parent::_prepareForm(); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tabs.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tabs.php new file mode 100644 index 0000000..54297c3 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tabs.php @@ -0,0 +1,87 @@ +setId('chatbotapi_tabs'); + $this->setDestElementId('edit_form'); + $this->setTitle(Mage::helper('werules_chatbot')->__('ChatbotAPI')); + } + + /** + * before render html + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Tabs + * @author Ultimate Module Creator + */ + protected function _beforeToHtml() + { + $this->addTab( + 'form_chatbotapi', + array( + 'label' => Mage::helper('werules_chatbot')->__('ChatbotAPI'), + 'title' => Mage::helper('werules_chatbot')->__('ChatbotAPI'), + 'content' => $this->getLayout()->createBlock( + 'werules_chatbot/adminhtml_chatbotapi_edit_tab_form' + ) + ->toHtml(), + ) + ); + if (!Mage::app()->isSingleStoreMode()) { + $this->addTab( + 'form_store_chatbotapi', + array( + 'label' => Mage::helper('werules_chatbot')->__('Store views'), + 'title' => Mage::helper('werules_chatbot')->__('Store views'), + 'content' => $this->getLayout()->createBlock( + 'werules_chatbot/adminhtml_chatbotapi_edit_tab_stores' + ) + ->toHtml(), + ) + ); + } + return parent::_beforeToHtml(); + } + + /** + * Retrieve chatbotapi entity + * + * @access public + * @return Werules_Chatbot_Model_Chatbotapi + * @author Ultimate Module Creator + */ + public function getChatbotapi() + { + return Mage::registry('current_chatbotapi'); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Grid.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Grid.php new file mode 100644 index 0000000..ce9f2e1 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Grid.php @@ -0,0 +1,378 @@ +setId('chatbotapiGrid'); + $this->setDefaultSort('entity_id'); + $this->setDefaultDir('ASC'); + $this->setSaveParametersInSession(true); + $this->setUseAjax(true); + } + + /** + * prepare collection + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Grid + * @author Ultimate Module Creator + */ + protected function _prepareCollection() + { + $collection = Mage::getModel('werules_chatbot/chatbotapi') + ->getCollection(); + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + /** + * prepare grid collection + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Grid + * @author Ultimate Module Creator + */ + protected function _prepareColumns() + { + $this->addColumn( + 'entity_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Id'), + 'index' => 'entity_id', + 'type' => 'number' + ) + ); + $this->addColumn( + 'chatbotapi_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('ChatbotAPI ID'), + 'align' => 'left', + 'index' => 'chatbotapi_id', + ) + ); + + $this->addColumn( + 'status', + array( + 'header' => Mage::helper('werules_chatbot')->__('Status'), + 'index' => 'status', + 'type' => 'options', + 'options' => array( + '1' => Mage::helper('werules_chatbot')->__('Enabled'), + '0' => Mage::helper('werules_chatbot')->__('Disabled'), + ) + ) + ); + $this->addColumn( + 'hash_key', + array( + 'header' => Mage::helper('werules_chatbot')->__('Hash Key'), + 'index' => 'hash_key', + 'type'=> 'text', + + ) + ); + $this->addColumn( + 'logged', + array( + 'header' => Mage::helper('werules_chatbot')->__('Logged?'), + 'index' => 'logged', + 'type' => 'options', + 'options' => array( + '1' => Mage::helper('werules_chatbot')->__('Yes'), + '0' => Mage::helper('werules_chatbot')->__('No'), + ) + + ) + ); + $this->addColumn( + 'enabled', + array( + 'header' => Mage::helper('werules_chatbot')->__('Enabled?'), + 'index' => 'enabled', + 'type' => 'options', + 'options' => array( + '1' => Mage::helper('werules_chatbot')->__('Yes'), + '0' => Mage::helper('werules_chatbot')->__('No'), + ) + + ) + ); + $this->addColumn( + 'chatbot_type', + array( + 'header' => Mage::helper('werules_chatbot')->__('Chatbot Type'), + 'index' => 'chatbot_type', + 'type'=> 'number', + + ) + ); + $this->addColumn( + 'chat_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Chat ID'), + 'index' => 'chat_id', + 'type'=> 'text', + + ) + ); + $this->addColumn( + 'conversation_state', + array( + 'header' => Mage::helper('werules_chatbot')->__('Conversation State'), + 'index' => 'conversation_state', + 'type'=> 'number', + + ) + ); + $this->addColumn( + 'fallback_qty', + array( + 'header' => Mage::helper('werules_chatbot')->__('Fallback Quantity'), + 'index' => 'fallback_qty', + 'type'=> 'number', + + ) + ); + $this->addColumn( + 'chatbotuser_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Chatbotuser ID'), + 'index' => 'chatbotuser_id', + 'type'=> 'number', + + ) + ); + $this->addColumn( + 'last_command_details', + array( + 'header' => Mage::helper('werules_chatbot')->__('Last Command Details'), + 'index' => 'last_command_details', + 'type'=> 'text', + + ) + ); + if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) { + $this->addColumn( + 'store_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Store Views'), + 'index' => 'store_id', + 'type' => 'store', + 'store_all' => true, + 'store_view' => true, + 'sortable' => false, + 'filter_condition_callback'=> array($this, '_filterStoreCondition'), + ) + ); + } + $this->addColumn( + 'created_at', + array( + 'header' => Mage::helper('werules_chatbot')->__('Created at'), + 'index' => 'created_at', + 'width' => '120px', + 'type' => 'datetime', + ) + ); + $this->addColumn( + 'updated_at', + array( + 'header' => Mage::helper('werules_chatbot')->__('Updated at'), + 'index' => 'updated_at', + 'width' => '120px', + 'type' => 'datetime', + ) + ); + $this->addColumn( + 'action', + array( + 'header' => Mage::helper('werules_chatbot')->__('Action'), + 'width' => '100', + 'type' => 'action', + 'getter' => 'getId', + 'actions' => array( + array( + 'caption' => Mage::helper('werules_chatbot')->__('Edit'), + 'url' => array('base'=> '*/*/edit'), + 'field' => 'id' + ) + ), + 'filter' => false, + 'is_system' => true, + 'sortable' => false, + ) + ); + $this->addExportType('*/*/exportCsv', Mage::helper('werules_chatbot')->__('CSV')); + $this->addExportType('*/*/exportExcel', Mage::helper('werules_chatbot')->__('Excel')); + $this->addExportType('*/*/exportXml', Mage::helper('werules_chatbot')->__('XML')); + return parent::_prepareColumns(); + } + + /** + * prepare mass action + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Grid + * @author Ultimate Module Creator + */ + protected function _prepareMassaction() + { + $this->setMassactionIdField('entity_id'); + $this->getMassactionBlock()->setFormFieldName('chatbotapi'); + $this->getMassactionBlock()->addItem( + 'delete', + array( + 'label'=> Mage::helper('werules_chatbot')->__('Delete'), + 'url' => $this->getUrl('*/*/massDelete'), + 'confirm' => Mage::helper('werules_chatbot')->__('Are you sure?') + ) + ); + $this->getMassactionBlock()->addItem( + 'status', + array( + 'label' => Mage::helper('werules_chatbot')->__('Change status'), + 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)), + 'additional' => array( + 'status' => array( + 'name' => 'status', + 'type' => 'select', + 'class' => 'required-entry', + 'label' => Mage::helper('werules_chatbot')->__('Status'), + 'values' => array( + '1' => Mage::helper('werules_chatbot')->__('Enabled'), + '0' => Mage::helper('werules_chatbot')->__('Disabled'), + ) + ) + ) + ) + ); + $this->getMassactionBlock()->addItem( + 'logged', + array( + 'label' => Mage::helper('werules_chatbot')->__('Change Logged?'), + 'url' => $this->getUrl('*/*/massLogged', array('_current'=>true)), + 'additional' => array( + 'flag_logged' => array( + 'name' => 'flag_logged', + 'type' => 'select', + 'class' => 'required-entry', + 'label' => Mage::helper('werules_chatbot')->__('Logged?'), + 'values' => array( + '1' => Mage::helper('werules_chatbot')->__('Yes'), + '0' => Mage::helper('werules_chatbot')->__('No'), + ) + + ) + ) + ) + ); + $this->getMassactionBlock()->addItem( + 'enabled', + array( + 'label' => Mage::helper('werules_chatbot')->__('Change Enabled?'), + 'url' => $this->getUrl('*/*/massEnabled', array('_current'=>true)), + 'additional' => array( + 'flag_enabled' => array( + 'name' => 'flag_enabled', + 'type' => 'select', + 'class' => 'required-entry', + 'label' => Mage::helper('werules_chatbot')->__('Enabled?'), + 'values' => array( + '1' => Mage::helper('werules_chatbot')->__('Yes'), + '0' => Mage::helper('werules_chatbot')->__('No'), + ) + + ) + ) + ) + ); + return $this; + } + + /** + * get the row url + * + * @access public + * @param Werules_Chatbot_Model_Chatbotapi + * @return string + * @author Ultimate Module Creator + */ + public function getRowUrl($row) + { + return $this->getUrl('*/*/edit', array('id' => $row->getId())); + } + + /** + * get the grid url + * + * @access public + * @return string + * @author Ultimate Module Creator + */ + public function getGridUrl() + { + return $this->getUrl('*/*/grid', array('_current'=>true)); + } + + /** + * after collection load + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Grid + * @author Ultimate Module Creator + */ + protected function _afterLoadCollection() + { + $this->getCollection()->walk('afterLoad'); + parent::_afterLoadCollection(); + } + + /** + * filter store column + * + * @access protected + * @param Werules_Chatbot_Model_Resource_Chatbotapi_Collection $collection + * @param Mage_Adminhtml_Block_Widget_Grid_Column $column + * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Grid + * @author Ultimate Module Creator + */ + protected function _filterStoreCondition($collection, $column) + { + if (!$value = $column->getFilter()->getValue()) { + return; + } + $collection->addStoreFilter($value); + return $this; + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser.php new file mode 100644 index 0000000..d898e30 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser.php @@ -0,0 +1,42 @@ +_controller = 'adminhtml_chatbotuser'; + $this->_blockGroup = 'werules_chatbot'; + parent::__construct(); + $this->_headerText = Mage::helper('werules_chatbot')->__('ChatbotUser'); + $this->_updateButton('add', 'label', Mage::helper('werules_chatbot')->__('Add ChatbotUser')); + + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit.php new file mode 100644 index 0000000..8c09430 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit.php @@ -0,0 +1,82 @@ +_blockGroup = 'werules_chatbot'; + $this->_controller = 'adminhtml_chatbotuser'; + $this->_updateButton( + 'save', + 'label', + Mage::helper('werules_chatbot')->__('Save ChatbotUser') + ); + $this->_updateButton( + 'delete', + 'label', + Mage::helper('werules_chatbot')->__('Delete ChatbotUser') + ); + $this->_addButton( + 'saveandcontinue', + array( + 'label' => Mage::helper('werules_chatbot')->__('Save And Continue Edit'), + 'onclick' => 'saveAndContinueEdit()', + 'class' => 'save', + ), + -100 + ); + $this->_formScripts[] = " + function saveAndContinueEdit() { + editForm.submit($('edit_form').action+'back/edit/'); + } + "; + } + + /** + * get the edit form header + * + * @access public + * @return string + * @author Ultimate Module Creator + */ + public function getHeaderText() + { + if (Mage::registry('current_chatbotuser') && Mage::registry('current_chatbotuser')->getId()) { + return Mage::helper('werules_chatbot')->__( + "Edit ChatbotUser '%s'", + $this->escapeHtml(Mage::registry('current_chatbotuser')->getChatbotuserId()) + ); + } else { + return Mage::helper('werules_chatbot')->__('Add ChatbotUser'); + } + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Form.php new file mode 100644 index 0000000..e4765e4 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Form.php @@ -0,0 +1,52 @@ + 'edit_form', + 'action' => $this->getUrl( + '*/*/save', + array( + 'id' => $this->getRequest()->getParam('id') + ) + ), + 'method' => 'post', + 'enctype' => 'multipart/form-data' + ) + ); + $form->setUseContainer(true); + $this->setForm($form); + return parent::_prepareForm(); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Form.php new file mode 100644 index 0000000..4e0fe6f --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Form.php @@ -0,0 +1,175 @@ +setHtmlIdPrefix('chatbotuser_'); + $form->setFieldNameSuffix('chatbotuser'); + $this->setForm($form); + $fieldset = $form->addFieldset( + 'chatbotuser_form', + array('legend' => Mage::helper('werules_chatbot')->__('ChatbotUser')) + ); + + $fieldset->addField( + 'chatbotuser_id', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('ChatbotUser ID'), + 'name' => 'chatbotuser_id', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'session_id', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Session ID'), + 'name' => 'session_id', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'enable_promotional_messages', + 'select', + array( + 'label' => Mage::helper('werules_chatbot')->__('Enable Promotional Messages'), + 'name' => 'enable_promotional_messages', + 'required' => true, + 'class' => 'required-entry', + + 'values'=> array( + array( + 'value' => 1, + 'label' => Mage::helper('werules_chatbot')->__('Yes'), + ), + array( + 'value' => 0, + 'label' => Mage::helper('werules_chatbot')->__('No'), + ), + ), + ) + ); + + $fieldset->addField( + 'enable_support', + 'select', + array( + 'label' => Mage::helper('werules_chatbot')->__('Enable Support'), + 'name' => 'enable_support', + 'required' => true, + 'class' => 'required-entry', + + 'values'=> array( + array( + 'value' => 1, + 'label' => Mage::helper('werules_chatbot')->__('Yes'), + ), + array( + 'value' => 0, + 'label' => Mage::helper('werules_chatbot')->__('No'), + ), + ), + ) + ); + + $fieldset->addField( + 'admin', + 'select', + array( + 'label' => Mage::helper('werules_chatbot')->__('Is Admin?'), + 'name' => 'admin', + 'required' => true, + 'class' => 'required-entry', + + 'values'=> array( + array( + 'value' => 1, + 'label' => Mage::helper('werules_chatbot')->__('Yes'), + ), + array( + 'value' => 0, + 'label' => Mage::helper('werules_chatbot')->__('No'), + ), + ), + ) + ); + $fieldset->addField( + 'status', + 'select', + array( + 'label' => Mage::helper('werules_chatbot')->__('Status'), + 'name' => 'status', + 'values' => array( + array( + 'value' => 1, + 'label' => Mage::helper('werules_chatbot')->__('Enabled'), + ), + array( + 'value' => 0, + 'label' => Mage::helper('werules_chatbot')->__('Disabled'), + ), + ), + ) + ); + if (Mage::app()->isSingleStoreMode()) { + $fieldset->addField( + 'store_id', + 'hidden', + array( + 'name' => 'stores[]', + 'value' => Mage::app()->getStore(true)->getId() + ) + ); + Mage::registry('current_chatbotuser')->setStoreId(Mage::app()->getStore(true)->getId()); + } + $formValues = Mage::registry('current_chatbotuser')->getDefaultValues(); + if (!is_array($formValues)) { + $formValues = array(); + } + if (Mage::getSingleton('adminhtml/session')->getChatbotuserData()) { + $formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getChatbotuserData()); + Mage::getSingleton('adminhtml/session')->setChatbotuserData(null); + } elseif (Mage::registry('current_chatbotuser')) { + $formValues = array_merge($formValues, Mage::registry('current_chatbotuser')->getData()); + } + $form->setValues($formValues); + return parent::_prepareForm(); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Stores.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Stores.php new file mode 100644 index 0000000..48a70d3 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Stores.php @@ -0,0 +1,58 @@ +setFieldNameSuffix('chatbotuser'); + $this->setForm($form); + $fieldset = $form->addFieldset( + 'chatbotuser_stores_form', + array('legend' => Mage::helper('werules_chatbot')->__('Store views')) + ); + $field = $fieldset->addField( + 'store_id', + 'multiselect', + array( + 'name' => 'stores[]', + 'label' => Mage::helper('werules_chatbot')->__('Store Views'), + 'title' => Mage::helper('werules_chatbot')->__('Store Views'), + 'required' => true, + 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true), + ) + ); + $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element'); + $field->setRenderer($renderer); + $form->addValues(Mage::registry('current_chatbotuser')->getData()); + return parent::_prepareForm(); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tabs.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tabs.php new file mode 100644 index 0000000..6b792f4 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tabs.php @@ -0,0 +1,87 @@ +setId('chatbotuser_tabs'); + $this->setDestElementId('edit_form'); + $this->setTitle(Mage::helper('werules_chatbot')->__('ChatbotUser')); + } + + /** + * before render html + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Tabs + * @author Ultimate Module Creator + */ + protected function _beforeToHtml() + { + $this->addTab( + 'form_chatbotuser', + array( + 'label' => Mage::helper('werules_chatbot')->__('ChatbotUser'), + 'title' => Mage::helper('werules_chatbot')->__('ChatbotUser'), + 'content' => $this->getLayout()->createBlock( + 'werules_chatbot/adminhtml_chatbotuser_edit_tab_form' + ) + ->toHtml(), + ) + ); + if (!Mage::app()->isSingleStoreMode()) { + $this->addTab( + 'form_store_chatbotuser', + array( + 'label' => Mage::helper('werules_chatbot')->__('Store views'), + 'title' => Mage::helper('werules_chatbot')->__('Store views'), + 'content' => $this->getLayout()->createBlock( + 'werules_chatbot/adminhtml_chatbotuser_edit_tab_stores' + ) + ->toHtml(), + ) + ); + } + return parent::_beforeToHtml(); + } + + /** + * Retrieve chatbotuser entity + * + * @access public + * @return Werules_Chatbot_Model_Chatbotuser + * @author Ultimate Module Creator + */ + public function getChatbotuser() + { + return Mage::registry('current_chatbotuser'); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Grid.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Grid.php new file mode 100644 index 0000000..a23290e --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Grid.php @@ -0,0 +1,357 @@ +setId('chatbotuserGrid'); + $this->setDefaultSort('entity_id'); + $this->setDefaultDir('ASC'); + $this->setSaveParametersInSession(true); + $this->setUseAjax(true); + } + + /** + * prepare collection + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Grid + * @author Ultimate Module Creator + */ + protected function _prepareCollection() + { + $collection = Mage::getModel('werules_chatbot/chatbotuser') + ->getCollection(); + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + /** + * prepare grid collection + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Grid + * @author Ultimate Module Creator + */ + protected function _prepareColumns() + { + $this->addColumn( + 'entity_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Id'), + 'index' => 'entity_id', + 'type' => 'number' + ) + ); + $this->addColumn( + 'chatbotuser_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('ChatbotUser ID'), + 'align' => 'left', + 'index' => 'chatbotuser_id', + ) + ); + + $this->addColumn( + 'status', + array( + 'header' => Mage::helper('werules_chatbot')->__('Status'), + 'index' => 'status', + 'type' => 'options', + 'options' => array( + '1' => Mage::helper('werules_chatbot')->__('Enabled'), + '0' => Mage::helper('werules_chatbot')->__('Disabled'), + ) + ) + ); + $this->addColumn( + 'session_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Session ID'), + 'index' => 'session_id', + 'type'=> 'text', + + ) + ); + $this->addColumn( + 'enable_promotional_messages', + array( + 'header' => Mage::helper('werules_chatbot')->__('Enable Promotional Messages'), + 'index' => 'enable_promotional_messages', + 'type' => 'options', + 'options' => array( + '1' => Mage::helper('werules_chatbot')->__('Yes'), + '0' => Mage::helper('werules_chatbot')->__('No'), + ) + + ) + ); + $this->addColumn( + 'enable_support', + array( + 'header' => Mage::helper('werules_chatbot')->__('Enable Support'), + 'index' => 'enable_support', + 'type' => 'options', + 'options' => array( + '1' => Mage::helper('werules_chatbot')->__('Yes'), + '0' => Mage::helper('werules_chatbot')->__('No'), + ) + + ) + ); + $this->addColumn( + 'admin', + array( + 'header' => Mage::helper('werules_chatbot')->__('Is Admin?'), + 'index' => 'admin', + 'type' => 'options', + 'options' => array( + '1' => Mage::helper('werules_chatbot')->__('Yes'), + '0' => Mage::helper('werules_chatbot')->__('No'), + ) + + ) + ); + if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) { + $this->addColumn( + 'store_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Store Views'), + 'index' => 'store_id', + 'type' => 'store', + 'store_all' => true, + 'store_view' => true, + 'sortable' => false, + 'filter_condition_callback'=> array($this, '_filterStoreCondition'), + ) + ); + } + $this->addColumn( + 'created_at', + array( + 'header' => Mage::helper('werules_chatbot')->__('Created at'), + 'index' => 'created_at', + 'width' => '120px', + 'type' => 'datetime', + ) + ); + $this->addColumn( + 'updated_at', + array( + 'header' => Mage::helper('werules_chatbot')->__('Updated at'), + 'index' => 'updated_at', + 'width' => '120px', + 'type' => 'datetime', + ) + ); + $this->addColumn( + 'action', + array( + 'header' => Mage::helper('werules_chatbot')->__('Action'), + 'width' => '100', + 'type' => 'action', + 'getter' => 'getId', + 'actions' => array( + array( + 'caption' => Mage::helper('werules_chatbot')->__('Edit'), + 'url' => array('base'=> '*/*/edit'), + 'field' => 'id' + ) + ), + 'filter' => false, + 'is_system' => true, + 'sortable' => false, + ) + ); + $this->addExportType('*/*/exportCsv', Mage::helper('werules_chatbot')->__('CSV')); + $this->addExportType('*/*/exportExcel', Mage::helper('werules_chatbot')->__('Excel')); + $this->addExportType('*/*/exportXml', Mage::helper('werules_chatbot')->__('XML')); + return parent::_prepareColumns(); + } + + /** + * prepare mass action + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Grid + * @author Ultimate Module Creator + */ + protected function _prepareMassaction() + { + $this->setMassactionIdField('entity_id'); + $this->getMassactionBlock()->setFormFieldName('chatbotuser'); + $this->getMassactionBlock()->addItem( + 'delete', + array( + 'label'=> Mage::helper('werules_chatbot')->__('Delete'), + 'url' => $this->getUrl('*/*/massDelete'), + 'confirm' => Mage::helper('werules_chatbot')->__('Are you sure?') + ) + ); + $this->getMassactionBlock()->addItem( + 'status', + array( + 'label' => Mage::helper('werules_chatbot')->__('Change status'), + 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)), + 'additional' => array( + 'status' => array( + 'name' => 'status', + 'type' => 'select', + 'class' => 'required-entry', + 'label' => Mage::helper('werules_chatbot')->__('Status'), + 'values' => array( + '1' => Mage::helper('werules_chatbot')->__('Enabled'), + '0' => Mage::helper('werules_chatbot')->__('Disabled'), + ) + ) + ) + ) + ); + $this->getMassactionBlock()->addItem( + 'enable_promotional_messages', + array( + 'label' => Mage::helper('werules_chatbot')->__('Change Enable Promotional Messages'), + 'url' => $this->getUrl('*/*/massEnablePromotionalMessages', array('_current'=>true)), + 'additional' => array( + 'flag_enable_promotional_messages' => array( + 'name' => 'flag_enable_promotional_messages', + 'type' => 'select', + 'class' => 'required-entry', + 'label' => Mage::helper('werules_chatbot')->__('Enable Promotional Messages'), + 'values' => array( + '1' => Mage::helper('werules_chatbot')->__('Yes'), + '0' => Mage::helper('werules_chatbot')->__('No'), + ) + + ) + ) + ) + ); + $this->getMassactionBlock()->addItem( + 'enable_support', + array( + 'label' => Mage::helper('werules_chatbot')->__('Change Enable Support'), + 'url' => $this->getUrl('*/*/massEnableSupport', array('_current'=>true)), + 'additional' => array( + 'flag_enable_support' => array( + 'name' => 'flag_enable_support', + 'type' => 'select', + 'class' => 'required-entry', + 'label' => Mage::helper('werules_chatbot')->__('Enable Support'), + 'values' => array( + '1' => Mage::helper('werules_chatbot')->__('Yes'), + '0' => Mage::helper('werules_chatbot')->__('No'), + ) + + ) + ) + ) + ); + $this->getMassactionBlock()->addItem( + 'admin', + array( + 'label' => Mage::helper('werules_chatbot')->__('Change Is Admin?'), + 'url' => $this->getUrl('*/*/massAdmin', array('_current'=>true)), + 'additional' => array( + 'flag_admin' => array( + 'name' => 'flag_admin', + 'type' => 'select', + 'class' => 'required-entry', + 'label' => Mage::helper('werules_chatbot')->__('Is Admin?'), + 'values' => array( + '1' => Mage::helper('werules_chatbot')->__('Yes'), + '0' => Mage::helper('werules_chatbot')->__('No'), + ) + + ) + ) + ) + ); + return $this; + } + + /** + * get the row url + * + * @access public + * @param Werules_Chatbot_Model_Chatbotuser + * @return string + * @author Ultimate Module Creator + */ + public function getRowUrl($row) + { + return $this->getUrl('*/*/edit', array('id' => $row->getId())); + } + + /** + * get the grid url + * + * @access public + * @return string + * @author Ultimate Module Creator + */ + public function getGridUrl() + { + return $this->getUrl('*/*/grid', array('_current'=>true)); + } + + /** + * after collection load + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Grid + * @author Ultimate Module Creator + */ + protected function _afterLoadCollection() + { + $this->getCollection()->walk('afterLoad'); + parent::_afterLoadCollection(); + } + + /** + * filter store column + * + * @access protected + * @param Werules_Chatbot_Model_Resource_Chatbotuser_Collection $collection + * @param Mage_Adminhtml_Block_Widget_Grid_Column $column + * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Grid + * @author Ultimate Module Creator + */ + protected function _filterStoreCondition($collection, $column) + { + if (!$value = $column->getFilter()->getValue()) { + return; + } + $collection->addStoreFilter($value); + return $this; + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message.php new file mode 100644 index 0000000..06f8e00 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message.php @@ -0,0 +1,42 @@ +_controller = 'adminhtml_message'; + $this->_blockGroup = 'werules_chatbot'; + parent::__construct(); + $this->_headerText = Mage::helper('werules_chatbot')->__('Message'); + $this->_updateButton('add', 'label', Mage::helper('werules_chatbot')->__('Add Message')); + + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit.php new file mode 100644 index 0000000..68e4aec --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit.php @@ -0,0 +1,82 @@ +_blockGroup = 'werules_chatbot'; + $this->_controller = 'adminhtml_message'; + $this->_updateButton( + 'save', + 'label', + Mage::helper('werules_chatbot')->__('Save Message') + ); + $this->_updateButton( + 'delete', + 'label', + Mage::helper('werules_chatbot')->__('Delete Message') + ); + $this->_addButton( + 'saveandcontinue', + array( + 'label' => Mage::helper('werules_chatbot')->__('Save And Continue Edit'), + 'onclick' => 'saveAndContinueEdit()', + 'class' => 'save', + ), + -100 + ); + $this->_formScripts[] = " + function saveAndContinueEdit() { + editForm.submit($('edit_form').action+'back/edit/'); + } + "; + } + + /** + * get the edit form header + * + * @access public + * @return string + * @author Ultimate Module Creator + */ + public function getHeaderText() + { + if (Mage::registry('current_message') && Mage::registry('current_message')->getId()) { + return Mage::helper('werules_chatbot')->__( + "Edit Message '%s'", + $this->escapeHtml(Mage::registry('current_message')->getMessageId()) + ); + } else { + return Mage::helper('werules_chatbot')->__('Add Message'); + } + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Form.php new file mode 100644 index 0000000..9ae4cd6 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Form.php @@ -0,0 +1,52 @@ + 'edit_form', + 'action' => $this->getUrl( + '*/*/save', + array( + 'id' => $this->getRequest()->getParam('id') + ) + ), + 'method' => 'post', + 'enctype' => 'multipart/form-data' + ) + ); + $form->setUseContainer(true); + $this->setForm($form); + return parent::_prepareForm(); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Form.php new file mode 100644 index 0000000..af1fb04 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Form.php @@ -0,0 +1,219 @@ +setHtmlIdPrefix('message_'); + $form->setFieldNameSuffix('message'); + $this->setForm($form); + $fieldset = $form->addFieldset( + 'message_form', + array('legend' => Mage::helper('werules_chatbot')->__('Message')) + ); + + $fieldset->addField( + 'sender_id', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Sender ID'), + 'name' => 'sender_id', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'content', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Content'), + 'name' => 'content', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'status', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Status'), + 'name' => 'status', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'direction', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Direction'), + 'name' => 'direction', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'chat_message_id', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Chat Message ID'), + 'name' => 'chat_message_id', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'chatbot_type', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Chatbot Type'), + 'name' => 'chatbot_type', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'content_type', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Content Type'), + 'name' => 'content_type', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'message_payload', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Message Payload'), + 'name' => 'message_payload', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'sent_at', + 'date', + array( + 'label' => Mage::helper('werules_chatbot')->__('Sent At'), + 'name' => 'sent_at', + 'required' => true, + 'class' => 'required-entry', + + 'image' => $this->getSkinUrl('images/grid-cal.gif'), + 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), + ) + ); + + $fieldset->addField( + 'current_command_details', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Current Command Details'), + 'name' => 'current_command_details', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + + $fieldset->addField( + 'message_id', + 'text', + array( + 'label' => Mage::helper('werules_chatbot')->__('Message ID'), + 'name' => 'message_id', + 'required' => true, + 'class' => 'required-entry', + + ) + ); + $fieldset->addField( + 'status', + 'select', + array( + 'label' => Mage::helper('werules_chatbot')->__('Status'), + 'name' => 'status', + 'values' => array( + array( + 'value' => 1, + 'label' => Mage::helper('werules_chatbot')->__('Enabled'), + ), + array( + 'value' => 0, + 'label' => Mage::helper('werules_chatbot')->__('Disabled'), + ), + ), + ) + ); + if (Mage::app()->isSingleStoreMode()) { + $fieldset->addField( + 'store_id', + 'hidden', + array( + 'name' => 'stores[]', + 'value' => Mage::app()->getStore(true)->getId() + ) + ); + Mage::registry('current_message')->setStoreId(Mage::app()->getStore(true)->getId()); + } + $formValues = Mage::registry('current_message')->getDefaultValues(); + if (!is_array($formValues)) { + $formValues = array(); + } + if (Mage::getSingleton('adminhtml/session')->getMessageData()) { + $formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getMessageData()); + Mage::getSingleton('adminhtml/session')->setMessageData(null); + } elseif (Mage::registry('current_message')) { + $formValues = array_merge($formValues, Mage::registry('current_message')->getData()); + } + $form->setValues($formValues); + return parent::_prepareForm(); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Stores.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Stores.php new file mode 100644 index 0000000..312ed26 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Stores.php @@ -0,0 +1,58 @@ +setFieldNameSuffix('message'); + $this->setForm($form); + $fieldset = $form->addFieldset( + 'message_stores_form', + array('legend' => Mage::helper('werules_chatbot')->__('Store views')) + ); + $field = $fieldset->addField( + 'store_id', + 'multiselect', + array( + 'name' => 'stores[]', + 'label' => Mage::helper('werules_chatbot')->__('Store Views'), + 'title' => Mage::helper('werules_chatbot')->__('Store Views'), + 'required' => true, + 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true), + ) + ); + $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element'); + $field->setRenderer($renderer); + $form->addValues(Mage::registry('current_message')->getData()); + return parent::_prepareForm(); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tabs.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tabs.php new file mode 100644 index 0000000..9796475 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tabs.php @@ -0,0 +1,87 @@ +setId('message_tabs'); + $this->setDestElementId('edit_form'); + $this->setTitle(Mage::helper('werules_chatbot')->__('Message')); + } + + /** + * before render html + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Message_Edit_Tabs + * @author Ultimate Module Creator + */ + protected function _beforeToHtml() + { + $this->addTab( + 'form_message', + array( + 'label' => Mage::helper('werules_chatbot')->__('Message'), + 'title' => Mage::helper('werules_chatbot')->__('Message'), + 'content' => $this->getLayout()->createBlock( + 'werules_chatbot/adminhtml_message_edit_tab_form' + ) + ->toHtml(), + ) + ); + if (!Mage::app()->isSingleStoreMode()) { + $this->addTab( + 'form_store_message', + array( + 'label' => Mage::helper('werules_chatbot')->__('Store views'), + 'title' => Mage::helper('werules_chatbot')->__('Store views'), + 'content' => $this->getLayout()->createBlock( + 'werules_chatbot/adminhtml_message_edit_tab_stores' + ) + ->toHtml(), + ) + ); + } + return parent::_beforeToHtml(); + } + + /** + * Retrieve message entity + * + * @access public + * @return Werules_Chatbot_Model_Message + * @author Ultimate Module Creator + */ + public function getMessage() + { + return Mage::registry('current_message'); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php new file mode 100644 index 0000000..254c20f --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php @@ -0,0 +1,339 @@ +setId('messageGrid'); + $this->setDefaultSort('entity_id'); + $this->setDefaultDir('ASC'); + $this->setSaveParametersInSession(true); + $this->setUseAjax(true); + } + + /** + * prepare collection + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Message_Grid + * @author Ultimate Module Creator + */ + protected function _prepareCollection() + { + $collection = Mage::getModel('werules_chatbot/message') + ->getCollection(); + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + /** + * prepare grid collection + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Message_Grid + * @author Ultimate Module Creator + */ + protected function _prepareColumns() + { + $this->addColumn( + 'entity_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Id'), + 'index' => 'entity_id', + 'type' => 'number' + ) + ); + $this->addColumn( + 'message_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Message ID'), + 'align' => 'left', + 'index' => 'message_id', + ) + ); + + $this->addColumn( + 'status', + array( + 'header' => Mage::helper('werules_chatbot')->__('Status'), + 'index' => 'status', + 'type' => 'options', + 'options' => array( + '1' => Mage::helper('werules_chatbot')->__('Enabled'), + '0' => Mage::helper('werules_chatbot')->__('Disabled'), + ) + ) + ); + $this->addColumn( + 'sender_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Sender ID'), + 'index' => 'sender_id', + 'type'=> 'text', + + ) + ); + $this->addColumn( + 'content', + array( + 'header' => Mage::helper('werules_chatbot')->__('Content'), + 'index' => 'content', + 'type'=> 'text', + + ) + ); + $this->addColumn( + 'status', + array( + 'header' => Mage::helper('werules_chatbot')->__('Status'), + 'index' => 'status', + 'type'=> 'number', + + ) + ); + $this->addColumn( + 'direction', + array( + 'header' => Mage::helper('werules_chatbot')->__('Direction'), + 'index' => 'direction', + 'type'=> 'number', + + ) + ); + $this->addColumn( + 'chat_message_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Chat Message ID'), + 'index' => 'chat_message_id', + 'type'=> 'text', + + ) + ); + $this->addColumn( + 'chatbot_type', + array( + 'header' => Mage::helper('werules_chatbot')->__('Chatbot Type'), + 'index' => 'chatbot_type', + 'type'=> 'number', + + ) + ); + $this->addColumn( + 'content_type', + array( + 'header' => Mage::helper('werules_chatbot')->__('Content Type'), + 'index' => 'content_type', + 'type'=> 'number', + + ) + ); + $this->addColumn( + 'message_payload', + array( + 'header' => Mage::helper('werules_chatbot')->__('Message Payload'), + 'index' => 'message_payload', + 'type'=> 'text', + + ) + ); + $this->addColumn( + 'sent_at', + array( + 'header' => Mage::helper('werules_chatbot')->__('Sent At'), + 'index' => 'sent_at', + 'type'=> 'date', + + ) + ); + $this->addColumn( + 'current_command_details', + array( + 'header' => Mage::helper('werules_chatbot')->__('Current Command Details'), + 'index' => 'current_command_details', + 'type'=> 'text', + + ) + ); + if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) { + $this->addColumn( + 'store_id', + array( + 'header' => Mage::helper('werules_chatbot')->__('Store Views'), + 'index' => 'store_id', + 'type' => 'store', + 'store_all' => true, + 'store_view' => true, + 'sortable' => false, + 'filter_condition_callback'=> array($this, '_filterStoreCondition'), + ) + ); + } + $this->addColumn( + 'created_at', + array( + 'header' => Mage::helper('werules_chatbot')->__('Created at'), + 'index' => 'created_at', + 'width' => '120px', + 'type' => 'datetime', + ) + ); + $this->addColumn( + 'updated_at', + array( + 'header' => Mage::helper('werules_chatbot')->__('Updated at'), + 'index' => 'updated_at', + 'width' => '120px', + 'type' => 'datetime', + ) + ); + $this->addColumn( + 'action', + array( + 'header' => Mage::helper('werules_chatbot')->__('Action'), + 'width' => '100', + 'type' => 'action', + 'getter' => 'getId', + 'actions' => array( + array( + 'caption' => Mage::helper('werules_chatbot')->__('Edit'), + 'url' => array('base'=> '*/*/edit'), + 'field' => 'id' + ) + ), + 'filter' => false, + 'is_system' => true, + 'sortable' => false, + ) + ); + $this->addExportType('*/*/exportCsv', Mage::helper('werules_chatbot')->__('CSV')); + $this->addExportType('*/*/exportExcel', Mage::helper('werules_chatbot')->__('Excel')); + $this->addExportType('*/*/exportXml', Mage::helper('werules_chatbot')->__('XML')); + return parent::_prepareColumns(); + } + + /** + * prepare mass action + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Message_Grid + * @author Ultimate Module Creator + */ + protected function _prepareMassaction() + { + $this->setMassactionIdField('entity_id'); + $this->getMassactionBlock()->setFormFieldName('message'); + $this->getMassactionBlock()->addItem( + 'delete', + array( + 'label'=> Mage::helper('werules_chatbot')->__('Delete'), + 'url' => $this->getUrl('*/*/massDelete'), + 'confirm' => Mage::helper('werules_chatbot')->__('Are you sure?') + ) + ); + $this->getMassactionBlock()->addItem( + 'status', + array( + 'label' => Mage::helper('werules_chatbot')->__('Change status'), + 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)), + 'additional' => array( + 'status' => array( + 'name' => 'status', + 'type' => 'select', + 'class' => 'required-entry', + 'label' => Mage::helper('werules_chatbot')->__('Status'), + 'values' => array( + '1' => Mage::helper('werules_chatbot')->__('Enabled'), + '0' => Mage::helper('werules_chatbot')->__('Disabled'), + ) + ) + ) + ) + ); + return $this; + } + + /** + * get the row url + * + * @access public + * @param Werules_Chatbot_Model_Message + * @return string + * @author Ultimate Module Creator + */ + public function getRowUrl($row) + { + return $this->getUrl('*/*/edit', array('id' => $row->getId())); + } + + /** + * get the grid url + * + * @access public + * @return string + * @author Ultimate Module Creator + */ + public function getGridUrl() + { + return $this->getUrl('*/*/grid', array('_current'=>true)); + } + + /** + * after collection load + * + * @access protected + * @return Werules_Chatbot_Block_Adminhtml_Message_Grid + * @author Ultimate Module Creator + */ + protected function _afterLoadCollection() + { + $this->getCollection()->walk('afterLoad'); + parent::_afterLoadCollection(); + } + + /** + * filter store column + * + * @access protected + * @param Werules_Chatbot_Model_Resource_Message_Collection $collection + * @param Mage_Adminhtml_Block_Widget_Grid_Column $column + * @return Werules_Chatbot_Block_Adminhtml_Message_Grid + * @author Ultimate Module Creator + */ + protected function _filterStoreCondition($collection, $column) + { + if (!$value = $column->getFilter()->getValue()) { + return; + } + $collection->addStoreFilter($value); + return $this; + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Controller/Adminhtml/Chatbot.php b/Magento1/app/code/community/Werules/Chatbot/Controller/Adminhtml/Chatbot.php new file mode 100644 index 0000000..68350d1 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Controller/Adminhtml/Chatbot.php @@ -0,0 +1,60 @@ +setAllowRenameFiles(true); + $uploader->setFilesDispersion(true); + $uploader->setAllowCreateFolders(true); + $result = $uploader->save($destinationFolder); + return $result['file']; + } + } catch (Exception $e) { + if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) { + throw $e; + } else { + if (isset($data[$input]['value'])) { + return $data[$input]['value']; + } + } + } + return ''; + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Setup.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Setup.php new file mode 100644 index 0000000..b7026ed --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Setup.php @@ -0,0 +1,26 @@ +getRequest()->getParam('id'); + $chatbotapi = Mage::getModel('werules_chatbot/chatbotapi'); + if ($chatbotapiId) { + $chatbotapi->load($chatbotapiId); + } + Mage::register('current_chatbotapi', $chatbotapi); + return $chatbotapi; + } + + /** + * default action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function indexAction() + { + $this->loadLayout(); + $this->_title(Mage::helper('werules_chatbot')->__('Chatbot Settings')) + ->_title(Mage::helper('werules_chatbot')->__('ChatbotAPIs')); + $this->renderLayout(); + } + + /** + * grid action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function gridAction() + { + $this->loadLayout()->renderLayout(); + } + + /** + * edit chatbotapi - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function editAction() + { + $chatbotapiId = $this->getRequest()->getParam('id'); + $chatbotapi = $this->_initChatbotapi(); + if ($chatbotapiId && !$chatbotapi->getId()) { + $this->_getSession()->addError( + Mage::helper('werules_chatbot')->__('This chatbotapi no longer exists.') + ); + $this->_redirect('*/*/'); + return; + } + $data = Mage::getSingleton('adminhtml/session')->getChatbotapiData(true); + if (!empty($data)) { + $chatbotapi->setData($data); + } + Mage::register('chatbotapi_data', $chatbotapi); + $this->loadLayout(); + $this->_title(Mage::helper('werules_chatbot')->__('Chatbot Settings')) + ->_title(Mage::helper('werules_chatbot')->__('ChatbotAPIs')); + if ($chatbotapi->getId()) { + $this->_title($chatbotapi->getChatbotapiId()); + } else { + $this->_title(Mage::helper('werules_chatbot')->__('Add chatbotapi')); + } + if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { + $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); + } + $this->renderLayout(); + } + + /** + * new chatbotapi action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function newAction() + { + $this->_forward('edit'); + } + + /** + * save chatbotapi - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function saveAction() + { + if ($data = $this->getRequest()->getPost('chatbotapi')) { + try { + $chatbotapi = $this->_initChatbotapi(); + $chatbotapi->addData($data); + $chatbotapi->save(); + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('werules_chatbot')->__('ChatbotAPI was successfully saved') + ); + Mage::getSingleton('adminhtml/session')->setFormData(false); + if ($this->getRequest()->getParam('back')) { + $this->_redirect('*/*/edit', array('id' => $chatbotapi->getId())); + return; + } + $this->_redirect('*/*/'); + return; + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + Mage::getSingleton('adminhtml/session')->setChatbotapiData($data); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + return; + } catch (Exception $e) { + Mage::logException($e); + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was a problem saving the chatbotapi.') + ); + Mage::getSingleton('adminhtml/session')->setChatbotapiData($data); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + return; + } + } + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Unable to find chatbotapi to save.') + ); + $this->_redirect('*/*/'); + } + + /** + * delete chatbotapi - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function deleteAction() + { + if ( $this->getRequest()->getParam('id') > 0) { + try { + $chatbotapi = Mage::getModel('werules_chatbot/chatbotapi'); + $chatbotapi->setId($this->getRequest()->getParam('id'))->delete(); + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('werules_chatbot')->__('ChatbotAPI was successfully deleted.') + ); + $this->_redirect('*/*/'); + return; + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error deleting chatbotapi.') + ); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + Mage::logException($e); + return; + } + } + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Could not find chatbotapi to delete.') + ); + $this->_redirect('*/*/'); + } + + /** + * mass delete chatbotapi - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function massDeleteAction() + { + $chatbotapiIds = $this->getRequest()->getParam('chatbotapi'); + if (!is_array($chatbotapiIds)) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Please select chatbotapis to delete.') + ); + } else { + try { + foreach ($chatbotapiIds as $chatbotapiId) { + $chatbotapi = Mage::getModel('werules_chatbot/chatbotapi'); + $chatbotapi->setId($chatbotapiId)->delete(); + } + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('werules_chatbot')->__('Total of %d chatbotapis were successfully deleted.', count($chatbotapiIds)) + ); + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error deleting chatbotapis.') + ); + Mage::logException($e); + } + } + $this->_redirect('*/*/index'); + } + + /** + * mass status change - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function massStatusAction() + { + $chatbotapiIds = $this->getRequest()->getParam('chatbotapi'); + if (!is_array($chatbotapiIds)) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Please select chatbotapis.') + ); + } else { + try { + foreach ($chatbotapiIds as $chatbotapiId) { + $chatbotapi = Mage::getSingleton('werules_chatbot/chatbotapi')->load($chatbotapiId) + ->setStatus($this->getRequest()->getParam('status')) + ->setIsMassupdate(true) + ->save(); + } + $this->_getSession()->addSuccess( + $this->__('Total of %d chatbotapis were successfully updated.', count($chatbotapiIds)) + ); + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error updating chatbotapis.') + ); + Mage::logException($e); + } + } + $this->_redirect('*/*/index'); + } + + /** + * mass Logged? change - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function massLoggedAction() + { + $chatbotapiIds = $this->getRequest()->getParam('chatbotapi'); + if (!is_array($chatbotapiIds)) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Please select chatbotapis.') + ); + } else { + try { + foreach ($chatbotapiIds as $chatbotapiId) { + $chatbotapi = Mage::getSingleton('werules_chatbot/chatbotapi')->load($chatbotapiId) + ->setLogged($this->getRequest()->getParam('flag_logged')) + ->setIsMassupdate(true) + ->save(); + } + $this->_getSession()->addSuccess( + $this->__('Total of %d chatbotapis were successfully updated.', count($chatbotapiIds)) + ); + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error updating chatbotapis.') + ); + Mage::logException($e); + } + } + $this->_redirect('*/*/index'); + } + + /** + * mass Enabled? change - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function massEnabledAction() + { + $chatbotapiIds = $this->getRequest()->getParam('chatbotapi'); + if (!is_array($chatbotapiIds)) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Please select chatbotapis.') + ); + } else { + try { + foreach ($chatbotapiIds as $chatbotapiId) { + $chatbotapi = Mage::getSingleton('werules_chatbot/chatbotapi')->load($chatbotapiId) + ->setEnabled($this->getRequest()->getParam('flag_enabled')) + ->setIsMassupdate(true) + ->save(); + } + $this->_getSession()->addSuccess( + $this->__('Total of %d chatbotapis were successfully updated.', count($chatbotapiIds)) + ); + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error updating chatbotapis.') + ); + Mage::logException($e); + } + } + $this->_redirect('*/*/index'); + } + + /** + * export as csv - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function exportCsvAction() + { + $fileName = 'chatbotapi.csv'; + $content = $this->getLayout()->createBlock('werules_chatbot/adminhtml_chatbotapi_grid') + ->getCsv(); + $this->_prepareDownloadResponse($fileName, $content); + } + + /** + * export as MsExcel - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function exportExcelAction() + { + $fileName = 'chatbotapi.xls'; + $content = $this->getLayout()->createBlock('werules_chatbot/adminhtml_chatbotapi_grid') + ->getExcelFile(); + $this->_prepareDownloadResponse($fileName, $content); + } + + /** + * export as xml - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function exportXmlAction() + { + $fileName = 'chatbotapi.xml'; + $content = $this->getLayout()->createBlock('werules_chatbot/adminhtml_chatbotapi_grid') + ->getXml(); + $this->_prepareDownloadResponse($fileName, $content); + } + + /** + * Check if admin has permissions to visit related pages + * + * @access protected + * @return boolean + * @author Ultimate Module Creator + */ + protected function _isAllowed() + { + return Mage::getSingleton('admin/session')->isAllowed('system/config/werules_chatbot/chatbotapi'); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotuserController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotuserController.php new file mode 100644 index 0000000..6c38883 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotuserController.php @@ -0,0 +1,439 @@ +getRequest()->getParam('id'); + $chatbotuser = Mage::getModel('werules_chatbot/chatbotuser'); + if ($chatbotuserId) { + $chatbotuser->load($chatbotuserId); + } + Mage::register('current_chatbotuser', $chatbotuser); + return $chatbotuser; + } + + /** + * default action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function indexAction() + { + $this->loadLayout(); + $this->_title(Mage::helper('werules_chatbot')->__('Chatbot Settings')) + ->_title(Mage::helper('werules_chatbot')->__('ChatbotUsers')); + $this->renderLayout(); + } + + /** + * grid action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function gridAction() + { + $this->loadLayout()->renderLayout(); + } + + /** + * edit chatbotuser - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function editAction() + { + $chatbotuserId = $this->getRequest()->getParam('id'); + $chatbotuser = $this->_initChatbotuser(); + if ($chatbotuserId && !$chatbotuser->getId()) { + $this->_getSession()->addError( + Mage::helper('werules_chatbot')->__('This chatbotuser no longer exists.') + ); + $this->_redirect('*/*/'); + return; + } + $data = Mage::getSingleton('adminhtml/session')->getChatbotuserData(true); + if (!empty($data)) { + $chatbotuser->setData($data); + } + Mage::register('chatbotuser_data', $chatbotuser); + $this->loadLayout(); + $this->_title(Mage::helper('werules_chatbot')->__('Chatbot Settings')) + ->_title(Mage::helper('werules_chatbot')->__('ChatbotUsers')); + if ($chatbotuser->getId()) { + $this->_title($chatbotuser->getChatbotuserId()); + } else { + $this->_title(Mage::helper('werules_chatbot')->__('Add chatbotuser')); + } + if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { + $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); + } + $this->renderLayout(); + } + + /** + * new chatbotuser action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function newAction() + { + $this->_forward('edit'); + } + + /** + * save chatbotuser - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function saveAction() + { + if ($data = $this->getRequest()->getPost('chatbotuser')) { + try { + $chatbotuser = $this->_initChatbotuser(); + $chatbotuser->addData($data); + $chatbotuser->save(); + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('werules_chatbot')->__('ChatbotUser was successfully saved') + ); + Mage::getSingleton('adminhtml/session')->setFormData(false); + if ($this->getRequest()->getParam('back')) { + $this->_redirect('*/*/edit', array('id' => $chatbotuser->getId())); + return; + } + $this->_redirect('*/*/'); + return; + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + Mage::getSingleton('adminhtml/session')->setChatbotuserData($data); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + return; + } catch (Exception $e) { + Mage::logException($e); + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was a problem saving the chatbotuser.') + ); + Mage::getSingleton('adminhtml/session')->setChatbotuserData($data); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + return; + } + } + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Unable to find chatbotuser to save.') + ); + $this->_redirect('*/*/'); + } + + /** + * delete chatbotuser - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function deleteAction() + { + if ( $this->getRequest()->getParam('id') > 0) { + try { + $chatbotuser = Mage::getModel('werules_chatbot/chatbotuser'); + $chatbotuser->setId($this->getRequest()->getParam('id'))->delete(); + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('werules_chatbot')->__('ChatbotUser was successfully deleted.') + ); + $this->_redirect('*/*/'); + return; + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error deleting chatbotuser.') + ); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + Mage::logException($e); + return; + } + } + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Could not find chatbotuser to delete.') + ); + $this->_redirect('*/*/'); + } + + /** + * mass delete chatbotuser - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function massDeleteAction() + { + $chatbotuserIds = $this->getRequest()->getParam('chatbotuser'); + if (!is_array($chatbotuserIds)) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Please select chatbotusers to delete.') + ); + } else { + try { + foreach ($chatbotuserIds as $chatbotuserId) { + $chatbotuser = Mage::getModel('werules_chatbot/chatbotuser'); + $chatbotuser->setId($chatbotuserId)->delete(); + } + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('werules_chatbot')->__('Total of %d chatbotusers were successfully deleted.', count($chatbotuserIds)) + ); + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error deleting chatbotusers.') + ); + Mage::logException($e); + } + } + $this->_redirect('*/*/index'); + } + + /** + * mass status change - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function massStatusAction() + { + $chatbotuserIds = $this->getRequest()->getParam('chatbotuser'); + if (!is_array($chatbotuserIds)) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Please select chatbotusers.') + ); + } else { + try { + foreach ($chatbotuserIds as $chatbotuserId) { + $chatbotuser = Mage::getSingleton('werules_chatbot/chatbotuser')->load($chatbotuserId) + ->setStatus($this->getRequest()->getParam('status')) + ->setIsMassupdate(true) + ->save(); + } + $this->_getSession()->addSuccess( + $this->__('Total of %d chatbotusers were successfully updated.', count($chatbotuserIds)) + ); + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error updating chatbotusers.') + ); + Mage::logException($e); + } + } + $this->_redirect('*/*/index'); + } + + /** + * mass Enable Promotional Messages change - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function massEnablePromotionalMessagesAction() + { + $chatbotuserIds = $this->getRequest()->getParam('chatbotuser'); + if (!is_array($chatbotuserIds)) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Please select chatbotusers.') + ); + } else { + try { + foreach ($chatbotuserIds as $chatbotuserId) { + $chatbotuser = Mage::getSingleton('werules_chatbot/chatbotuser')->load($chatbotuserId) + ->setEnablePromotionalMessages($this->getRequest()->getParam('flag_enable_promotional_messages')) + ->setIsMassupdate(true) + ->save(); + } + $this->_getSession()->addSuccess( + $this->__('Total of %d chatbotusers were successfully updated.', count($chatbotuserIds)) + ); + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error updating chatbotusers.') + ); + Mage::logException($e); + } + } + $this->_redirect('*/*/index'); + } + + /** + * mass Enable Support change - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function massEnableSupportAction() + { + $chatbotuserIds = $this->getRequest()->getParam('chatbotuser'); + if (!is_array($chatbotuserIds)) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Please select chatbotusers.') + ); + } else { + try { + foreach ($chatbotuserIds as $chatbotuserId) { + $chatbotuser = Mage::getSingleton('werules_chatbot/chatbotuser')->load($chatbotuserId) + ->setEnableSupport($this->getRequest()->getParam('flag_enable_support')) + ->setIsMassupdate(true) + ->save(); + } + $this->_getSession()->addSuccess( + $this->__('Total of %d chatbotusers were successfully updated.', count($chatbotuserIds)) + ); + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error updating chatbotusers.') + ); + Mage::logException($e); + } + } + $this->_redirect('*/*/index'); + } + + /** + * mass Is Admin? change - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function massAdminAction() + { + $chatbotuserIds = $this->getRequest()->getParam('chatbotuser'); + if (!is_array($chatbotuserIds)) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Please select chatbotusers.') + ); + } else { + try { + foreach ($chatbotuserIds as $chatbotuserId) { + $chatbotuser = Mage::getSingleton('werules_chatbot/chatbotuser')->load($chatbotuserId) + ->setAdmin($this->getRequest()->getParam('flag_admin')) + ->setIsMassupdate(true) + ->save(); + } + $this->_getSession()->addSuccess( + $this->__('Total of %d chatbotusers were successfully updated.', count($chatbotuserIds)) + ); + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error updating chatbotusers.') + ); + Mage::logException($e); + } + } + $this->_redirect('*/*/index'); + } + + /** + * export as csv - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function exportCsvAction() + { + $fileName = 'chatbotuser.csv'; + $content = $this->getLayout()->createBlock('werules_chatbot/adminhtml_chatbotuser_grid') + ->getCsv(); + $this->_prepareDownloadResponse($fileName, $content); + } + + /** + * export as MsExcel - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function exportExcelAction() + { + $fileName = 'chatbotuser.xls'; + $content = $this->getLayout()->createBlock('werules_chatbot/adminhtml_chatbotuser_grid') + ->getExcelFile(); + $this->_prepareDownloadResponse($fileName, $content); + } + + /** + * export as xml - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function exportXmlAction() + { + $fileName = 'chatbotuser.xml'; + $content = $this->getLayout()->createBlock('werules_chatbot/adminhtml_chatbotuser_grid') + ->getXml(); + $this->_prepareDownloadResponse($fileName, $content); + } + + /** + * Check if admin has permissions to visit related pages + * + * @access protected + * @return boolean + * @author Ultimate Module Creator + */ + protected function _isAllowed() + { + return Mage::getSingleton('admin/session')->isAllowed('system/config/werules_chatbot/chatbotuser'); + } +} diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/MessageController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/MessageController.php new file mode 100644 index 0000000..6603f78 --- /dev/null +++ b/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/MessageController.php @@ -0,0 +1,329 @@ +getRequest()->getParam('id'); + $message = Mage::getModel('werules_chatbot/message'); + if ($messageId) { + $message->load($messageId); + } + Mage::register('current_message', $message); + return $message; + } + + /** + * default action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function indexAction() + { + $this->loadLayout(); + $this->_title(Mage::helper('werules_chatbot')->__('Chatbot Settings')) + ->_title(Mage::helper('werules_chatbot')->__('Messages')); + $this->renderLayout(); + } + + /** + * grid action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function gridAction() + { + $this->loadLayout()->renderLayout(); + } + + /** + * edit message - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function editAction() + { + $messageId = $this->getRequest()->getParam('id'); + $message = $this->_initMessage(); + if ($messageId && !$message->getId()) { + $this->_getSession()->addError( + Mage::helper('werules_chatbot')->__('This message no longer exists.') + ); + $this->_redirect('*/*/'); + return; + } + $data = Mage::getSingleton('adminhtml/session')->getMessageData(true); + if (!empty($data)) { + $message->setData($data); + } + Mage::register('message_data', $message); + $this->loadLayout(); + $this->_title(Mage::helper('werules_chatbot')->__('Chatbot Settings')) + ->_title(Mage::helper('werules_chatbot')->__('Messages')); + if ($message->getId()) { + $this->_title($message->getMessageId()); + } else { + $this->_title(Mage::helper('werules_chatbot')->__('Add message')); + } + if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { + $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); + } + $this->renderLayout(); + } + + /** + * new message action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function newAction() + { + $this->_forward('edit'); + } + + /** + * save message - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function saveAction() + { + if ($data = $this->getRequest()->getPost('message')) { + try { + $data = $this->_filterDates($data, array('sent_at')); + $message = $this->_initMessage(); + $message->addData($data); + $message->save(); + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('werules_chatbot')->__('Message was successfully saved') + ); + Mage::getSingleton('adminhtml/session')->setFormData(false); + if ($this->getRequest()->getParam('back')) { + $this->_redirect('*/*/edit', array('id' => $message->getId())); + return; + } + $this->_redirect('*/*/'); + return; + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + Mage::getSingleton('adminhtml/session')->setMessageData($data); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + return; + } catch (Exception $e) { + Mage::logException($e); + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was a problem saving the message.') + ); + Mage::getSingleton('adminhtml/session')->setMessageData($data); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + return; + } + } + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Unable to find message to save.') + ); + $this->_redirect('*/*/'); + } + + /** + * delete message - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function deleteAction() + { + if ( $this->getRequest()->getParam('id') > 0) { + try { + $message = Mage::getModel('werules_chatbot/message'); + $message->setId($this->getRequest()->getParam('id'))->delete(); + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('werules_chatbot')->__('Message was successfully deleted.') + ); + $this->_redirect('*/*/'); + return; + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error deleting message.') + ); + $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); + Mage::logException($e); + return; + } + } + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Could not find message to delete.') + ); + $this->_redirect('*/*/'); + } + + /** + * mass delete message - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function massDeleteAction() + { + $messageIds = $this->getRequest()->getParam('message'); + if (!is_array($messageIds)) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Please select messages to delete.') + ); + } else { + try { + foreach ($messageIds as $messageId) { + $message = Mage::getModel('werules_chatbot/message'); + $message->setId($messageId)->delete(); + } + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('werules_chatbot')->__('Total of %d messages were successfully deleted.', count($messageIds)) + ); + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error deleting messages.') + ); + Mage::logException($e); + } + } + $this->_redirect('*/*/index'); + } + + /** + * mass status change - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function massStatusAction() + { + $messageIds = $this->getRequest()->getParam('message'); + if (!is_array($messageIds)) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('Please select messages.') + ); + } else { + try { + foreach ($messageIds as $messageId) { + $message = Mage::getSingleton('werules_chatbot/message')->load($messageId) + ->setStatus($this->getRequest()->getParam('status')) + ->setIsMassupdate(true) + ->save(); + } + $this->_getSession()->addSuccess( + $this->__('Total of %d messages were successfully updated.', count($messageIds)) + ); + } catch (Mage_Core_Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('werules_chatbot')->__('There was an error updating messages.') + ); + Mage::logException($e); + } + } + $this->_redirect('*/*/index'); + } + + /** + * export as csv - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function exportCsvAction() + { + $fileName = 'message.csv'; + $content = $this->getLayout()->createBlock('werules_chatbot/adminhtml_message_grid') + ->getCsv(); + $this->_prepareDownloadResponse($fileName, $content); + } + + /** + * export as MsExcel - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function exportExcelAction() + { + $fileName = 'message.xls'; + $content = $this->getLayout()->createBlock('werules_chatbot/adminhtml_message_grid') + ->getExcelFile(); + $this->_prepareDownloadResponse($fileName, $content); + } + + /** + * export as xml - action + * + * @access public + * @return void + * @author Ultimate Module Creator + */ + public function exportXmlAction() + { + $fileName = 'message.xml'; + $content = $this->getLayout()->createBlock('werules_chatbot/adminhtml_message_grid') + ->getXml(); + $this->_prepareDownloadResponse($fileName, $content); + } + + /** + * Check if admin has permissions to visit related pages + * + * @access protected + * @return boolean + * @author Ultimate Module Creator + */ + protected function _isAllowed() + { + return Mage::getSingleton('admin/session')->isAllowed('system/config/werules_chatbot/message'); + } +} From 5b3f3deadd75370496db33cf2aaca74f57c50b43 Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 14:14:06 -0200 Subject: [PATCH 12/25] fix tabing --- .../Chatbot/Block/Adminhtml/Chatbotapi.php | 44 +++++------ .../Block/Adminhtml/Chatbotapi/Edit.php | 38 +++++----- .../Block/Adminhtml/Chatbotapi/Edit/Form.php | 37 +++++----- .../Adminhtml/Chatbotapi/Edit/Tab/Form.php | 37 +++++----- .../Adminhtml/Chatbotapi/Edit/Tab/Stores.php | 37 +++++----- .../Block/Adminhtml/Chatbotapi/Edit/Tabs.php | 39 +++++----- .../Block/Adminhtml/Chatbotapi/Grid.php | 44 +++++------ .../Chatbot/Block/Adminhtml/Chatbotuser.php | 43 +++++------ .../Block/Adminhtml/Chatbotuser/Edit.php | 38 +++++----- .../Block/Adminhtml/Chatbotuser/Edit/Form.php | 37 +++++----- .../Adminhtml/Chatbotuser/Edit/Tab/Form.php | 37 +++++----- .../Adminhtml/Chatbotuser/Edit/Tab/Stores.php | 37 +++++----- .../Block/Adminhtml/Chatbotuser/Edit/Tabs.php | 39 +++++----- .../Block/Adminhtml/Chatbotuser/Grid.php | 44 +++++------ .../Chatbot/Block/Adminhtml/Message.php | 43 +++++------ .../Chatbot/Block/Adminhtml/Message/Edit.php | 38 +++++----- .../Block/Adminhtml/Message/Edit/Form.php | 37 +++++----- .../Block/Adminhtml/Message/Edit/Tab/Form.php | 37 +++++----- .../Adminhtml/Message/Edit/Tab/Stores.php | 37 +++++----- .../Block/Adminhtml/Message/Edit/Tabs.php | 39 +++++----- .../Chatbot/Block/Adminhtml/Message/Grid.php | 44 +++++------ .../Chatbot/Controller/Adminhtml/Chatbot.php | 37 +++++----- .../community/Werules/Chatbot/Helper/Data.php | 1 - .../Werules/Chatbot/Model/Chatbotapi.php | 8 +- .../Werules/Chatbot/Model/Chatbotuser.php | 8 +- .../Werules/Chatbot/Model/Message.php | 8 +- .../Chatbot/Model/Resource/Chatbotapi.php | 8 +- .../Model/Resource/Chatbotapi/Collection.php | 12 +-- .../Chatbot/Model/Resource/Chatbotuser.php | 8 +- .../Model/Resource/Chatbotuser/Collection.php | 12 +-- .../Chatbot/Model/Resource/Message.php | 8 +- .../Model/Resource/Message/Collection.php | 12 +-- .../Werules/Chatbot/Model/Resource/Setup.php | 36 +++++---- .../Chatbot/ChatbotapiController.php | 64 ++++++++-------- .../Chatbot/ChatbotuserController.php | 66 ++++++++--------- .../Adminhtml/Chatbot/MessageController.php | 59 +++++++-------- .../Werules/Chatbot/etc/adminhtml.xml | 2 - Magento1/js/werules/chatbot/chatbot.js | 74 +++++++++---------- 38 files changed, 570 insertions(+), 679 deletions(-) diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php index 227d3d3..a792069 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotapi extends Mage_Adminhtml_Block_Widget_Grid_Container { /** @@ -28,15 +26,13 @@ class Werules_Chatbot_Block_Adminhtml_Chatbotapi extends Mage_Adminhtml_Block_Wi * * @access public * @return void - * @author Ultimate Module Creator */ public function __construct() { - $this->_controller = 'adminhtml_chatbotapi'; - $this->_blockGroup = 'werules_chatbot'; + $this->_controller = 'adminhtml_chatbotapi'; + $this->_blockGroup = 'werules_chatbot'; parent::__construct(); - $this->_headerText = Mage::helper('werules_chatbot')->__('ChatbotAPI'); + $this->_headerText = Mage::helper('werules_chatbot')->__('ChatbotAPI'); $this->_updateButton('add', 'label', Mage::helper('werules_chatbot')->__('Add ChatbotAPI')); - } } diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit.php index a62c9e7..35feaac 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit extends Mage_Adminhtml_Block_Widget_Form_Container { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit extends Mage_Adminhtml_Blo * * @access public * @return void - * @author Ultimate Module Creator */ public function __construct() { @@ -66,7 +63,6 @@ function saveAndContinueEdit() { * * @access public * @return string - * @author Ultimate Module Creator */ public function getHeaderText() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Form.php index 055238f..f4223c7 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Form.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Form.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Form extends Mage_Adminhtml_Block_Widget_Form { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Form extends Mage_Adminhtm * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Form - * @author Ultimate Module Creator */ protected function _prepareForm() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Form.php index 0ab33a9..adbed3d 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Form.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Form.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Tab_Form extends Mage_Admi * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Tab_Form - * @author Ultimate Module Creator */ protected function _prepareForm() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Stores.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Stores.php index 526e1f3..2b9af92 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Stores.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Stores.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Tab_Stores extends Mage_Ad * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Tab_Stores - * @author Ultimate Module Creator */ protected function _prepareForm() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tabs.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tabs.php index 54297c3..9392a98 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tabs.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tabs.php @@ -1,33 +1,30 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs { /** * Initialize Tabs * * @access public - * @author Ultimate Module Creator */ public function __construct() { @@ -42,7 +39,6 @@ public function __construct() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Edit_Tabs - * @author Ultimate Module Creator */ protected function _beforeToHtml() { @@ -78,7 +74,6 @@ protected function _beforeToHtml() * * @access public * @return Werules_Chatbot_Model_Chatbotapi - * @author Ultimate Module Creator */ public function getChatbotapi() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Grid.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Grid.php index ce9f2e1..e55d26e 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Grid.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi/Grid.php @@ -1,33 +1,30 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotapi_Grid extends Mage_Adminhtml_Block_Widget_Grid { /** * constructor * * @access public - * @author Ultimate Module Creator */ public function __construct() { @@ -44,7 +41,6 @@ public function __construct() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Grid - * @author Ultimate Module Creator */ protected function _prepareCollection() { @@ -60,7 +56,6 @@ protected function _prepareCollection() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Grid - * @author Ultimate Module Creator */ protected function _prepareColumns() { @@ -244,7 +239,6 @@ protected function _prepareColumns() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Grid - * @author Ultimate Module Creator */ protected function _prepareMassaction() { @@ -326,7 +320,6 @@ protected function _prepareMassaction() * @access public * @param Werules_Chatbot_Model_Chatbotapi * @return string - * @author Ultimate Module Creator */ public function getRowUrl($row) { @@ -338,7 +331,6 @@ public function getRowUrl($row) * * @access public * @return string - * @author Ultimate Module Creator */ public function getGridUrl() { @@ -350,7 +342,6 @@ public function getGridUrl() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Grid - * @author Ultimate Module Creator */ protected function _afterLoadCollection() { @@ -365,7 +356,6 @@ protected function _afterLoadCollection() * @param Werules_Chatbot_Model_Resource_Chatbotapi_Collection $collection * @param Mage_Adminhtml_Block_Widget_Grid_Column $column * @return Werules_Chatbot_Block_Adminhtml_Chatbotapi_Grid - * @author Ultimate Module Creator */ protected function _filterStoreCondition($collection, $column) { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser.php index d898e30..7f4f0d2 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotuser extends Mage_Adminhtml_Block_Widget_Grid_Container { /** @@ -28,14 +26,13 @@ class Werules_Chatbot_Block_Adminhtml_Chatbotuser extends Mage_Adminhtml_Block_W * * @access public * @return void - * @author Ultimate Module Creator */ public function __construct() { - $this->_controller = 'adminhtml_chatbotuser'; - $this->_blockGroup = 'werules_chatbot'; + $this->_controller = 'adminhtml_chatbotuser'; + $this->_blockGroup = 'werules_chatbot'; parent::__construct(); - $this->_headerText = Mage::helper('werules_chatbot')->__('ChatbotUser'); + $this->_headerText = Mage::helper('werules_chatbot')->__('ChatbotUser'); $this->_updateButton('add', 'label', Mage::helper('werules_chatbot')->__('Add ChatbotUser')); } diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit.php index 8c09430..57efe7d 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit extends Mage_Adminhtml_Block_Widget_Form_Container { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit extends Mage_Adminhtml_Bl * * @access public * @return void - * @author Ultimate Module Creator */ public function __construct() { @@ -66,7 +63,6 @@ function saveAndContinueEdit() { * * @access public * @return string - * @author Ultimate Module Creator */ public function getHeaderText() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Form.php index e4765e4..b4bba91 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Form.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Form.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Form extends Mage_Adminhtml_Block_Widget_Form { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Form extends Mage_Adminht * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Form - * @author Ultimate Module Creator */ protected function _prepareForm() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Form.php index 4e0fe6f..c51ddfc 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Form.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Form.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Tab_Form extends Mage_Adm * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Tab_Form - * @author Ultimate Module Creator */ protected function _prepareForm() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Stores.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Stores.php index 48a70d3..923501b 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Stores.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Stores.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Tab_Stores extends Mage_A * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Tab_Stores - * @author Ultimate Module Creator */ protected function _prepareForm() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tabs.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tabs.php index 6b792f4..791fd0e 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tabs.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tabs.php @@ -1,33 +1,30 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs { /** * Initialize Tabs * * @access public - * @author Ultimate Module Creator */ public function __construct() { @@ -42,7 +39,6 @@ public function __construct() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Edit_Tabs - * @author Ultimate Module Creator */ protected function _beforeToHtml() { @@ -78,7 +74,6 @@ protected function _beforeToHtml() * * @access public * @return Werules_Chatbot_Model_Chatbotuser - * @author Ultimate Module Creator */ public function getChatbotuser() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Grid.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Grid.php index a23290e..97d0f23 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Grid.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotuser/Grid.php @@ -1,33 +1,30 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Chatbotuser_Grid extends Mage_Adminhtml_Block_Widget_Grid { /** * constructor * * @access public - * @author Ultimate Module Creator */ public function __construct() { @@ -44,7 +41,6 @@ public function __construct() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Grid - * @author Ultimate Module Creator */ protected function _prepareCollection() { @@ -60,7 +56,6 @@ protected function _prepareCollection() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Grid - * @author Ultimate Module Creator */ protected function _prepareColumns() { @@ -203,7 +198,6 @@ protected function _prepareColumns() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Grid - * @author Ultimate Module Creator */ protected function _prepareMassaction() { @@ -305,7 +299,6 @@ protected function _prepareMassaction() * @access public * @param Werules_Chatbot_Model_Chatbotuser * @return string - * @author Ultimate Module Creator */ public function getRowUrl($row) { @@ -317,7 +310,6 @@ public function getRowUrl($row) * * @access public * @return string - * @author Ultimate Module Creator */ public function getGridUrl() { @@ -329,7 +321,6 @@ public function getGridUrl() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Grid - * @author Ultimate Module Creator */ protected function _afterLoadCollection() { @@ -344,7 +335,6 @@ protected function _afterLoadCollection() * @param Werules_Chatbot_Model_Resource_Chatbotuser_Collection $collection * @param Mage_Adminhtml_Block_Widget_Grid_Column $column * @return Werules_Chatbot_Block_Adminhtml_Chatbotuser_Grid - * @author Ultimate Module Creator */ protected function _filterStoreCondition($collection, $column) { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message.php index 06f8e00..d933d13 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Message extends Mage_Adminhtml_Block_Widget_Grid_Container { /** @@ -28,14 +26,13 @@ class Werules_Chatbot_Block_Adminhtml_Message extends Mage_Adminhtml_Block_Widge * * @access public * @return void - * @author Ultimate Module Creator */ public function __construct() { - $this->_controller = 'adminhtml_message'; - $this->_blockGroup = 'werules_chatbot'; + $this->_controller = 'adminhtml_message'; + $this->_blockGroup = 'werules_chatbot'; parent::__construct(); - $this->_headerText = Mage::helper('werules_chatbot')->__('Message'); + $this->_headerText = Mage::helper('werules_chatbot')->__('Message'); $this->_updateButton('add', 'label', Mage::helper('werules_chatbot')->__('Add Message')); } diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit.php index 68e4aec..12d171c 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Message_Edit extends Mage_Adminhtml_Block_Widget_Form_Container { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Message_Edit extends Mage_Adminhtml_Block_ * * @access public * @return void - * @author Ultimate Module Creator */ public function __construct() { @@ -66,7 +63,6 @@ function saveAndContinueEdit() { * * @access public * @return string - * @author Ultimate Module Creator */ public function getHeaderText() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Form.php index 9ae4cd6..aecc609 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Form.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Form.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Message_Edit_Form extends Mage_Adminhtml_Block_Widget_Form { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Message_Edit_Form extends Mage_Adminhtml_B * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Message_Edit_Form - * @author Ultimate Module Creator */ protected function _prepareForm() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Form.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Form.php index af1fb04..5514c29 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Form.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Form.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Message_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Message_Edit_Tab_Form extends Mage_Adminht * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Message_Edit_Tab_Form - * @author Ultimate Module Creator */ protected function _prepareForm() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Stores.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Stores.php index 312ed26..e6bedf3 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Stores.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Stores.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Message_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form { /** @@ -28,7 +26,6 @@ class Werules_Chatbot_Block_Adminhtml_Message_Edit_Tab_Stores extends Mage_Admin * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Message_Edit_Tab_Stores - * @author Ultimate Module Creator */ protected function _prepareForm() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tabs.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tabs.php index 9796475..6dfe66d 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tabs.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Edit/Tabs.php @@ -1,33 +1,30 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Message_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs { /** * Initialize Tabs * * @access public - * @author Ultimate Module Creator */ public function __construct() { @@ -42,7 +39,6 @@ public function __construct() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Message_Edit_Tabs - * @author Ultimate Module Creator */ protected function _beforeToHtml() { @@ -78,7 +74,6 @@ protected function _beforeToHtml() * * @access public * @return Werules_Chatbot_Model_Message - * @author Ultimate Module Creator */ public function getMessage() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php index 254c20f..be5dc0c 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php @@ -1,33 +1,30 @@ . */ + class Werules_Chatbot_Block_Adminhtml_Message_Grid extends Mage_Adminhtml_Block_Widget_Grid { /** * constructor * * @access public - * @author Ultimate Module Creator */ public function __construct() { @@ -44,7 +41,6 @@ public function __construct() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Message_Grid - * @author Ultimate Module Creator */ protected function _prepareCollection() { @@ -60,7 +56,6 @@ protected function _prepareCollection() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Message_Grid - * @author Ultimate Module Creator */ protected function _prepareColumns() { @@ -245,7 +240,6 @@ protected function _prepareColumns() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Message_Grid - * @author Ultimate Module Creator */ protected function _prepareMassaction() { @@ -287,7 +281,6 @@ protected function _prepareMassaction() * @access public * @param Werules_Chatbot_Model_Message * @return string - * @author Ultimate Module Creator */ public function getRowUrl($row) { @@ -299,7 +292,6 @@ public function getRowUrl($row) * * @access public * @return string - * @author Ultimate Module Creator */ public function getGridUrl() { @@ -311,7 +303,6 @@ public function getGridUrl() * * @access protected * @return Werules_Chatbot_Block_Adminhtml_Message_Grid - * @author Ultimate Module Creator */ protected function _afterLoadCollection() { @@ -326,7 +317,6 @@ protected function _afterLoadCollection() * @param Werules_Chatbot_Model_Resource_Message_Collection $collection * @param Mage_Adminhtml_Block_Widget_Grid_Column $column * @return Werules_Chatbot_Block_Adminhtml_Message_Grid - * @author Ultimate Module Creator */ protected function _filterStoreCondition($collection, $column) { diff --git a/Magento1/app/code/community/Werules/Chatbot/Controller/Adminhtml/Chatbot.php b/Magento1/app/code/community/Werules/Chatbot/Controller/Adminhtml/Chatbot.php index 68350d1..09a0956 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Controller/Adminhtml/Chatbot.php +++ b/Magento1/app/code/community/Werules/Chatbot/Controller/Adminhtml/Chatbot.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Controller_Adminhtml_Chatbot extends Mage_Adminhtml_Controller_Action { /** @@ -31,7 +29,6 @@ class Werules_Chatbot_Controller_Adminhtml_Chatbot extends Mage_Adminhtml_Contro * @param string $destinationFolder * @param array $data * @return string - * @author Ultimate Module Creator */ protected function _uploadAndGetName($input, $destinationFolder, $data) { diff --git a/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php b/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php index e4ae5c8..8ce0de0 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php +++ b/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php @@ -27,7 +27,6 @@ class Werules_Chatbot_Helper_Data extends Mage_Core_Helper_Abstract * @access public * @param $options * @return array - * @author Ultimate Module Creator */ public function convertOptions($options) { diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php index d1fd6b4..f447e66 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php @@ -47,7 +47,7 @@ class Werules_Chatbot_Model_Chatbotapi extends Mage_Core_Model_Abstract * * @access public * @return void - * @author Ultimate Module Creator + */ public function _construct() { @@ -60,7 +60,7 @@ public function _construct() * * @access protected * @return Werules_Chatbot_Model_Chatbotapi - * @author Ultimate Module Creator + */ protected function _beforeSave() { @@ -78,7 +78,7 @@ protected function _beforeSave() * * @access public * @return Werules_Chatbot_Model_Chatbotapi - * @author Ultimate Module Creator + */ protected function _afterSave() { @@ -90,7 +90,7 @@ protected function _afterSave() * * @access public * @return array - * @author Ultimate Module Creator + */ public function getDefaultValues() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php index b9c5a8e..697931e 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotuser.php @@ -47,7 +47,7 @@ class Werules_Chatbot_Model_Chatbotuser extends Mage_Core_Model_Abstract * * @access public * @return void - * @author Ultimate Module Creator + */ public function _construct() { @@ -60,7 +60,7 @@ public function _construct() * * @access protected * @return Werules_Chatbot_Model_Chatbotuser - * @author Ultimate Module Creator + */ protected function _beforeSave() { @@ -78,7 +78,7 @@ protected function _beforeSave() * * @access public * @return Werules_Chatbot_Model_Chatbotuser - * @author Ultimate Module Creator + */ protected function _afterSave() { @@ -90,7 +90,7 @@ protected function _afterSave() * * @access public * @return array - * @author Ultimate Module Creator + */ public function getDefaultValues() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Message.php b/Magento1/app/code/community/Werules/Chatbot/Model/Message.php index c1815cd..f07f4b8 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Message.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Message.php @@ -47,7 +47,7 @@ class Werules_Chatbot_Model_Message extends Mage_Core_Model_Abstract * * @access public * @return void - * @author Ultimate Module Creator + */ public function _construct() { @@ -60,7 +60,7 @@ public function _construct() * * @access protected * @return Werules_Chatbot_Model_Message - * @author Ultimate Module Creator + */ protected function _beforeSave() { @@ -78,7 +78,7 @@ protected function _beforeSave() * * @access public * @return Werules_Chatbot_Model_Message - * @author Ultimate Module Creator + */ protected function _afterSave() { @@ -90,7 +90,7 @@ protected function _afterSave() * * @access public * @return array - * @author Ultimate Module Creator + */ public function getDefaultValues() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi.php index bef30b2..47b4250 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi.php @@ -26,7 +26,7 @@ class Werules_Chatbot_Model_Resource_Chatbotapi extends Mage_Core_Model_Resource * constructor * * @access public - * @author Ultimate Module Creator + */ public function _construct() { @@ -39,7 +39,7 @@ public function _construct() * @access public * @param int $chatbotapiId * @return array - * @author Ultimate Module Creator + */ public function lookupStoreIds($chatbotapiId) { @@ -56,7 +56,7 @@ public function lookupStoreIds($chatbotapiId) * @access public * @param Mage_Core_Model_Abstract $object * @return Werules_Chatbot_Model_Resource_Chatbotapi - * @author Ultimate Module Creator + */ protected function _afterLoad(Mage_Core_Model_Abstract $object) { @@ -98,7 +98,7 @@ protected function _getLoadSelect($field, $value, $object) * @access protected * @param Mage_Core_Model_Abstract $object * @return Werules_Chatbot_Model_Resource_Chatbotapi - * @author Ultimate Module Creator + */ protected function _afterSave(Mage_Core_Model_Abstract $object) { diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi/Collection.php index 0418d7c..37ac6a9 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi/Collection.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotapi/Collection.php @@ -28,7 +28,7 @@ class Werules_Chatbot_Model_Resource_Chatbotapi_Collection extends Mage_Core_Mod * * @access public * @return void - * @author Ultimate Module Creator + */ protected function _construct() { @@ -44,7 +44,7 @@ protected function _construct() * @param int|Mage_Core_Model_Store $store * @param bool $withAdmin * @return Werules_Chatbot_Model_Resource_Chatbotapi_Collection - * @author Ultimate Module Creator + */ public function addStoreFilter($store, $withAdmin = true) { @@ -69,7 +69,7 @@ public function addStoreFilter($store, $withAdmin = true) * * @access protected * @return Werules_Chatbot_Model_Resource_Chatbotapi_Collection - * @author Ultimate Module Creator + */ protected function _renderFiltersBefore() { @@ -96,7 +96,7 @@ protected function _renderFiltersBefore() * @param string $labelField * @param array $additional * @return array - * @author Ultimate Module Creator + */ protected function _toOptionArray($valueField='entity_id', $labelField='chatbotapi_id', $additional=array()) { @@ -110,7 +110,7 @@ protected function _toOptionArray($valueField='entity_id', $labelField='chatbota * @param string $valueField * @param string $labelField * @return array - * @author Ultimate Module Creator + */ protected function _toOptionHash($valueField='entity_id', $labelField='chatbotapi_id') { @@ -123,7 +123,7 @@ protected function _toOptionHash($valueField='entity_id', $labelField='chatbotap * * @access public * @return Varien_Db_Select - * @author Ultimate Module Creator + */ public function getSelectCountSql() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser.php index c9bcf38..cff754c 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser.php @@ -26,7 +26,7 @@ class Werules_Chatbot_Model_Resource_Chatbotuser extends Mage_Core_Model_Resourc * constructor * * @access public - * @author Ultimate Module Creator + */ public function _construct() { @@ -39,7 +39,7 @@ public function _construct() * @access public * @param int $chatbotuserId * @return array - * @author Ultimate Module Creator + */ public function lookupStoreIds($chatbotuserId) { @@ -56,7 +56,7 @@ public function lookupStoreIds($chatbotuserId) * @access public * @param Mage_Core_Model_Abstract $object * @return Werules_Chatbot_Model_Resource_Chatbotuser - * @author Ultimate Module Creator + */ protected function _afterLoad(Mage_Core_Model_Abstract $object) { @@ -98,7 +98,7 @@ protected function _getLoadSelect($field, $value, $object) * @access protected * @param Mage_Core_Model_Abstract $object * @return Werules_Chatbot_Model_Resource_Chatbotuser - * @author Ultimate Module Creator + */ protected function _afterSave(Mage_Core_Model_Abstract $object) { diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser/Collection.php index afcf085..8879918 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser/Collection.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Chatbotuser/Collection.php @@ -28,7 +28,7 @@ class Werules_Chatbot_Model_Resource_Chatbotuser_Collection extends Mage_Core_Mo * * @access public * @return void - * @author Ultimate Module Creator + */ protected function _construct() { @@ -44,7 +44,7 @@ protected function _construct() * @param int|Mage_Core_Model_Store $store * @param bool $withAdmin * @return Werules_Chatbot_Model_Resource_Chatbotuser_Collection - * @author Ultimate Module Creator + */ public function addStoreFilter($store, $withAdmin = true) { @@ -69,7 +69,7 @@ public function addStoreFilter($store, $withAdmin = true) * * @access protected * @return Werules_Chatbot_Model_Resource_Chatbotuser_Collection - * @author Ultimate Module Creator + */ protected function _renderFiltersBefore() { @@ -96,7 +96,7 @@ protected function _renderFiltersBefore() * @param string $labelField * @param array $additional * @return array - * @author Ultimate Module Creator + */ protected function _toOptionArray($valueField='entity_id', $labelField='chatbotuser_id', $additional=array()) { @@ -110,7 +110,7 @@ protected function _toOptionArray($valueField='entity_id', $labelField='chatbotu * @param string $valueField * @param string $labelField * @return array - * @author Ultimate Module Creator + */ protected function _toOptionHash($valueField='entity_id', $labelField='chatbotuser_id') { @@ -123,7 +123,7 @@ protected function _toOptionHash($valueField='entity_id', $labelField='chatbotus * * @access public * @return Varien_Db_Select - * @author Ultimate Module Creator + */ public function getSelectCountSql() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message.php index 2b8294b..f9a3073 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message.php @@ -26,7 +26,7 @@ class Werules_Chatbot_Model_Resource_Message extends Mage_Core_Model_Resource_Db * constructor * * @access public - * @author Ultimate Module Creator + */ public function _construct() { @@ -39,7 +39,7 @@ public function _construct() * @access public * @param int $messageId * @return array - * @author Ultimate Module Creator + */ public function lookupStoreIds($messageId) { @@ -56,7 +56,7 @@ public function lookupStoreIds($messageId) * @access public * @param Mage_Core_Model_Abstract $object * @return Werules_Chatbot_Model_Resource_Message - * @author Ultimate Module Creator + */ protected function _afterLoad(Mage_Core_Model_Abstract $object) { @@ -98,7 +98,7 @@ protected function _getLoadSelect($field, $value, $object) * @access protected * @param Mage_Core_Model_Abstract $object * @return Werules_Chatbot_Model_Resource_Message - * @author Ultimate Module Creator + */ protected function _afterSave(Mage_Core_Model_Abstract $object) { diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message/Collection.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message/Collection.php index 2f2adf0..1edbe89 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message/Collection.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Message/Collection.php @@ -28,7 +28,7 @@ class Werules_Chatbot_Model_Resource_Message_Collection extends Mage_Core_Model_ * * @access public * @return void - * @author Ultimate Module Creator + */ protected function _construct() { @@ -44,7 +44,7 @@ protected function _construct() * @param int|Mage_Core_Model_Store $store * @param bool $withAdmin * @return Werules_Chatbot_Model_Resource_Message_Collection - * @author Ultimate Module Creator + */ public function addStoreFilter($store, $withAdmin = true) { @@ -69,7 +69,7 @@ public function addStoreFilter($store, $withAdmin = true) * * @access protected * @return Werules_Chatbot_Model_Resource_Message_Collection - * @author Ultimate Module Creator + */ protected function _renderFiltersBefore() { @@ -96,7 +96,7 @@ protected function _renderFiltersBefore() * @param string $labelField * @param array $additional * @return array - * @author Ultimate Module Creator + */ protected function _toOptionArray($valueField='entity_id', $labelField='message_id', $additional=array()) { @@ -110,7 +110,7 @@ protected function _toOptionArray($valueField='entity_id', $labelField='message_ * @param string $valueField * @param string $labelField * @return array - * @author Ultimate Module Creator + */ protected function _toOptionHash($valueField='entity_id', $labelField='message_id') { @@ -123,7 +123,7 @@ protected function _toOptionHash($valueField='entity_id', $labelField='message_i * * @access public * @return Varien_Db_Select - * @author Ultimate Module Creator + */ public function getSelectCountSql() { diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Setup.php b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Setup.php index b7026ed..1092206 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Setup.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Resource/Setup.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup { } diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotapiController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotapiController.php index bc05644..114df14 100644 --- a/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotapiController.php +++ b/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotapiController.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Adminhtml_Chatbot_ChatbotapiController extends Werules_Chatbot_Controller_Adminhtml_Chatbot { /** @@ -45,7 +43,7 @@ protected function _initChatbotapi() * * @access public * @return void - * @author Ultimate Module Creator + */ public function indexAction() { @@ -60,7 +58,7 @@ public function indexAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function gridAction() { @@ -72,7 +70,7 @@ public function gridAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function editAction() { @@ -109,7 +107,7 @@ public function editAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function newAction() { @@ -121,7 +119,7 @@ public function newAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function saveAction() { @@ -166,7 +164,7 @@ public function saveAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function deleteAction() { @@ -202,7 +200,7 @@ public function deleteAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function massDeleteAction() { @@ -237,7 +235,7 @@ public function massDeleteAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function massStatusAction() { @@ -274,7 +272,7 @@ public function massStatusAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function massLoggedAction() { @@ -311,7 +309,7 @@ public function massLoggedAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function massEnabledAction() { @@ -348,7 +346,7 @@ public function massEnabledAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function exportCsvAction() { @@ -363,7 +361,7 @@ public function exportCsvAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function exportExcelAction() { @@ -378,7 +376,7 @@ public function exportExcelAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function exportXmlAction() { @@ -393,7 +391,7 @@ public function exportXmlAction() * * @access protected * @return boolean - * @author Ultimate Module Creator + */ protected function _isAllowed() { diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotuserController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotuserController.php index 6c38883..245e1eb 100644 --- a/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotuserController.php +++ b/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/ChatbotuserController.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Adminhtml_Chatbot_ChatbotuserController extends Werules_Chatbot_Controller_Adminhtml_Chatbot { /** @@ -45,7 +43,7 @@ protected function _initChatbotuser() * * @access public * @return void - * @author Ultimate Module Creator + */ public function indexAction() { @@ -60,7 +58,7 @@ public function indexAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function gridAction() { @@ -72,7 +70,7 @@ public function gridAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function editAction() { @@ -109,7 +107,7 @@ public function editAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function newAction() { @@ -121,7 +119,7 @@ public function newAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function saveAction() { @@ -166,7 +164,7 @@ public function saveAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function deleteAction() { @@ -202,7 +200,7 @@ public function deleteAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function massDeleteAction() { @@ -237,7 +235,7 @@ public function massDeleteAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function massStatusAction() { @@ -274,7 +272,7 @@ public function massStatusAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function massEnablePromotionalMessagesAction() { @@ -311,7 +309,7 @@ public function massEnablePromotionalMessagesAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function massEnableSupportAction() { @@ -348,7 +346,7 @@ public function massEnableSupportAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function massAdminAction() { @@ -385,7 +383,7 @@ public function massAdminAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function exportCsvAction() { @@ -400,7 +398,7 @@ public function exportCsvAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function exportExcelAction() { @@ -415,7 +413,7 @@ public function exportExcelAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function exportXmlAction() { @@ -430,7 +428,7 @@ public function exportXmlAction() * * @access protected * @return boolean - * @author Ultimate Module Creator + */ protected function _isAllowed() { diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/MessageController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/MessageController.php index 6603f78..b84899e 100644 --- a/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/MessageController.php +++ b/Magento1/app/code/community/Werules/Chatbot/controllers/Adminhtml/Chatbot/MessageController.php @@ -1,26 +1,24 @@ . */ + class Werules_Chatbot_Adminhtml_Chatbot_MessageController extends Werules_Chatbot_Controller_Adminhtml_Chatbot { /** @@ -45,7 +43,6 @@ protected function _initMessage() * * @access public * @return void - * @author Ultimate Module Creator */ public function indexAction() { @@ -60,7 +57,7 @@ public function indexAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function gridAction() { @@ -72,7 +69,7 @@ public function gridAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function editAction() { @@ -109,7 +106,7 @@ public function editAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function newAction() { @@ -121,7 +118,7 @@ public function newAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function saveAction() { @@ -167,7 +164,7 @@ public function saveAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function deleteAction() { @@ -203,7 +200,7 @@ public function deleteAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function massDeleteAction() { @@ -238,7 +235,7 @@ public function massDeleteAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function massStatusAction() { @@ -275,7 +272,7 @@ public function massStatusAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function exportCsvAction() { @@ -290,7 +287,7 @@ public function exportCsvAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function exportExcelAction() { @@ -305,7 +302,7 @@ public function exportExcelAction() * * @access public * @return void - * @author Ultimate Module Creator + */ public function exportXmlAction() { @@ -320,7 +317,7 @@ public function exportXmlAction() * * @access protected * @return boolean - * @author Ultimate Module Creator + */ protected function _isAllowed() { diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml index 82c868c..37b4c4e 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml @@ -40,7 +40,6 @@ - @@ -75,6 +74,5 @@ - diff --git a/Magento1/js/werules/chatbot/chatbot.js b/Magento1/js/werules/chatbot/chatbot.js index d78765f..28a42ed 100644 --- a/Magento1/js/werules/chatbot/chatbot.js +++ b/Magento1/js/werules/chatbot/chatbot.js @@ -1,50 +1,50 @@ // display/hide match mode function werulesTogleMatchMode(element) { - //debugger; - var val = element.value; - var name = element.name; - name = name.substr(0, name.lastIndexOf("[")) + "[similarity]"; - var target = document.getElementsByName(name); - if (val === 0) - target[0].disabled = false; - else - target[0].disabled = true; + //debugger; + var val = element.value; + var name = element.name; + name = name.substr(0, name.lastIndexOf("[")) + "[similarity]"; + var target = document.getElementsByName(name); + if (val === 0) + target[0].disabled = false; + else + target[0].disabled = true; } function werulesTogleEnable(element) { - //debugger; - // var val = element.value; - // var name = element.name; - // if (val == 0) - // { - // name = name.substr(0, name.lastIndexOf("[")) + "[similarity]"; - // var target = document.getElementsByName(name); - // target[0].disabled = false; - // } - // else - // { - // name = name.substr(0, name.lastIndexOf("[")) + "[similarity]"; - // var target = document.getElementsByName(name); - // target[0].disabled = true; - // } + //debugger; + // var val = element.value; + // var name = element.name; + // if (val == 0) + // { + // name = name.substr(0, name.lastIndexOf("[")) + "[similarity]"; + // var target = document.getElementsByName(name); + // target[0].disabled = false; + // } + // else + // { + // name = name.substr(0, name.lastIndexOf("[")) + "[similarity]"; + // var target = document.getElementsByName(name); + // target[0].disabled = true; + // } } // display/hide reply mode function werulesTogleReplyMode(element) { - //debugger; - var val = element.value; - var name = element.name; - name = name.substr(0, name.lastIndexOf("[")) + "[command_id]"; - var target = document.getElementsByName(name); - if (val === 0) - target[0].disabled = true; - else - { - //target[0].classList.remove("werules-disabled"); - //target[0].style = ""; - target[0].disabled = false; - } + //debugger; + var val = element.value; + var name = element.name; + name = name.substr(0, name.lastIndexOf("[")) + "[command_id]"; + var target = document.getElementsByName(name); + if (val === 0) + target[0].disabled = true; + else + { + //target[0].classList.remove("werules-disabled"); + //target[0].style = ""; + target[0].disabled = false; + } } \ No newline at end of file From 1604edc18cc6b74530d3534e7e35de5517422b83 Mon Sep 17 00:00:00 2001 From: blopa Date: Sat, 30 Dec 2017 19:43:28 -0200 Subject: [PATCH 13/25] fix helper call --- .../Werules/Chatbot/etc/adminhtml.xml | 156 +++++++++--------- .../community/Werules/Chatbot/etc/system.xml | 8 +- 2 files changed, 82 insertions(+), 82 deletions(-) diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml index 37b4c4e..3ae9b7d 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml @@ -1,78 +1,78 @@ - - - - - - - - - - - - Chatbot - - - - - - - - - - - Chatbot Settings - - - Message - 0 - - - ChatbotUser - 10 - - - ChatbotAPI - 20 - - - - - - - - - - - - - - - - - - Chatbot Settings - 10 - - - Message - adminhtml/chatbot_message - 0 - - - ChatbotUser - adminhtml/chatbot_chatbotuser - 10 - - - ChatbotAPI - adminhtml/chatbot_chatbotapi - 20 - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml index 2f8738e..de2450a 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml @@ -1,13 +1,13 @@ - + 0 - + werules_chatbot text @@ -38,7 +38,7 @@ - + werules_chatbot text @@ -69,7 +69,7 @@ - + werules_chatbot text From ace6202aa8b89f28ed0d1a801539a3717b570e90 Mon Sep 17 00:00:00 2001 From: blopa Date: Sat, 30 Dec 2017 21:39:07 -0200 Subject: [PATCH 14/25] sort order --- .../Werules/Chatbot/etc/adminhtml.xml | 103 ++++++++++-------- .../community/Werules/Chatbot/etc/system.xml | 64 +++++------ 2 files changed, 88 insertions(+), 79 deletions(-) diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml index 3ae9b7d..acef8d6 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/adminhtml.xml @@ -1,49 +1,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + Chatbot + + + General Settings + + + Messenger Settings + + + Danger Zone + + + + + + + + + + + Chatbot Settings + + + Message + 0 + + + ChatbotUser + 10 + + + ChatbotAPI + 20 + + + + + + + + + + + @@ -75,4 +84,4 @@ - + diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml index de2450a..da8771c 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml @@ -3,41 +3,10 @@ - 0 + 50 - - - werules_chatbot - text - 2 - 1 - 1 - 1 - - - - text - 2 - 1 - 1 - 1 - - - - select - adminhtml/system_config_source_enabledisable - 0 - 1 - 1 - 1 - Clear message pending list. After changing this value and saving, a process to clear message pending list will be schedule for the next minute. - - - - - werules_chatbot @@ -100,5 +69,36 @@ + + + werules_chatbot + text + 2 + 1 + 1 + 1 + + + + text + 2 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_enabledisable + 0 + 1 + 1 + 1 + Clear message pending list. After changing this value and saving, a process to clear message pending list will be schedule for the next minute. + + + + + From f38d92dcf51b07bb6cadde8d7b1c994e0803daf3 Mon Sep 17 00:00:00 2001 From: blopa Date: Sat, 30 Dec 2017 21:53:26 -0200 Subject: [PATCH 15/25] add general settings --- .../community/Werules/Chatbot/etc/system.xml | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml index da8771c..bc7401a 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml @@ -18,6 +18,10 @@ + Magento Chatbot v1.0.0 +

To use this module you'll have to use SSL in your store.

+ ]]>
text 0 1 @@ -34,6 +38,58 @@ 1 Enable module. + + + text + 1 + 1 + 1 + 1 + validate-alphanum + This is Your Custom Secret Key Used For The Webhook URL, to Activate/Deactivate The API Webhook For Telegram, And to Use as Your Challenge Hub For Facebook. Alphanumeric Only! Access http://(YOUR_STORE_URL)/chatbot/chatdata/(API)/webhook/(YOUR_CUSTOM_KEY) to Set The Webhook, change API to "telegram" or "facebook". + + + + select + adminhtml/system_config_source_yesno + 2 + 1 + 1 + 1 + Enable listing of categories with no products or unallowed products (this module supports only simple products for now). + + + + + + + select + adminhtml/system_config_source_yesno + 4 + 1 + 1 + 1 + Log will be at root/var/log/. + + + + select + adminhtml/system_config_source_yesno + 5 + 1 + 1 + 1 + Enable wit.ai Natural Language Processor. + + + + text + 6 + 1 + 1 + 1 + wit.ai Server Access Token. +
From bbb9dfbc1dd94ba4ac5eda064446f73b35d2792c Mon Sep 17 00:00:00 2001 From: blopa Date: Sat, 30 Dec 2017 21:58:39 -0200 Subject: [PATCH 16/25] add danger zone --- .../community/Werules/Chatbot/etc/system.xml | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml index bc7401a..ed234c1 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml @@ -121,6 +121,28 @@ 1 Enable Messenger bot. + + + + + + + + + + + + + + + + + + + + + + @@ -136,6 +158,15 @@ + Magento Chatbot v1.0.0 +

To use this module you'll have to use SSL in your store.

+

You should only change settings here if you know what you're doing.

+ + ]]>
text 2 1 @@ -152,6 +183,15 @@ 1 Clear message pending list. After changing this value and saving, a process to clear message pending list will be schedule for the next minute. + + + text + 1 + 1 + 1 + 1 + If you like, you can specify a Sender Chat ID to filter the message clearing process. +
From 0e4e44264bb1dc8b7695ce0b29cc4744b92d5223 Mon Sep 17 00:00:00 2001 From: blopa Date: Sat, 30 Dec 2017 22:30:27 -0200 Subject: [PATCH 17/25] add messenger settings --- .../community/Werules/Chatbot/etc/system.xml | 207 ++++++++++++++++-- 1 file changed, 185 insertions(+), 22 deletions(-) diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml index ed234c1..5161e74 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml @@ -121,28 +121,191 @@ 1 Enable Messenger bot. - - - - - - - - - - - - - - - - - - - - - - + + + select + adminhtml/system_config_source_enabledisable + 1 + 1 + 1 + 1 + Enable Hub Challenge verification. + + + + text + 2 + 1 + 1 + 1 + Message to send when bot is disabled. Leave it empty to send no message. Please check the maximum size for messages on Messenger API, otherwise your message might not be sent. + + + + text + 3 + 1 + 1 + 1 + Your Facebook Application ID. + + + + text + 4 + 1 + 1 + 1 + Your page access token. + + + + text + 5 + 1 + 1 + 1 + Facebook page username. If you don't know, leave it blank. + + + + text + 6 + 1 + 1 + 1 + Facebook Page ID. If you don't know, leave it blank and we fill it for you. + + + + select + adminhtml/system_config_source_yesno + 7 + 1 + 1 + 1 + Is this domain whitelisted on Facebook? If not, don't worry, we'll whitelist it for you and update this setting. + + + + select + adminhtml/system_config_source_yesno + 8 + 1 + 1 + 1 + Enable Messenger chat box. + + + + + + text + 11 + 1 + 1 + 1 + First message the bot will send to your client. please check the maximum size for messages on Facebook API, otherwise your message might not be sent. you can use "{customername}" to send the customer name. + + + + select + adminhtml/system_config_source_yesno + 12 + 1 + 1 + 1 + Enable welcome message options. + + + + + + + text + 14 + 1 + 1 + 1 + Message will be sent when customer asks informations about the store. Please check the maximum size for messages on Facebook API, otherwise your message might not be sent. + + + + text + 15 + 1 + 1 + 1 + Message will be sent when customer asks for help. Please check the maximum size for messages on Facebook API, otherwise your message might not be sent. + + + + select + adminhtml/system_config_source_yesno + 16 + 1 + 1 + 1 + Enable command listing when customer ask for help. + + + + + + + select + adminhtml/system_config_source_yesno + 18 + 1 + 1 + 1 + Enable default replies. + + + + + + + select + adminhtml/system_config_source_yesno + 20 + 1 + 1 + 1 + Enable Natural Language Processor replies. + + + + text + 21 + 1 + 1 + 1 + validate-no-html-tags + Natural Language Processor entity prefix is a prefix name to flag that the request is coming from Messenger. + + + + + + + text + 23 + 1 + 1 + 1 + Message will be sent when the bot don't understand customer messages for the Nst time. + + + + text + 24 + 1 + 1 + 1 + input-number validate-number + Number of fallbacks before sending the fallback message. + From 434ba5ed0aa9a3067493f22010e670ba0cbf66b7 Mon Sep 17 00:00:00 2001 From: blopa Date: Sat, 30 Dec 2017 22:38:59 -0200 Subject: [PATCH 18/25] add comment --- Magento1/app/code/community/Werules/Chatbot/etc/system.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml index 5161e74..ef60178 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml @@ -105,6 +105,10 @@ + Magento Chatbot v1.0.0 +

To use this module you'll have to use SSL in your store.

+ ]]>
text 1 1 From ca95bd6bdbe6745411023ba882a6c269f73f01ca Mon Sep 17 00:00:00 2001 From: blopa Date: Sat, 30 Dec 2017 22:48:49 -0200 Subject: [PATCH 19/25] add depends --- .../community/Werules/Chatbot/etc/system.xml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml index ef60178..5ed13df 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml @@ -21,6 +21,7 @@ Magento Chatbot v1.0.0

To use this module you'll have to use SSL in your store.

+
]]>
text 0 @@ -82,6 +83,9 @@ Enable wit.ai Natural Language Processor. + + 1 + text 6 @@ -108,6 +112,7 @@ Magento Chatbot v1.0.0

To use this module you'll have to use SSL in your store.

+
]]>
text 1 @@ -136,6 +141,9 @@ Enable Hub Challenge verification. + + 0 + text 2 @@ -222,6 +230,9 @@ Enable welcome message options. + + + @@ -266,6 +277,9 @@ Enable default replies. + + + @@ -289,6 +303,9 @@ Natural Language Processor entity prefix is a prefix name to flag that the request is coming from Messenger. + + + @@ -333,6 +350,7 @@

A 'Message Clearing Process' is scheduled for the next minute. Please wait.

If a minute has passed and nothing happened, please check your cron configuration in your server.

+
]]> text 2 @@ -351,6 +369,9 @@ Clear message pending list. After changing this value and saving, a process to clear message pending list will be schedule for the next minute. + + 1 + text 1 From df6962ac067375255a30be1d7b1c44e55e32c1bf Mon Sep 17 00:00:00 2001 From: blopa Date: Sat, 30 Dec 2017 22:53:22 -0200 Subject: [PATCH 20/25] update year --- .../community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Form.php | 2 +- .../Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Form.php | 2 +- .../Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tab/Stores.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Chatbotapi/Edit/Tabs.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Chatbotapi/Grid.php | 2 +- .../community/Werules/Chatbot/Block/Adminhtml/Chatbotuser.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Form.php | 2 +- .../Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Form.php | 2 +- .../Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tab/Stores.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Chatbotuser/Edit/Tabs.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Chatbotuser/Grid.php | 2 +- .../code/community/Werules/Chatbot/Block/Adminhtml/Message.php | 2 +- .../community/Werules/Chatbot/Block/Adminhtml/Message/Edit.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Message/Edit/Form.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Form.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Message/Edit/Tab/Stores.php | 2 +- .../Werules/Chatbot/Block/Adminhtml/Message/Edit/Tabs.php | 2 +- .../community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php | 2 +- Magento1/app/code/community/Werules/Chatbot/Block/Index.php | 2 +- Magento1/app/code/community/Werules/Chatbot/Block/Messenger.php | 2 +- Magento1/app/code/community/Werules/Chatbot/Block/Telegram.php | 2 +- .../community/Werules/Chatbot/Controller/Adminhtml/Chatbot.php | 2 +- Magento1/app/code/community/Werules/Chatbot/Helper/Data.php | 2 +- Magento1/app/code/community/Werules/Chatbot/Helper/Define.php | 2 +- .../community/Werules/Chatbot/Model/Adminhtml/Serialized.php | 2 +- .../app/code/community/Werules/Chatbot/Model/Api/Messenger.php | 2 +- Magento1/app/code/community/Werules/Chatbot/Model/Api/witAI.php | 2 +- .../app/code/community/Werules/Chatbot/Model/Chatbotapi.php | 2 +- .../app/code/community/Werules/Chatbot/Model/Chatbotuser.php | 2 +- Magento1/app/code/community/Werules/Chatbot/Model/Cron.php | 2 +- Magento1/app/code/community/Werules/Chatbot/Model/Message.php | 2 +- .../community/Werules/Chatbot/Model/Resource/Chatbotapi.php | 2 +- .../Werules/Chatbot/Model/Resource/Chatbotapi/Collection.php | 2 +- .../community/Werules/Chatbot/Model/Resource/Chatbotuser.php | 2 +- .../Werules/Chatbot/Model/Resource/Chatbotuser/Collection.php | 2 +- .../code/community/Werules/Chatbot/Model/Resource/Message.php | 2 +- .../Werules/Chatbot/Model/Resource/Message/Collection.php | 2 +- .../app/code/community/Werules/Chatbot/Model/Resource/Setup.php | 2 +- .../controllers/Adminhtml/Chatbot/ChatbotapiController.php | 2 +- .../controllers/Adminhtml/Chatbot/ChatbotuserController.php | 2 +- .../Chatbot/controllers/Adminhtml/Chatbot/MessageController.php | 2 +- .../Werules/Chatbot/controllers/CustomerController.php | 2 +- .../community/Werules/Chatbot/controllers/WebhookController.php | 2 +- .../Werules/Chatbot/sql/werules_chatbot_setup/install-1.0.0.php | 2 +- 47 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php index a792069..c92e11f 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Chatbotapi.php @@ -1,7 +1,7 @@ Date: Sun, 31 Dec 2017 11:52:34 -0200 Subject: [PATCH 21/25] set endpoint --- .../Chatbot/controllers/WebhookController.php | 58 +++++++++++++------ 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/Magento1/app/code/community/Werules/Chatbot/controllers/WebhookController.php b/Magento1/app/code/community/Werules/Chatbot/controllers/WebhookController.php index 3a4639c..caf4cd9 100644 --- a/Magento1/app/code/community/Werules/Chatbot/controllers/WebhookController.php +++ b/Magento1/app/code/community/Werules/Chatbot/controllers/WebhookController.php @@ -19,24 +19,48 @@ * along with this program. If not, see . */ -class Werules_Chatbot_IndexController extends Mage_Core_Controller_Front_Action{ - public function IndexAction() { - - $this->loadLayout(); - $this->getLayout()->getBlock("head")->setTitle($this->__("Titlename")); - $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs"); - $breadcrumbs->addCrumb("home", array( - "label" => $this->__("Home Page"), - "title" => $this->__("Home Page"), - "link" => Mage::getBaseUrl() - )); - - $breadcrumbs->addCrumb("titlename", array( - "label" => $this->__("Titlename"), - "title" => $this->__("Titlename") - )); +class Werules_Chatbot_WebhookController extends Mage_Core_Controller_Front_Action{ +// public function IndexAction() { +// +// $this->loadLayout(); +// $this->getLayout()->getBlock("head")->setTitle($this->__("Titlename")); +// $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs"); +// $breadcrumbs->addCrumb("home", array( +// "label" => $this->__("Home Page"), +// "title" => $this->__("Home Page"), +// "link" => Mage::getBaseUrl() +// )); +// +// $breadcrumbs->addCrumb("titlename", array( +// "label" => $this->__("Titlename"), +// "title" => $this->__("Titlename") +// )); +// +// $this->renderLayout(); +// +// } + public function IndexAction() + { + $this->loadLayout(); + $this->getLayout()->getBlock('root')->setTemplate("chatbot/index.phtml"); // use root block to output pure values without html tags + $this->renderLayout(); + } - $this->renderLayout(); + public function MessengerAction() + { + $this->loadLayout(); + $this->getLayout()->getBlock('root')->setTemplate("chatbot/messenger.phtml"); // use root block to output pure values without html tags + $this->renderLayout(); + } + public function TelegramAction() + { + $this->loadLayout(); + $this->getLayout()->getBlock('root')->setTemplate("chatbot/telegram.phtml"); // use root block to output pure values without html tags + //$this->getLayout()->getBlock('root')->setTemplate("werules_chatbot_view.phtml")->setTitle(Mage::helper('core')->__('Chatbot')); // use root block to output pure values without html tags + //$this->getLayout()->getBlock('head')->setTitle(Mage::helper('core')->__('Chatbot')); + //$this->getLayout()->getBlock('head')->setTitle($this->__('My Title')); // then this works + //$this->getLayout()->unsetBlock('head'); + $this->renderLayout(); } } \ No newline at end of file From 3fa0e6d320af321a1746bf2c2cfdfe3721bb066a Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 31 Dec 2017 13:18:07 -0200 Subject: [PATCH 22/25] webhook endpoints working --- .../community/Werules/Chatbot/Block/{ => Webhook}/Index.php | 0 .../Werules/Chatbot/Block/{ => Webhook}/Messenger.php | 0 .../Werules/Chatbot/Block/{ => Webhook}/Telegram.php | 2 +- .../frontend/base/default/template/chatbot/index.phtml | 5 ++++- .../frontend/base/default/template/chatbot/messenger.phtml | 5 ++++- .../frontend/base/default/template/chatbot/telegram.phtml | 5 ++++- 6 files changed, 13 insertions(+), 4 deletions(-) rename Magento1/app/code/community/Werules/Chatbot/Block/{ => Webhook}/Index.php (100%) rename Magento1/app/code/community/Werules/Chatbot/Block/{ => Webhook}/Messenger.php (100%) rename Magento1/app/code/community/Werules/Chatbot/Block/{ => Webhook}/Telegram.php (90%) diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Index.php b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Index.php similarity index 100% rename from Magento1/app/code/community/Werules/Chatbot/Block/Index.php rename to Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Index.php diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Messenger.php b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php similarity index 100% rename from Magento1/app/code/community/Werules/Chatbot/Block/Messenger.php rename to Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Telegram.php b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Telegram.php similarity index 90% rename from Magento1/app/code/community/Werules/Chatbot/Block/Telegram.php rename to Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Telegram.php index 608674a..f35a0e8 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Telegram.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Telegram.php @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -class Werules_Chatbot_Block_Telegram extends Mage_Core_Block_Template +class Werules_Chatbot_Block_Webhook_Telegram extends Mage_Core_Block_Template { } \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml index bd022a0..d405834 100644 --- a/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml +++ b/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml @@ -1 +1,4 @@ -Index Page \ No newline at end of file +getLayout()->getBlockSingleton('werules_chatbot/webhook_messenger'); + $thisBlock = $this->getLayout()->createBlock('werules_chatbot/webhook_index'); +?> \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml index ef74fc6..0203ad6 100644 --- a/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml +++ b/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml @@ -1 +1,4 @@ -Messenger Page \ No newline at end of file +getLayout()->getBlockSingleton('werules_chatbot/webhook_messenger'); + $thisBlock = $this->getLayout()->createBlock('werules_chatbot/webhook_messenger'); +?> \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml index 6d6cbfa..a163655 100644 --- a/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml +++ b/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml @@ -1 +1,4 @@ -Telegram Page \ No newline at end of file +getLayout()->getBlockSingleton('werules_chatbot/webhook_telegram'); + $thisBlock = $this->getLayout()->createBlock('werules_chatbot/webhook_telegram'); +?> \ No newline at end of file From 508b0e69c7048c071377d41718c283fdede34c1e Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 31 Dec 2017 16:19:09 -0200 Subject: [PATCH 23/25] copying files from m2 --- .../Werules/Chatbot/Block/Webhook/Index.php | 93 ++++++++++++- .../Chatbot/Block/Webhook/Messenger.php | 73 +++++++++- .../Chatbot/Block/Webhook/Telegram.php | 2 +- .../community/Werules/Chatbot/Helper/Data.php | 129 +++++++++++++++++- .../Werules/Chatbot/Helper/Define.php | 116 ++++++++-------- .../Werules/Chatbot/Model/Chatbotapi.php | 6 +- .../community/Werules/Chatbot/etc/system.xml | 7 +- .../base/default/template/chatbot/index.phtml | 20 +++ .../default/template/chatbot/messenger.phtml | 20 +++ .../default/template/chatbot/settings.phtml | 22 ++- .../default/template/chatbot/telegram.phtml | 20 +++ 11 files changed, 436 insertions(+), 72 deletions(-) diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Index.php b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Index.php index 7d8245f..3fe6aa0 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Index.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Index.php @@ -19,7 +19,98 @@ * along with this program. If not, see . */ -class Werules_Chatbot_Block_Index extends Mage_Core_Block_Template +class Werules_Chatbot_Block_Webhook_Index extends Mage_Core_Block_Template { + protected $_helper; + protected $_chatbotAPI; + protected $_messageModel; + protected $_request; + protected $_define; +// protected $_cronWorker; + public function _construct() + { + $this->_helper = Mage::helper('werules_chatbot'); + $this->_chatbotAPI = Mage::getModel('werules_chatbot/chatbotapi'); + $this->_messageModel = Mage::getModel('werules_chatbot/message'); + $this->_request = $this->getRequest(); + $this->_define = new Werules_Chatbot_Helper_Define; + } + + protected function createMessageObject($apiModel){} // TODO + public function processRequest(){} // TODO + + protected function checkEndpointSecretKey() + { + $urlKey = $this->_request->getParam('endpoint'); + $customKey = $this->getConfigValue('werules_chatbot_general/general/custom_key'); + if ($urlKey == $customKey) + return true; + + return false; + } + + public function requestHandler() + { + $enabled = $this->getConfigValue('werules_chatbot_general/general/enable'); + if ($enabled != $this->_define->ENABLED) + return $this->getJsonErrorResponse(); + + $correctKey = $this->checkEndpointSecretKey(); + if ($correctKey) + $result = $this->processRequest(); + else + $result = $this->getJsonErrorResponse(); + + return $result; + } + + protected function messageHandler($messageObject) + { + $messageModel = $this->_helper->createIncomingMessage($messageObject); + if ($messageModel->getMessageId()) + { + $messageQueueMode = $this->_helper->getQueueMessageMode(); + if (($messageQueueMode == $this->_define->QUEUE_NONE) || ($messageQueueMode == $this->_define->QUEUE_NON_RESTRICTIVE)) + { + $outgoingMessages = $this->_helper->processIncomingMessage($messageModel); + foreach ($outgoingMessages as $outgoingMessage) + { + $result = $this->_helper->processOutgoingMessage($outgoingMessage); + } + } + else if (($messageQueueMode == $this->_define->QUEUE_RESTRICTIVE) || ($messageQueueMode == $this->_define->QUEUE_SIMPLE_RESTRICTIVE)) + { + $result = $this->_helper->processIncomingMessageQueueBySenderId($messageModel->getSenderId()); + if ($result) + $result = $this->_helper->processOutgoingMessageQueueBySenderId($messageModel->getSenderId()); + } + } + else + return $this->_helper->getJsonErrorResponse(); + + return $this->getJsonSuccessResponse(); + } + + public function getConfigValue($code) + { + return $this->_helper->getConfigValue($code); + } + + protected function getJsonErrorResponse() + { + return $this->_helper->getJsonErrorResponse(); + } + + protected function getJsonSuccessResponse() + { + return $this->_helper->getJsonSuccessResponse(); + } + + protected function logPostData($data, $file = 'werules_chatbot.log') + { + $postLog = ($this->getConfigValue('werules_chatbot_general/general/enable_post_log') == $this->_define->ENABLED); + if ($postLog) + $this->_helper->logger($data, $file); + } } \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php index 6acecc3..d58cd46 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php @@ -19,7 +19,78 @@ * along with this program. If not, see . */ -class Werules_Chatbot_Block_Messenger extends Mage_Core_Block_Template +class Werules_Chatbot_Block_Webhook_Messenger extends Werules_Chatbot_Block_Webhook_Index { + public function processRequest() + { + $challenge_hub = $this->getConfigValue('werules_chatbot_messenger/general/enable_hub_challenge'); + if ($challenge_hub == $this->_define->ENABLED) + { + $hub_token = $this->getConfigValue('werules_chatbot_general/general/custom_key'); + $verification_hub = $this->getVerificationHub($hub_token); + if ($verification_hub) + $result = $verification_hub; + else + $result = __("Please check your Hub Verify Token."); + } + else // process message + { + $messengerInstance = $this->getMessengerInstance(); + $this->logPostData($messengerInstance->getPostData(), 'werules_chatbot_messenger.log'); + $messageObject = $this->createMessageObject($messengerInstance); + if (isset($messageObject->content)) + $result = $this->messageHandler($messageObject); + else + $result = $this->getJsonSuccessResponse(); // return success to avoid receiving the same message again + } + + return $result; + } + + protected function getMessengerInstance() + { + $api_token = $this->_helper->getConfigValue('werules_chatbot_messenger/general/api_key'); + $messenger = $this->_chatbotAPI->initMessengerAPI($api_token); + return $messenger; + } + + protected function createMessageObject($messenger) + { + $messageObject = new stdClass(); + if ($messenger->Text()) + $content = $messenger->Text(); + else + $content = $messenger->getPostbackTitle(); + if (!$content) + return $messageObject; + + $messageObject->senderId = $messenger->ChatID(); + $messageObject->content = $content; + $messageObject->status = $this->_define->PROCESSING; + $messageObject->direction = $this->_define->INCOMING; + $messageObject->chatType = $this->_define->MESSENGER_INT; // TODO + $messageObject->contentType = $this->_define->CONTENT_TEXT; // TODO + $messageObject->currentCommandDetails = $this->_define->CURRENT_COMMAND_DETAILS_DEFAULT; // TODO + $messageObject->messagePayload = $this->getMessengerPayload($messenger); // TODO + $messageObject->chatMessageId = $messenger->MessageID(); + if ($messenger->getMessageTimestamp()) + $messageObject->sentAt = (int)$messenger->getMessageTimestamp(); + else + $messageObject->sentAt = time(); + $datetime = date('Y-m-d H:i:s'); + $messageObject->createdAt = $datetime; + $messageObject->updatedAt = $datetime; + + return $messageObject; + } + + protected function getMessengerPayload($messenger) + { + $payload = $messenger->getPostbackPayload(); + if (!$payload) + $payload = $messenger->getQuickReplyPayload(); + + return $payload; + } } \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Telegram.php b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Telegram.php index f35a0e8..72380d3 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Telegram.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Telegram.php @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -class Werules_Chatbot_Block_Webhook_Telegram extends Mage_Core_Block_Template +class Werules_Chatbot_Block_Webhook_Telegram extends Werules_Chatbot_Block_Webhook_Index { } \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php b/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php index ce74ed1..dbd3c62 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php +++ b/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php @@ -21,13 +21,45 @@ class Werules_Chatbot_Helper_Data extends Mage_Core_Helper_Abstract { - /** - * convert array to options - * - * @access public - * @param $options - * @return array - */ + protected $storeManager; + protected $_messageModelFactory; + protected $_messageModel; + protected $_chatbotAPIFactory; + protected $_chatbotUserFactory; + protected $_serializer; + protected $_categoryHelper; + protected $_categoryFactory; + protected $_categoryCollectionFactory; + protected $_orderCollectionFactory; + protected $_productCollection; + protected $_customerRepositoryInterface; + protected $_quoteModel; + protected $_configWriter; + protected $_imageHelper; + protected $_stockRegistry; + protected $_stockFilter; + protected $_priceHelper; + + // not from construct parameters + protected $_define; + protected $_messageQueueMode; + protected $_configPrefix; + protected $_commandsList; + protected $_completeCommandsList; + protected $_currentCommand; + protected $_messagePayload; + protected $_chatbotAPIModel; + + public function __construct() + { + $this->_serializer = Mage::helper('core/unserializeArray'); // ->unserialize((string)$serializedValue); // fix magento unserializing bug +// $this->storeManager = $storeManager; + $this->_messageModel = Mage::getModel('werules_chatbot/message'); // TODO + $this->_messageModelFactory = Mage::getModel('werules_chatbot/message'); // TODO + $this->_chatbotAPIFactory = Mage::getModel('werules_chatbot/chatbotapi'); // TODO + $this->_chatbotUserFactory = Mage::getModel('werules_chatbot/chatbotuser'); // TODO + $this->_define = new Werules_Chatbot_Helper_Define; + } public function convertOptions($options) { $converted = array(); @@ -39,4 +71,87 @@ public function convertOptions($options) } return $converted; } + + public function createIncomingMessage($messageObject) + { + $incomingMessage = $this->_messageModelFactory->create(); + if (isset($messageObject->senderId)) + { + $incomingMessage->setSenderId($messageObject->senderId); + $incomingMessage->setContent($messageObject->content); + $incomingMessage->setChatbotType($messageObject->chatType); + $incomingMessage->setContentType($messageObject->contentType); + $incomingMessage->setCurrentCommandDetails($messageObject->currentCommandDetails); + $incomingMessage->setStatus($messageObject->status); + $incomingMessage->setDirection($messageObject->direction); + $incomingMessage->setMessagePayload($messageObject->messagePayload); + $incomingMessage->setChatMessageId($messageObject->chatMessageId); + $incomingMessage->setSentAt($messageObject->sentAt); + $incomingMessage->setCreatedAt($messageObject->createdAt); + $incomingMessage->setUpdatedAt($messageObject->updatedAt); + $incomingMessage->save(); + } + + return $incomingMessage; + } + + public function getQueueMessageMode() + { + if (isset($this->_messageQueueMode)) + return $this->_messageQueueMode; + + $this->_messageQueueMode = $this->getConfigValue('werules_chatbot_general/general/message_queue_mode'); + return $this->_messageQueueMode; + } + + public function processIncomingMessage($message) // TODO_NOW + { + return array(); + } + + public function processOutgoingMessage($outgoingMessage) // TODO_NOW + { + return array(); + } + + public function processIncomingMessageQueueBySenderId($senderId) // TODO_NOW + { + return array(); + } + + public function processOutgoingMessageQueueBySenderId($senderId) // TODO_NOW + { + return array(); + } + + public function logger($text, $file = 'werules_chatbot.log') + { + Mage::log($text, null, $file); + } + + public function getConfigValue($field) + { + return Mage::getStoreConfig($field); + } + + public function getJsonSuccessResponse() + { + return $this->getJsonResponse(true); + } + + public function getJsonErrorResponse() + { + return $this->getJsonResponse(false); + } + + private function getJsonResponse($success) + { + header_remove('Content-Type'); // TODO + header('Content-Type: application/json'); // TODO + if ($success) + $result = array('status' => 'success', 'success' => true); + else + $result = array('status' => 'error', 'success' => false); + return json_encode($result); + } } \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Helper/Define.php b/Magento1/app/code/community/Werules/Chatbot/Helper/Define.php index a1f8334..b8831cf 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Helper/Define.php +++ b/Magento1/app/code/community/Werules/Chatbot/Helper/Define.php @@ -19,81 +19,81 @@ * along with this program. If not, see . */ -class Define +class Werules_Chatbot_Helper_Define { - const MESSENGER_INT = 0; - const TELEGRAM_INT = 1; - const NOT_PROCESSED = 0; - const PROCESSING = 1; - const PROCESSED = 2; - const INCOMING = 0; - const OUTGOING = 1; - const DISABLED = 0; - const ENABLED = 1; - const NOT_LOGGED = 0; - const NOT_ADMIN = 0; - const ADMIN = 1; - const LOGGED = 1; - const SECONDS_IN_HOUR = 3600; - const SECONDS_IN_MINUTE = 60; - const DEFAULT_MIN_CONFIDENCE = 0.7; - const BREAK_LINE = '\n'; // chr(10) - const QUEUE_PROCESSING_LIMIT = self::SECONDS_IN_MINUTE * 3; + public $MESSENGER_INT = 0; + public $TELEGRAM_INT = 1; + public $NOT_PROCESSED = 0; + public $PROCESSING = 1; + public $PROCESSED = 2; + public $INCOMING = 0; + public $OUTGOING = 1; + public $DISABLED = 0; + public $ENABLED = 1; + public $NOT_LOGGED = 0; + public $NOT_ADMIN = 0; + public $ADMIN = 1; + public $LOGGED = 1; + public $SECONDS_IN_HOUR = 3600; + public $SECONDS_IN_MINUTE = 60; + public $DEFAULT_MIN_CONFIDENCE = 0.7; + public $BREAK_LINE = '\n'; // chr(10) + public $QUEUE_PROCESSING_LIMIT = 180;//$SECONDS_IN_MINUTE * 3; // commands - const START_COMMAND_ID = 0; - const LIST_CATEGORIES_COMMAND_ID = 1; - const SEARCH_COMMAND_ID = 2; - const LOGIN_COMMAND_ID = 3; - const LIST_ORDERS_COMMAND_ID = 4; - const REORDER_COMMAND_ID = 5; - const ADD_TO_CART_COMMAND_ID = 6; - const CHECKOUT_COMMAND_ID = 7; - const CLEAR_CART_COMMAND_ID = 8; - const TRACK_ORDER_COMMAND_ID = 9; - const SUPPORT_COMMAND_ID = 10; - const SEND_EMAIL_COMMAND_ID = 11; - const CANCEL_COMMAND_ID = 12; - const HELP_COMMAND_ID = 13; - const ABOUT_COMMAND_ID = 14; - const LOGOUT_COMMAND_ID = 15; - const REGISTER_COMMAND_ID = 16; - const LIST_MORE_COMMAND_ID = 17; - const LAST_COMMAND_DETAILS_DEFAULT = '{"last_command_parameter":"","last_command_text":"","last_conversation_state":0,"last_listed_quantity":0}'; + public $START_COMMAND_ID = 0; + public $LIST_CATEGORIES_COMMAND_ID = 1; + public $SEARCH_COMMAND_ID = 2; + public $LOGIN_COMMAND_ID = 3; + public $LIST_ORDERS_COMMAND_ID = 4; + public $REORDER_COMMAND_ID = 5; + public $ADD_TO_CART_COMMAND_ID = 6; + public $CHECKOUT_COMMAND_ID = 7; + public $CLEAR_CART_COMMAND_ID = 8; + public $TRACK_ORDER_COMMAND_ID = 9; + public $SUPPORT_COMMAND_ID = 10; + public $SEND_EMAIL_COMMAND_ID = 11; + public $CANCEL_COMMAND_ID = 12; + public $HELP_COMMAND_ID = 13; + public $ABOUT_COMMAND_ID = 14; + public $LOGOUT_COMMAND_ID = 15; + public $REGISTER_COMMAND_ID = 16; + public $LIST_MORE_COMMAND_ID = 17; + public $LAST_COMMAND_DETAILS_DEFAULT = '{"last_command_parameter":"","last_command_text":"","last_conversation_state":0,"last_listed_quantity":0}'; // array( // 'last_command_parameter' => '', // 'last_command_text' => '', // 'last_conversation_state' => 0, // 'last_listed_quantity' => 0, // ); - const CURRENT_COMMAND_DETAILS_DEFAULT = '[]'; + public $CURRENT_COMMAND_DETAILS_DEFAULT = '[]'; // json_encode(array()) // message content types - const CONTENT_TEXT = 0; - const QUICK_REPLY = 1; - const IMAGE_WITH_TEXT = 2; - const IMAGE_WITH_OPTIONS = 3; - const RECEIPT_LAYOUT = 4; - const LIST_WITH_IMAGE = 5; - const TEXT_WITH_OPTIONS = 6; + public $CONTENT_TEXT = 0; + public $QUICK_REPLY = 1; + public $IMAGE_WITH_TEXT = 2; + public $IMAGE_WITH_OPTIONS = 3; + public $RECEIPT_LAYOUT = 4; + public $LIST_WITH_IMAGE = 5; + public $TEXT_WITH_OPTIONS = 6; // conversation states - const CONVERSATION_STARTED = 0; - const CONVERSATION_LIST_CATEGORIES = 1; - const CONVERSATION_SEARCH = 2; - const CONVERSATION_EMAIL = 3; - const CONVERSATION_TRACK_ORDER = 4; + public $CONVERSATION_STARTED = 0; + public $CONVERSATION_LIST_CATEGORIES = 1; + public $CONVERSATION_SEARCH = 2; + public $CONVERSATION_EMAIL = 3; + public $CONVERSATION_TRACK_ORDER = 4; // API - const MAX_MESSAGE_ELEMENTS = 7; + public $MAX_MESSAGE_ELEMENTS = 7; // MESSAGE QUEUE MODES - const QUEUE_NONE = 0; - const QUEUE_SIMPLE_RESTRICTIVE = 1; - const QUEUE_RESTRICTIVE = 2; - const QUEUE_NON_RESTRICTIVE = 3; + public $QUEUE_NONE = 0; + public $QUEUE_SIMPLE_RESTRICTIVE = 1; + public $QUEUE_RESTRICTIVE = 2; + public $QUEUE_NON_RESTRICTIVE = 3; - const DONT_CLEAR_MESSAGE_QUEUE = 0; - const CLEAR_MESSAGE_QUEUE = 1; + public $DONT_CLEAR_MESSAGE_QUEUE = 0; + public $CLEAR_MESSAGE_QUEUE = 1; } \ No newline at end of file diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php index 00db75a..3cc61dc 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php @@ -98,5 +98,9 @@ public function getDefaultValues() $values['status'] = 1; return $values; } - + + public function initMessengerAPI($bot_token) // TODO TODO TODO + { + return new Werules_Chatbot_Model_Api_Messenger($bot_token); + } } diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml index 5ed13df..a16640c 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml @@ -21,7 +21,7 @@ Magento Chatbot v1.0.0

To use this module you'll have to use SSL in your store.

-
+
]]>
text 0 @@ -47,7 +47,10 @@ 1 1 validate-alphanum - This is Your Custom Secret Key Used For The Webhook URL, to Activate/Deactivate The API Webhook For Telegram, And to Use as Your Challenge Hub For Facebook. Alphanumeric Only! Access http://(YOUR_STORE_URL)/chatbot/chatdata/(API)/webhook/(YOUR_CUSTOM_KEY) to Set The Webhook, change API to "telegram" or "facebook". + Generate +

This is your secret key used for the webhook URL and Facebook Verification Hub. Click here to get instructions on how to configure your endpoint for Messenger or here to configure it for Telegram.

+ ]]>
diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml index d405834..126930c 100644 --- a/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml +++ b/Magento1/app/design/frontend/base/default/template/chatbot/index.phtml @@ -1,4 +1,24 @@ . + */ // $thisBlock = $this->getLayout()->getBlockSingleton('werules_chatbot/webhook_messenger'); $thisBlock = $this->getLayout()->createBlock('werules_chatbot/webhook_index'); + echo $thisBlock->requestHandler(); ?> \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml index 0203ad6..3b20a19 100644 --- a/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml +++ b/Magento1/app/design/frontend/base/default/template/chatbot/messenger.phtml @@ -1,4 +1,24 @@ . + */ // $thisBlock = $this->getLayout()->getBlockSingleton('werules_chatbot/webhook_messenger'); $thisBlock = $this->getLayout()->createBlock('werules_chatbot/webhook_messenger'); + echo $thisBlock->requestHandler(); ?> \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml index 20d839c..2216f7e 100644 --- a/Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml +++ b/Magento1/app/design/frontend/base/default/template/chatbot/settings.phtml @@ -1 +1,21 @@ -Settings Page \ No newline at end of file +. + */ +?> \ No newline at end of file diff --git a/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml b/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml index a163655..411afd0 100644 --- a/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml +++ b/Magento1/app/design/frontend/base/default/template/chatbot/telegram.phtml @@ -1,4 +1,24 @@ . + */ // $thisBlock = $this->getLayout()->getBlockSingleton('werules_chatbot/webhook_telegram'); $thisBlock = $this->getLayout()->createBlock('werules_chatbot/webhook_telegram'); + echo $thisBlock->requestHandler(); ?> \ No newline at end of file From 5462a4304676275fc3e7a5e3557fdc0b56f6a97d Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 31 Dec 2017 16:48:18 -0200 Subject: [PATCH 24/25] add error handler --- .../code/community/Werules/Chatbot/Block/Webhook/Messenger.php | 3 +++ .../app/code/community/Werules/Chatbot/Model/Api/Messenger.php | 2 +- .../app/code/community/Werules/Chatbot/Model/Chatbotapi.php | 1 + Magento1/app/code/community/Werules/Chatbot/etc/system.xml | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php index d58cd46..8f8b0c2 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php @@ -36,6 +36,9 @@ public function processRequest() else // process message { $messengerInstance = $this->getMessengerInstance(); + if (!$messengerInstance->getPostData()) + return $this->getJsonErrorResponse(); + $this->logPostData($messengerInstance->getPostData(), 'werules_chatbot_messenger.log'); $messageObject = $this->createMessageObject($messengerInstance); diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Api/Messenger.php b/Magento1/app/code/community/Werules/Chatbot/Model/Api/Messenger.php index 818a1c7..47eb917 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Api/Messenger.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Api/Messenger.php @@ -31,7 +31,7 @@ * along with this program. If not, see . */ -class Werules_Chatbot_Model_Api_Messenger extends Mage_Core_Model_Mysql4_Abstract { +class Werules_Chatbot_Model_Api_Messenger { private $bot_token; private $api_version = "v2.11"; diff --git a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php index 3cc61dc..58138f1 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php +++ b/Magento1/app/code/community/Werules/Chatbot/Model/Chatbotapi.php @@ -99,6 +99,7 @@ public function getDefaultValues() return $values; } + // CUSTOM FUNCTIONS public function initMessengerAPI($bot_token) // TODO TODO TODO { return new Werules_Chatbot_Model_Api_Messenger($bot_token); diff --git a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml index a16640c..d7a3468 100644 --- a/Magento1/app/code/community/Werules/Chatbot/etc/system.xml +++ b/Magento1/app/code/community/Werules/Chatbot/etc/system.xml @@ -297,6 +297,9 @@
+ + 1 + text 21 1 From 4ada98c1630150494d07d151cd727fbbda8d5546 Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 31 Dec 2017 17:56:43 -0200 Subject: [PATCH 25/25] saving message model --- .../Werules/Chatbot/Block/Adminhtml/Message/Grid.php | 2 +- .../community/Werules/Chatbot/Block/Webhook/Messenger.php | 2 +- Magento1/app/code/community/Werules/Chatbot/Helper/Data.php | 4 +++- .../Chatbot/sql/werules_chatbot_setup/install-1.0.0.php | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php index c5cce5a..6ba3e11 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Adminhtml/Message/Grid.php @@ -165,7 +165,7 @@ protected function _prepareColumns() array( 'header' => Mage::helper('werules_chatbot')->__('Sent At'), 'index' => 'sent_at', - 'type'=> 'date', + 'type'=> 'datetime', ) ); diff --git a/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php index 8f8b0c2..7d14dca 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php +++ b/Magento1/app/code/community/Werules/Chatbot/Block/Webhook/Messenger.php @@ -78,7 +78,7 @@ protected function createMessageObject($messenger) $messageObject->messagePayload = $this->getMessengerPayload($messenger); // TODO $messageObject->chatMessageId = $messenger->MessageID(); if ($messenger->getMessageTimestamp()) - $messageObject->sentAt = (int)$messenger->getMessageTimestamp(); + $messageObject->sentAt = substr($messenger->getMessageTimestamp(), 0, 10); else $messageObject->sentAt = time(); $datetime = date('Y-m-d H:i:s'); diff --git a/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php b/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php index dbd3c62..fd2e9da 100644 --- a/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php +++ b/Magento1/app/code/community/Werules/Chatbot/Helper/Data.php @@ -74,7 +74,9 @@ public function convertOptions($options) public function createIncomingMessage($messageObject) { - $incomingMessage = $this->_messageModelFactory->create(); + $this->logger('messageObject -> '); + $this->logger($messageObject); + $incomingMessage = $this->_messageModelFactory; if (isset($messageObject->senderId)) { $incomingMessage->setSenderId($messageObject->senderId); diff --git a/Magento1/app/code/community/Werules/Chatbot/sql/werules_chatbot_setup/install-1.0.0.php b/Magento1/app/code/community/Werules/Chatbot/sql/werules_chatbot_setup/install-1.0.0.php index 44b2425..3161e14 100644 --- a/Magento1/app/code/community/Werules/Chatbot/sql/werules_chatbot_setup/install-1.0.0.php +++ b/Magento1/app/code/community/Werules/Chatbot/sql/werules_chatbot_setup/install-1.0.0.php @@ -99,7 +99,7 @@ ) ->addColumn( 'sent_at', - Varien_Db_Ddl_Table::TYPE_DATETIME, 255, + Varien_Db_Ddl_Table::TYPE_TIMESTAMP, 255, array( 'nullable' => false, ),