Version Notes
This is the first release
Download this release
Release Info
Developer | Eduard G. Dumitrescu |
Extension | Slack |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Intelivemetrics/Slack/Helper/Data.php +28 -0
- app/code/community/Intelivemetrics/Slack/Model/Abstract.php +317 -0
- app/code/community/Intelivemetrics/Slack/Model/Notification.php +62 -0
- app/code/community/Intelivemetrics/Slack/Model/Observers/Abstract.php +46 -0
- app/code/community/Intelivemetrics/Slack/Model/Observers/AdminUserLoginFailed.php +42 -0
- app/code/community/Intelivemetrics/Slack/Model/Observers/AdminUserLoginSuccess.php +38 -0
- app/code/community/Intelivemetrics/Slack/Model/Observers/DailyStats.php +105 -0
- app/code/community/Intelivemetrics/Slack/Model/Observers/Interface.php +16 -0
- app/code/community/Intelivemetrics/Slack/Model/Observers/NewCreditmemo.php +51 -0
- app/code/community/Intelivemetrics/Slack/Model/Observers/NewCustomer.php +42 -0
- app/code/community/Intelivemetrics/Slack/Model/Observers/NewInvoice.php +51 -0
- app/code/community/Intelivemetrics/Slack/Model/Observers/NewOrder.php +55 -0
- app/code/community/Intelivemetrics/Slack/Model/Observers/NewShipment.php +51 -0
- app/code/community/Intelivemetrics/Slack/Model/Queue.php +87 -0
- app/code/community/Intelivemetrics/Slack/Model/Resource/Queue.php +54 -0
- app/code/community/Intelivemetrics/Slack/Model/Resource/Queue/Collection.php +37 -0
- app/code/community/Intelivemetrics/Slack/etc/adminhtml.xml +44 -0
- app/code/community/Intelivemetrics/Slack/etc/config.xml +163 -0
- app/code/community/Intelivemetrics/Slack/etc/system.xml +197 -0
- app/code/community/Intelivemetrics/Slack/sql/intelivemetrics_slack_setup/install-0.4.0.php +51 -0
- app/etc/modules/Intelivemetrics_Slack.xml +10 -0
- package.xml +18 -0
app/code/community/Intelivemetrics/Slack/Helper/Data.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Marcel Hauri
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
19 |
+
*
|
20 |
+
* @category Notification
|
21 |
+
* @package mhauri-slack
|
22 |
+
* @author Marcel Hauri <marcel@hauri.me>
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Intelivemetrics_Slack_Helper_Data extends Mage_Core_Helper_Abstract
|
26 |
+
{
|
27 |
+
|
28 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Abstract.php
ADDED
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Marcel Hauri
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
19 |
+
*
|
20 |
+
* @category Notification
|
21 |
+
* @package mhauri-slack
|
22 |
+
* @author Marcel Hauri <marcel@hauri.me>
|
23 |
+
*/
|
24 |
+
|
25 |
+
abstract class Intelivemetrics_Slack_Model_Abstract extends Mage_Core_Model_Abstract
|
26 |
+
{
|
27 |
+
|
28 |
+
const LOG_FILE = 'slack.log';
|
29 |
+
|
30 |
+
const DEFAULT_SENDER = 'Magento Slack';
|
31 |
+
const DEFAULT_CHANNEL = '#general';
|
32 |
+
const DEFAULT_ICON = ':bell:';
|
33 |
+
|
34 |
+
const ENABLE_NOTIFICATION_PATH = 'slack/general/enable_notification';
|
35 |
+
const ENABLE_LOG_PATH = 'slack/general/enable_log';
|
36 |
+
const USE_QUEUE = 'slack/general/use_queue';
|
37 |
+
|
38 |
+
const WEBHOOK_URL_PATH = 'slack/api/webhook_url';
|
39 |
+
const CHANNEL_PATH = 'slack/api/channel';
|
40 |
+
const USERNAME_PATH = 'slack/api/username';
|
41 |
+
const ICON_PATH = 'slack/api/icon';
|
42 |
+
|
43 |
+
const NEW_ORDER_PATH = 'slack/notification/new_order';
|
44 |
+
const NEW_INVOICE_PATH = 'slack/notification/new_invoice';
|
45 |
+
const DAILY_STATS_PATH = 'slack/notification/daily_stats';
|
46 |
+
const NEW_CREDITMEMO_PATH = 'slack/notification/new_creditmemo';
|
47 |
+
const NEW_SHIPMENT_PATH = 'slack/notification/new_shipment';
|
48 |
+
const NEW_CUSTOMER_ACCOUNT_PATH = 'slack/notification/new_customer_account';
|
49 |
+
const ADMIN_USER_LOGIN_FAILED_PATH = 'slack/notification/admin_user_login_failed';
|
50 |
+
const ADMIN_USER_LOGIN_SUCCESS_PATH = 'slack/notification/admin_user_login_success';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Store the Message
|
54 |
+
* @var string
|
55 |
+
*/
|
56 |
+
private $_message = '';
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Store the from name
|
60 |
+
* @var string
|
61 |
+
*/
|
62 |
+
private $_channel = null;
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @var null
|
66 |
+
*/
|
67 |
+
private $_icon = self::DEFAULT_ICON;
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Store room id
|
71 |
+
* @var null
|
72 |
+
*/
|
73 |
+
private $_username = null;
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Store webhook url
|
77 |
+
* @var null
|
78 |
+
*/
|
79 |
+
private $_webhook = null;
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Message author/ Store name
|
83 |
+
* @var null
|
84 |
+
*/
|
85 |
+
private $_author = null;
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Store link
|
89 |
+
* @var null
|
90 |
+
*/
|
91 |
+
private $_author_link = null;
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Store favicon
|
95 |
+
* @var null
|
96 |
+
*/
|
97 |
+
private $_author_icon = null;
|
98 |
+
|
99 |
+
private $_pretext = null;
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
protected function _construct()
|
104 |
+
{
|
105 |
+
$this->setWebhookUrl(Mage::getStoreConfig(self::WEBHOOK_URL_PATH, 0));
|
106 |
+
$this->setUsername(Mage::getStoreConfig(self::USERNAME_PATH, 0));
|
107 |
+
$this->setChannel(Mage::getStoreConfig(self::CHANNEL_PATH, 0));
|
108 |
+
$this->setIcon(Mage::getStoreConfig(self::ICON_PATH, 0));
|
109 |
+
$this->setAuthor(Mage::getStoreConfig('general/store_information/name', 0));
|
110 |
+
$this->setAuthorLink(Mage::getStoreConfig('web/secure/base_url', 0));
|
111 |
+
$this->setAuthorIcon(Mage::getStoreConfig('web/secure/base_url', 0).'media/favicon/'.Mage::getStoreConfig('slack/api/icon', 0));
|
112 |
+
$this->setWebhookUrl(Mage::getStoreConfig(self::WEBHOOK_URL_PATH, 0));
|
113 |
+
parent::_construct();
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* @param $webhook
|
118 |
+
* @return $this
|
119 |
+
*/
|
120 |
+
public function setWebhookUrl($webhook)
|
121 |
+
{
|
122 |
+
if(is_string($webhook)) {
|
123 |
+
$this->_webhook = $webhook;
|
124 |
+
}
|
125 |
+
|
126 |
+
return $this;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* @return null|string
|
131 |
+
*/
|
132 |
+
public function getWebhookUrl()
|
133 |
+
{
|
134 |
+
return $this->_webhook;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* @param $channel
|
139 |
+
* @return $this
|
140 |
+
*/
|
141 |
+
public function setChannel($channel)
|
142 |
+
{
|
143 |
+
if(is_string($channel)) {
|
144 |
+
$this->_channel = $channel;
|
145 |
+
}
|
146 |
+
|
147 |
+
return $this;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* @return string
|
152 |
+
*/
|
153 |
+
public function getChannel()
|
154 |
+
{
|
155 |
+
if($this->_channel) {
|
156 |
+
return $this->_channel;
|
157 |
+
}
|
158 |
+
|
159 |
+
return self::DEFAULT_CHANNEL;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @param $icon
|
164 |
+
* @return $this
|
165 |
+
*/
|
166 |
+
public function setIcon($icon)
|
167 |
+
{
|
168 |
+
if(is_string($icon)) {
|
169 |
+
$this->_icon = $icon;
|
170 |
+
}
|
171 |
+
return $this;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* @return null
|
176 |
+
*/
|
177 |
+
public function getIcon()
|
178 |
+
{
|
179 |
+
return $this->_icon;
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* @param $username
|
184 |
+
* @return $this
|
185 |
+
*/
|
186 |
+
public function setUsername($username)
|
187 |
+
{
|
188 |
+
if(is_string($username)) {
|
189 |
+
$this->_username = $username;
|
190 |
+
}
|
191 |
+
|
192 |
+
return $this;
|
193 |
+
}
|
194 |
+
|
195 |
+
public function setPretext($pretext)
|
196 |
+
{
|
197 |
+
if(is_string($pretext)) {
|
198 |
+
$this->_pretext = $pretext;
|
199 |
+
}
|
200 |
+
|
201 |
+
return $this;
|
202 |
+
}
|
203 |
+
|
204 |
+
public function setAuthor($author)
|
205 |
+
{
|
206 |
+
if(empty($author)){
|
207 |
+
$author = 'Magento Store';
|
208 |
+
}
|
209 |
+
if(is_string($author)) {
|
210 |
+
$this->_author = $author;
|
211 |
+
}
|
212 |
+
|
213 |
+
return $this;
|
214 |
+
}
|
215 |
+
|
216 |
+
public function setAuthorLink($link)
|
217 |
+
{
|
218 |
+
if(is_string($link)) {
|
219 |
+
$this->_author_link = $link;
|
220 |
+
}
|
221 |
+
|
222 |
+
return $this;
|
223 |
+
}
|
224 |
+
|
225 |
+
public function setAuthorIcon($icon)
|
226 |
+
{
|
227 |
+
if(is_string($icon)) {
|
228 |
+
$this->_author_icon = $icon;
|
229 |
+
}
|
230 |
+
|
231 |
+
return $this;
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* @return null
|
236 |
+
*/
|
237 |
+
public function getUsername()
|
238 |
+
{
|
239 |
+
return $this->_username;
|
240 |
+
}
|
241 |
+
|
242 |
+
public function getAuthor()
|
243 |
+
{
|
244 |
+
return $this->_author;
|
245 |
+
}
|
246 |
+
|
247 |
+
public function getPretext()
|
248 |
+
{
|
249 |
+
return $this->_pretext;
|
250 |
+
}
|
251 |
+
|
252 |
+
public function getAuthorLink()
|
253 |
+
{
|
254 |
+
return $this->_author_link;
|
255 |
+
}
|
256 |
+
|
257 |
+
public function getAuthorIcon()
|
258 |
+
{
|
259 |
+
return $this->_author_icon;
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* @param $message
|
264 |
+
* @return $this
|
265 |
+
*/
|
266 |
+
public function setMessage($message)
|
267 |
+
{
|
268 |
+
if(is_string($message)) {
|
269 |
+
$this->_message = $message;
|
270 |
+
}
|
271 |
+
return $this;
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* @return string
|
276 |
+
*/
|
277 |
+
public function getMessage()
|
278 |
+
{
|
279 |
+
return $this->_message;
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* @return mixed
|
284 |
+
*/
|
285 |
+
public function isEnabled()
|
286 |
+
{
|
287 |
+
return Mage::getStoreConfig(self::ENABLE_NOTIFICATION_PATH, 0);
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* @param $params
|
292 |
+
* @return bool
|
293 |
+
* @throws Exception
|
294 |
+
*/
|
295 |
+
public function sendMessage($params)
|
296 |
+
{
|
297 |
+
$ch = curl_init();
|
298 |
+
curl_setopt($ch, CURLOPT_NOBODY, 0);
|
299 |
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
300 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
301 |
+
curl_setopt($ch, CURLOPT_URL, $this->getWebhookUrl());
|
302 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
303 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, array('payload' => json_encode($params)));
|
304 |
+
|
305 |
+
if(curl_exec($ch)) {
|
306 |
+
if(Mage::getStoreConfig(self::ENABLE_LOG_PATH, 0)) {
|
307 |
+
Mage::log('Message sent: ' . $this->getMessage(), Zend_Log::INFO, self::LOG_FILE, true);
|
308 |
+
}
|
309 |
+
// print_r(json_encode($params));
|
310 |
+
// die();
|
311 |
+
} else {
|
312 |
+
throw new Exception('Unable to send Message');
|
313 |
+
}
|
314 |
+
curl_close($ch);
|
315 |
+
return true;
|
316 |
+
}
|
317 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Notification.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015, Marcel Hauri
|
5 |
+
* All rights reserved.
|
6 |
+
*
|
7 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
8 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
9 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
10 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
11 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
12 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
13 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
14 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
15 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
16 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
17 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
18 |
+
*
|
19 |
+
* @copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
20 |
+
*
|
21 |
+
* @category Notification
|
22 |
+
* @package mhauri-slack
|
23 |
+
* @author Marcel Hauri <marcel@hauri.me>
|
24 |
+
*/
|
25 |
+
class Intelivemetrics_Slack_Model_Notification extends Intelivemetrics_Slack_Model_Abstract {
|
26 |
+
|
27 |
+
public function send() {
|
28 |
+
if (!$this->isEnabled()) {
|
29 |
+
Mage::log('Slack Notifications are not enabled!', Zend_Log::ERR, self::LOG_FILE, true);
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
|
33 |
+
$params = array(
|
34 |
+
'channel' => $this->getChannel(),
|
35 |
+
'username' => $this->getUsername(),
|
36 |
+
'text' => $this->getMessage(),
|
37 |
+
'icon_emoji' => $this->getIcon(),
|
38 |
+
'mrkdwn' => true,
|
39 |
+
'mrkdwn_in' => '["text"]',
|
40 |
+
'attachments' => array(
|
41 |
+
array(
|
42 |
+
'pretext' => $this->getPretext(),
|
43 |
+
'author_name' => $this->getAuthor(),
|
44 |
+
'author_link' => $this->getAuthorLink(),
|
45 |
+
'author_icon' => $this->getAuthorIcon()
|
46 |
+
)
|
47 |
+
)
|
48 |
+
);
|
49 |
+
|
50 |
+
if (Mage::getStoreConfig(self::USE_QUEUE, 0)) {
|
51 |
+
Mage::getModel('intelivemetrics_slack/queue')->addMessageToQueue($params);
|
52 |
+
} else {
|
53 |
+
try {
|
54 |
+
$this->sendMessage($params);
|
55 |
+
} catch (Exception $e) {
|
56 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Intelivemetrics_Slack_Model_Abstract::LOG_FILE);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
return true;
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Observers/Abstract.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Marcel Hauri
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
19 |
+
*
|
20 |
+
* @category Notification
|
21 |
+
* @package mhauri-slack
|
22 |
+
* @author Marcel Hauri <marcel@hauri.me>, Sander Mangel <https://github.com/sandermangel>
|
23 |
+
*/
|
24 |
+
|
25 |
+
abstract class Intelivemetrics_Slack_Model_Observers_Abstract
|
26 |
+
implements Intelivemetrics_Slack_Model_Observers_Interface
|
27 |
+
{
|
28 |
+
protected $_notificationModel = null;
|
29 |
+
|
30 |
+
protected $_helper = null;
|
31 |
+
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
$this->_notificationModel = Mage::getSingleton('intelivemetrics_slack/notification');
|
35 |
+
$this->_helper = Mage::helper('intelivemetrics_slack');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param $path
|
40 |
+
* @return mixed
|
41 |
+
*/
|
42 |
+
protected function _getConfig($path)
|
43 |
+
{
|
44 |
+
return Mage::getStoreConfig($path, 0);
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Observers/AdminUserLoginFailed.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Marcel Hauri
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
19 |
+
*
|
20 |
+
* @category Notification
|
21 |
+
* @package mhauri-slack
|
22 |
+
* @author Marcel Hauri <marcel@hauri.me>, Sander Mangel <https://github.com/sandermangel>
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Intelivemetrics_Slack_Model_Observers_AdminUserLoginFailed
|
26 |
+
extends Intelivemetrics_Slack_Model_Observers_Abstract
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Send a notification when admin user login failed
|
30 |
+
* @param $observer
|
31 |
+
*/
|
32 |
+
public function notify($observer)
|
33 |
+
{
|
34 |
+
if($this->_getConfig(Intelivemetrics_Slack_Model_Notification::ADMIN_USER_LOGIN_FAILED_PATH)) {
|
35 |
+
$this->_notificationModel
|
36 |
+
->setMessage($this->_helper->__("Admin user login failed with username: %s", $observer->getUserName()))
|
37 |
+
->setIcon(':closed_lock_with_key:')
|
38 |
+
->setUsername($this->_helper->__('Wrong Credentials'))
|
39 |
+
->send();
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Observers/AdminUserLoginSuccess.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Intelive Metrics SRL
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Intelive Metrics SRL (http://mageslack.com/)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Intelivemetrics_Slack_Model_Observers_AdminUserLoginSuccess
|
22 |
+
extends Intelivemetrics_Slack_Model_Observers_Abstract
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* Send a notification when admin user login failed
|
26 |
+
* @param $observer
|
27 |
+
*/
|
28 |
+
public function notify($observer)
|
29 |
+
{
|
30 |
+
if($this->_getConfig(Intelivemetrics_Slack_Model_Notification::ADMIN_USER_LOGIN_SUCCESS_PATH)) {
|
31 |
+
$this->_notificationModel
|
32 |
+
->setMessage($this->_helper->__("Admin user %s %s logged in", $observer->getUser()->getFirstname(),$observer->getUser()->getLastname()))
|
33 |
+
->setIcon(':unlock:')
|
34 |
+
->setUsername($this->_helper->__('Login'))
|
35 |
+
->send();
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Observers/DailyStats.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015, Intelive Metrics SRL
|
5 |
+
* All rights reserved.
|
6 |
+
*
|
7 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
8 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
9 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
10 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
11 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
12 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
13 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
14 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
15 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
16 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
17 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
18 |
+
*
|
19 |
+
* @copyright Copyright 2015, Intelive Metrics SRL (http://mageslack.com/)
|
20 |
+
*/
|
21 |
+
class Intelivemetrics_Slack_Model_Observers_DailyStats extends Intelivemetrics_Slack_Model_Observers_Abstract {
|
22 |
+
|
23 |
+
protected function _getOrderStats($date) {
|
24 |
+
$stats = array(
|
25 |
+
'orders' => 0,
|
26 |
+
'gt' => 0,
|
27 |
+
'items' => 0
|
28 |
+
);
|
29 |
+
$collection = Mage::getModel('sales/order')
|
30 |
+
->getCollection()
|
31 |
+
->addAttributeToSelect('*');
|
32 |
+
$collection->getSelect()
|
33 |
+
->where("DATE(created_at) = '{$date}'")
|
34 |
+
->where("state <> '" . Mage_Sales_Model_Order::STATE_CANCELED . "'")
|
35 |
+
;
|
36 |
+
foreach ($collection as $order) {
|
37 |
+
$stats['orders']++;
|
38 |
+
$stats['gt']+=$order->getGrandTotal();
|
39 |
+
$stats['items']+=$order->getTotalQtyOrdered();
|
40 |
+
}
|
41 |
+
|
42 |
+
return $stats;
|
43 |
+
}
|
44 |
+
|
45 |
+
protected function _getCustomerStats($date) {
|
46 |
+
$stats = array(
|
47 |
+
'customers' => 0,
|
48 |
+
);
|
49 |
+
$collection = Mage::getModel('customer/customer')
|
50 |
+
->getCollection();
|
51 |
+
$collection->getSelect()
|
52 |
+
->where("DATE(created_at) = '{$date}'")
|
53 |
+
;
|
54 |
+
foreach ($collection as $customer) {
|
55 |
+
$stats['customers']++;
|
56 |
+
}
|
57 |
+
|
58 |
+
return $stats;
|
59 |
+
}
|
60 |
+
|
61 |
+
protected function _padToLength($text, $length=40){
|
62 |
+
$formated=$text;
|
63 |
+
for ($i = strlen($text); $i < $length; $i++) {
|
64 |
+
$formated = $formated.' ';
|
65 |
+
}
|
66 |
+
|
67 |
+
return $formated;
|
68 |
+
}
|
69 |
+
|
70 |
+
protected function _makeSpace($length=10){
|
71 |
+
$space='';
|
72 |
+
for ($i = 0; $i < $length; $i++) {
|
73 |
+
$space .= ' ';
|
74 |
+
}
|
75 |
+
return $space;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Send a daily notification with yesterday's stats
|
80 |
+
* @param $observer
|
81 |
+
*/
|
82 |
+
public function notify($observer) {
|
83 |
+
if ($this->_getConfig(Intelivemetrics_Slack_Model_Notification::DAILY_STATS_PATH)) {
|
84 |
+
$_yesterday = strtotime("-1 day", strtotime("12:00:00"));
|
85 |
+
$yesterday = date('Y-m-d', $_yesterday);
|
86 |
+
$orderStats = $this->_getOrderStats($yesterday);
|
87 |
+
$customerStats = $this->_getCustomerStats($yesterday);
|
88 |
+
|
89 |
+
echo $message = '*Orders:* '.$orderStats['orders']. $this->_makeSpace().
|
90 |
+
'*Products:* '.$orderStats['items'].$this->_makeSpace().
|
91 |
+
'*New Customers:* '.$customerStats['customers'].$this->_makeSpace().
|
92 |
+
'*Revenue:* '.number_format($orderStats['gt'],2,',','.') .$this->_makeSpace().
|
93 |
+
'*AOV:* '.number_format($orderStats['gt']/$orderStats['orders'],2,',','.').$this->_makeSpace().
|
94 |
+
'*AVG Items/Order:* '.round($orderStats['items']/$orderStats['orders'],2)
|
95 |
+
;
|
96 |
+
$this->_notificationModel
|
97 |
+
->setMessage($message)
|
98 |
+
->setIcon(':date:')
|
99 |
+
->setPretext("Unlock critical eCommerce KPI's with <http://www.unityreports.com/?utm_source=slackgento&utm_medium=slack&utm_content=pretext%20link%20&utm_campaign=slackgento|UnityReports>")
|
100 |
+
->setUsername('Stats for: '.date('l, M jS, Y', $_yesterday))
|
101 |
+
->send();
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Observers/Interface.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Observer interface
|
4 |
+
*
|
5 |
+
* @category Intelivemetrics
|
6 |
+
* @package Intelivemetrics_Slack
|
7 |
+
* @author Sander Mangel <https://github.com/sandermangel>
|
8 |
+
*/
|
9 |
+
interface Intelivemetrics_Slack_Model_Observers_Interface
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Send a notification to slack
|
13 |
+
* @param $observer
|
14 |
+
*/
|
15 |
+
public function notify($observer);
|
16 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Observers/NewCreditmemo.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Intelive Metrics SRL
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Intelive Metrics SRL (http://mageslack.com/)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Intelivemetrics_Slack_Model_Observers_NewCreditmemo
|
22 |
+
extends Intelivemetrics_Slack_Model_Observers_Abstract
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* Send a notification when a new order was placed
|
26 |
+
* @param $observer
|
27 |
+
*/
|
28 |
+
public function notify($observer)
|
29 |
+
{
|
30 |
+
if($this->_getConfig(Intelivemetrics_Slack_Model_Notification::NEW_CREDITMEMO_PATH)) {
|
31 |
+
$creditmemo = $observer->getCreditmemo();
|
32 |
+
$order = $creditmemo->getOrder();
|
33 |
+
$url1 = Mage::helper("adminhtml")->getUrl('adminhtml/sales_creditmemo/view', array('creditmemo_id' => $creditmemo->getId()));
|
34 |
+
$url2 = Mage::helper("adminhtml")->getUrl('adminhtml/sales_order/view', array('order_id' => $order->getId()));
|
35 |
+
$message = $this->_helper->__("*Credit Memo ID:* <%s|%s>, *Order ID:* <%s|%s>, *Amount:* %s %s",
|
36 |
+
$url1,
|
37 |
+
$creditmemo->getIncrementId(),
|
38 |
+
$url2,
|
39 |
+
$order->getIncrementId(),
|
40 |
+
$creditmemo->getGrandTotal(),
|
41 |
+
$order->getOrderCurrencyCode()
|
42 |
+
);
|
43 |
+
|
44 |
+
$this->_notificationModel
|
45 |
+
->setMessage($message)
|
46 |
+
->setIcon(':page_with_curl:')
|
47 |
+
->setUsername($this->_helper->__('New Credit Memo'))
|
48 |
+
->send();
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Observers/NewCustomer.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015, Marcel Hauri
|
5 |
+
* All rights reserved.
|
6 |
+
*
|
7 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
8 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
9 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
10 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
11 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
12 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
13 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
14 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
15 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
16 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
17 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
18 |
+
*
|
19 |
+
* @copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
20 |
+
*
|
21 |
+
* @category Notification
|
22 |
+
* @package mhauri-slack
|
23 |
+
* @author Marcel Hauri <marcel@hauri.me>, Sander Mangel <https://github.com/sandermangel>
|
24 |
+
*/
|
25 |
+
class Intelivemetrics_Slack_Model_Observers_NewCustomer extends Intelivemetrics_Slack_Model_Observers_Abstract {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Send a notification when a new customer account is created
|
29 |
+
*/
|
30 |
+
public function notify($observer) {
|
31 |
+
if ($this->_getConfig(Intelivemetrics_Slack_Model_Notification::NEW_CUSTOMER_ACCOUNT_PATH)) {
|
32 |
+
$customer = $observer->getCustomer();
|
33 |
+
$url = Mage::helper("adminhtml")->getUrl('adminhtml/customer/edit', array('id' => $customer->getId()));
|
34 |
+
$this->_notificationModel
|
35 |
+
->setMessage($this->_helper->__("*New customer registration:* <%s|%s %s>", $url, $customer->getFirstname(), $customer->getLastname()))
|
36 |
+
->setIcon(':bust_in_silhouette:')
|
37 |
+
->setUsername($this->_helper->__('New Customer'))
|
38 |
+
->send();
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Observers/NewInvoice.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Intelive Metrics SRL
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Intelive Metrics SRL (http://mageslack.com/)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Intelivemetrics_Slack_Model_Observers_NewInvoice
|
22 |
+
extends Intelivemetrics_Slack_Model_Observers_Abstract
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* Send a notification when a new order was placed
|
26 |
+
* @param $observer
|
27 |
+
*/
|
28 |
+
public function notify($observer)
|
29 |
+
{
|
30 |
+
if($this->_getConfig(Intelivemetrics_Slack_Model_Notification::NEW_INVOICE_PATH)) {
|
31 |
+
$invoice = $observer->getInvoice();
|
32 |
+
$order = $invoice->getOrder();
|
33 |
+
$url1 = Mage::helper("adminhtml")->getUrl('adminhtml/sales_invoice/view', array('invoice_id' => $invoice->getId()));
|
34 |
+
$url2 = Mage::helper("adminhtml")->getUrl('adminhtml/sales_order/view', array('order_id' => $order->getId()));
|
35 |
+
$message = $this->_helper->__("*Invoice ID:* <%s|%s>, *Order ID:* <%s|%s>, *Amount:* %s %s",
|
36 |
+
$url1,
|
37 |
+
$invoice->getIncrementId(),
|
38 |
+
$url2,
|
39 |
+
$order->getIncrementId(),
|
40 |
+
$invoice->getGrandTotal(),
|
41 |
+
$order->getOrderCurrencyCode()
|
42 |
+
);
|
43 |
+
|
44 |
+
$this->_notificationModel
|
45 |
+
->setMessage($message)
|
46 |
+
->setIcon(':memo:')
|
47 |
+
->setUsername($this->_helper->__('New Invoice'))
|
48 |
+
->send();
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Observers/NewOrder.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Marcel Hauri
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
19 |
+
*
|
20 |
+
* @category Notification
|
21 |
+
* @package mhauri-slack
|
22 |
+
* @author Marcel Hauri <marcel@hauri.me>, Sander Mangel <https://github.com/sandermangel>
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Intelivemetrics_Slack_Model_Observers_NewOrder
|
26 |
+
extends Intelivemetrics_Slack_Model_Observers_Abstract
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Send a notification when a new order was placed
|
30 |
+
* @param $observer
|
31 |
+
*/
|
32 |
+
public function notify($observer)
|
33 |
+
{
|
34 |
+
if($this->_getConfig(Intelivemetrics_Slack_Model_Notification::NEW_ORDER_PATH)) {
|
35 |
+
$order = $observer->getOrder();
|
36 |
+
$url1 = Mage::helper("adminhtml")->getUrl('adminhtml/sales_order/view', array('order_id' => $order->getId()));
|
37 |
+
$url2 = Mage::helper("adminhtml")->getUrl('adminhtml/customer/edit', array('id' => $order->getCustomer()->getId()));
|
38 |
+
$message = $this->_helper->__("*Order ID:* <%s|%s>, *Customer:* <%s|%s %s>, *Amount:* %s %s",
|
39 |
+
$url1,
|
40 |
+
$order->getIncrementId(),
|
41 |
+
$url2,
|
42 |
+
$order->getCustomer()->getFirstname(),
|
43 |
+
$order->getCustomer()->getLastname(),
|
44 |
+
$order->getQuoteBaseGrandTotal(),
|
45 |
+
$order->getOrderCurrencyCode()
|
46 |
+
);
|
47 |
+
|
48 |
+
$this->_notificationModel
|
49 |
+
->setMessage($message)
|
50 |
+
->setIcon(':package:')
|
51 |
+
->setUsername($this->_helper->__('New Order'))
|
52 |
+
->send();
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Observers/NewShipment.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Intelive Metrics SRL
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Intelive Metrics SRL (http://mageslack.com/)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Intelivemetrics_Slack_Model_Observers_NewShipment
|
22 |
+
extends Intelivemetrics_Slack_Model_Observers_Abstract
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* Send a notification when a new order was placed
|
26 |
+
* @param $observer
|
27 |
+
*/
|
28 |
+
public function notify($observer)
|
29 |
+
{
|
30 |
+
if($this->_getConfig(Intelivemetrics_Slack_Model_Notification::NEW_SHIPMENT_PATH)) {
|
31 |
+
$shipment = $observer->getShipment();
|
32 |
+
$order = $shipment->getOrder();
|
33 |
+
$url1 = Mage::helper("adminhtml")->getUrl('adminhtml/sales_shipment/view', array('shipment_id' => $shipment->getId()));
|
34 |
+
$url2 = Mage::helper("adminhtml")->getUrl('adminhtml/sales_order/view', array('order_id' => $order->getId()));
|
35 |
+
$message = $this->_helper->__("*Shipment ID:* <%s|%s>, *Order ID:* <%s|%s>",
|
36 |
+
$url1,
|
37 |
+
$shipment->getIncrementId(),
|
38 |
+
$url2,
|
39 |
+
$order->getIncrementId(),
|
40 |
+
$shipment->getGrandTotal(),
|
41 |
+
$order->getOrderCurrencyCode()
|
42 |
+
);
|
43 |
+
|
44 |
+
$this->_notificationModel
|
45 |
+
->setMessage($message)
|
46 |
+
->setIcon(':truck:')
|
47 |
+
->setUsername($this->_helper->__('New Shipment'))
|
48 |
+
->send();
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Queue.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Marcel Hauri
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
19 |
+
*
|
20 |
+
* @category Notification
|
21 |
+
* @package mhauri-slack
|
22 |
+
* @author Marcel Hauri <marcel@hauri.me>
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Intelivemetrics_Slack_Model_Queue extends Intelivemetrics_Slack_Model_Abstract
|
26 |
+
{
|
27 |
+
const MESSAGES_LIMIT_PER_CRON_RUN = 30;
|
28 |
+
|
29 |
+
protected function _construct()
|
30 |
+
{
|
31 |
+
$this->_init('intelivemetrics_slack/queue');
|
32 |
+
parent::_construct();
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @param $params
|
37 |
+
*/
|
38 |
+
public function addMessageToQueue($params)
|
39 |
+
{
|
40 |
+
$this->setMessageParams(serialize($params));
|
41 |
+
|
42 |
+
try {
|
43 |
+
$this->save();
|
44 |
+
|
45 |
+
if(Mage::getStoreConfig(self::ENABLE_LOG_PATH, 0)) {
|
46 |
+
Mage::log('Queued message: "' . $params['text'] . '"', Zend_Log::ERR, self::LOG_FILE, true);
|
47 |
+
}
|
48 |
+
} catch(Exception $e) {
|
49 |
+
Mage::log($e->getMessage(), Zend_log::ERR, Intelivemetrics_Slack_Model_Abstract::LOG_FILE);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Send all queued Messages
|
55 |
+
*/
|
56 |
+
public function sendQueuedMessages()
|
57 |
+
{
|
58 |
+
$collection = Mage::getModel('intelivemetrics_slack/queue')->getCollection()
|
59 |
+
->addOnlyForSendingFilter()
|
60 |
+
->setPageSize(self::MESSAGES_LIMIT_PER_CRON_RUN)
|
61 |
+
->setCurPage(1)
|
62 |
+
->load();
|
63 |
+
|
64 |
+
foreach($collection as $message) {
|
65 |
+
try {
|
66 |
+
$this->sendMessage(unserialize($message->getMessageParams()));
|
67 |
+
$message->setProcessedAt(Varien_Date::formatDate(true));
|
68 |
+
$message->save();
|
69 |
+
}
|
70 |
+
catch (Exception $e) {
|
71 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Intelivemetrics_Slack_Model_Abstract::LOG_FILE);
|
72 |
+
}
|
73 |
+
// Slack rate limits, see: https://api.slack.com/docs/rate-limits
|
74 |
+
sleep(1);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Remove sent messages
|
80 |
+
* @return $this
|
81 |
+
*/
|
82 |
+
public function cleanQueue()
|
83 |
+
{
|
84 |
+
$this->_getResource()->removeSentMessages();
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Resource/Queue.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Marcel Hauri
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
19 |
+
*
|
20 |
+
* @category Notification
|
21 |
+
* @package mhauri-slack
|
22 |
+
* @author Marcel Hauri <marcel@hauri.me>
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Intelivemetrics_Slack_Model_Resource_Queue extends Mage_Core_Model_Resource_Db_Abstract
|
26 |
+
{
|
27 |
+
protected function _construct()
|
28 |
+
{
|
29 |
+
$this->_init('intelivemetrics_slack/queue', 'message_id');
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @param Mage_Core_Model_Abstract $object
|
34 |
+
* @return Mage_Core_Model_Resource_Db_Abstract
|
35 |
+
*/
|
36 |
+
protected function _beforeSave(Mage_Core_Model_Abstract $object)
|
37 |
+
{
|
38 |
+
if ($object->isObjectNew()) {
|
39 |
+
$object->setCreatedAt($this->formatDate(true));
|
40 |
+
}
|
41 |
+
return parent::_beforeSave($object);
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Remove the sent messages from queue
|
46 |
+
*
|
47 |
+
* @return $this
|
48 |
+
*/
|
49 |
+
public function removeSentMessages()
|
50 |
+
{
|
51 |
+
$this->_getWriteAdapter()->delete($this->getMainTable(), 'processed_at IS NOT NULL');
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Intelivemetrics/Slack/Model/Resource/Queue/Collection.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Marcel Hauri
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
19 |
+
*
|
20 |
+
* @category Notification
|
21 |
+
* @package mhauri-slack
|
22 |
+
* @author Marcel Hauri <marcel@hauri.me>
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Intelivemetrics_Slack_Model_Resource_Queue_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
26 |
+
{
|
27 |
+
protected function _construct()
|
28 |
+
{
|
29 |
+
$this->_init('intelivemetrics_slack/queue', 'message_id');
|
30 |
+
}
|
31 |
+
|
32 |
+
public function addOnlyForSendingFilter()
|
33 |
+
{
|
34 |
+
$this->getSelect()->where('main_table.processed_at IS NULL');
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
}
|
app/code/community/Intelivemetrics/Slack/etc/adminhtml.xml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
Copyright (c) 2015, Marcel Hauri
|
4 |
+
All rights reserved.
|
5 |
+
|
6 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
|
18 |
+
@copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
19 |
+
|
20 |
+
@category Notification
|
21 |
+
@package mhauri-slack
|
22 |
+
@author Marcel Hauri <marcel@hauri.me>
|
23 |
+
-->
|
24 |
+
<config>
|
25 |
+
<acl>
|
26 |
+
<resources>
|
27 |
+
<admin>
|
28 |
+
<children>
|
29 |
+
<system>
|
30 |
+
<children>
|
31 |
+
<config>
|
32 |
+
<children>
|
33 |
+
<slack translate="title" module="intelivemetrics_slack">
|
34 |
+
<title>Slack</title>
|
35 |
+
</slack>
|
36 |
+
</children>
|
37 |
+
</config>
|
38 |
+
</children>
|
39 |
+
</system>
|
40 |
+
</children>
|
41 |
+
</admin>
|
42 |
+
</resources>
|
43 |
+
</acl>
|
44 |
+
</config>
|
app/code/community/Intelivemetrics/Slack/etc/config.xml
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Intelivemetrics_Slack>
|
5 |
+
<version>0.4.0</version>
|
6 |
+
</Intelivemetrics_Slack>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<helpers>
|
10 |
+
<intelivemetrics_slack>
|
11 |
+
<class>Intelivemetrics_Slack_Helper</class>
|
12 |
+
</intelivemetrics_slack>
|
13 |
+
</helpers>
|
14 |
+
<models>
|
15 |
+
<intelivemetrics_slack>
|
16 |
+
<class>Intelivemetrics_Slack_Model</class>
|
17 |
+
<resourceModel>intelivemetrics_slack_resource</resourceModel>
|
18 |
+
</intelivemetrics_slack>
|
19 |
+
<intelivemetrics_slack_resource>
|
20 |
+
<class>Intelivemetrics_Slack_Model_Resource</class>
|
21 |
+
<entities>
|
22 |
+
<queue>
|
23 |
+
<table>slack_queue</table>
|
24 |
+
</queue>
|
25 |
+
</entities>
|
26 |
+
</intelivemetrics_slack_resource>
|
27 |
+
</models>
|
28 |
+
<resources>
|
29 |
+
<intelivemetrics_slack_setup>
|
30 |
+
<setup>
|
31 |
+
<module>Intelivemetrics_Slack</module>
|
32 |
+
<class>Mage_Core_Model_Resource_Setup</class>
|
33 |
+
</setup>
|
34 |
+
<connection>
|
35 |
+
<use>core_setup</use>
|
36 |
+
</connection>
|
37 |
+
</intelivemetrics_slack_setup>
|
38 |
+
</resources>
|
39 |
+
|
40 |
+
<events>
|
41 |
+
<sales_order_place_after>
|
42 |
+
<observers>
|
43 |
+
<notifyNewOrder>
|
44 |
+
<class>Intelivemetrics_Slack_Model_Observers_NewOrder</class>
|
45 |
+
<method>notify</method>
|
46 |
+
</notifyNewOrder>
|
47 |
+
</observers>
|
48 |
+
</sales_order_place_after>
|
49 |
+
<sales_order_invoice_save_after>
|
50 |
+
<observers>
|
51 |
+
<notifyNewInvoice>
|
52 |
+
<class>Intelivemetrics_Slack_Model_Observers_NewInvoice</class>
|
53 |
+
<method>notify</method>
|
54 |
+
</notifyNewInvoice>
|
55 |
+
</observers>
|
56 |
+
</sales_order_invoice_save_after>
|
57 |
+
<sales_order_shipment_save_after>
|
58 |
+
<observers>
|
59 |
+
<notifyNewShipment>
|
60 |
+
<class>Intelivemetrics_Slack_Model_Observers_NewShipment</class>
|
61 |
+
<method>notify</method>
|
62 |
+
</notifyNewShipment>
|
63 |
+
</observers>
|
64 |
+
</sales_order_shipment_save_after>
|
65 |
+
<sales_order_creditmemo_save_after>
|
66 |
+
<observers>
|
67 |
+
<notifyNewCreditmemo>
|
68 |
+
<class>Intelivemetrics_Slack_Model_Observers_NewCreditmemo</class>
|
69 |
+
<method>notify</method>
|
70 |
+
</notifyNewCreditmemo>
|
71 |
+
</observers>
|
72 |
+
</sales_order_creditmemo_save_after>
|
73 |
+
<admin_session_user_login_success>
|
74 |
+
<observers>
|
75 |
+
<notifyAdminUserLoginSuccess>
|
76 |
+
<class>Intelivemetrics_Slack_Model_Observers_AdminUserLoginSuccess</class>
|
77 |
+
<method>notify</method>
|
78 |
+
</notifyAdminUserLoginSuccess>
|
79 |
+
</observers>
|
80 |
+
</admin_session_user_login_success>
|
81 |
+
<admin_session_user_login_failed>
|
82 |
+
<observers>
|
83 |
+
<notifyAdminUserLoginFailed>
|
84 |
+
<class>Intelivemetrics_Slack_Model_Observers_AdminUserLoginFailed</class>
|
85 |
+
<method>notify</method>
|
86 |
+
</notifyAdminUserLoginFailed>
|
87 |
+
</observers>
|
88 |
+
</admin_session_user_login_failed>
|
89 |
+
<customer_register_success>
|
90 |
+
<observers>
|
91 |
+
<notifyNewCustomer>
|
92 |
+
<class>Intelivemetrics_Slack_Model_Observers_NewCustomer</class>
|
93 |
+
<method>notify</method>
|
94 |
+
</notifyNewCustomer>
|
95 |
+
</observers>
|
96 |
+
</customer_register_success>
|
97 |
+
</events>
|
98 |
+
|
99 |
+
</global>
|
100 |
+
<adminhtml>
|
101 |
+
<translate>
|
102 |
+
<modules>
|
103 |
+
<intelivemetrics_hipchat>
|
104 |
+
<files>
|
105 |
+
<default>Intelivemetrics_Slack.csv</default>
|
106 |
+
</files>
|
107 |
+
</intelivemetrics_hipchat>
|
108 |
+
</modules>
|
109 |
+
</translate>
|
110 |
+
</adminhtml>
|
111 |
+
<default>
|
112 |
+
<slack>
|
113 |
+
<general>
|
114 |
+
<enable_notification>0</enable_notification>
|
115 |
+
<enable_log>0</enable_log>
|
116 |
+
<use_queue>0</use_queue>
|
117 |
+
</general>
|
118 |
+
<api>
|
119 |
+
<username>Magento Slack</username>
|
120 |
+
<webhook_url/>
|
121 |
+
<channel>#general</channel>
|
122 |
+
</api>
|
123 |
+
<notification>
|
124 |
+
<new_order>1</new_order>
|
125 |
+
<new_invoice>1</new_invoice>
|
126 |
+
<new_shipment>1</new_shipment>
|
127 |
+
<new_creditmemo>1</new_creditmemo>
|
128 |
+
<new_customer_account>1</new_customer_account>
|
129 |
+
<admin_user_login_success>1</admin_user_login_success>
|
130 |
+
<admin_user_login_failed>1</admin_user_login_failed>
|
131 |
+
<daily_stats>1</daily_stats>
|
132 |
+
</notification>
|
133 |
+
</slack>
|
134 |
+
</default>
|
135 |
+
<crontab>
|
136 |
+
<jobs>
|
137 |
+
<intelivemetrics_slack_queue_send_all>
|
138 |
+
<schedule>
|
139 |
+
<cron_expr>*/5 * * * *</cron_expr>
|
140 |
+
</schedule>
|
141 |
+
<run>
|
142 |
+
<model>intelivemetrics_slack/queue::sendQueuedMessages</model>
|
143 |
+
</run>
|
144 |
+
</intelivemetrics_slack_queue_send_all>
|
145 |
+
<intelivemetrics_slack_queue_clean_up>
|
146 |
+
<schedule>
|
147 |
+
<cron_expr>0 0 * * *</cron_expr>
|
148 |
+
</schedule>
|
149 |
+
<run>
|
150 |
+
<model>intelivemetrics_slack/queue::cleanQueue</model>
|
151 |
+
</run>
|
152 |
+
</intelivemetrics_slack_queue_clean_up>
|
153 |
+
<intelivemetrics_slack_daily_stats>
|
154 |
+
<schedule>
|
155 |
+
<cron_expr>30 9 * * *</cron_expr>
|
156 |
+
</schedule>
|
157 |
+
<run>
|
158 |
+
<model>intelivemetrics_slack/observers_dailyStats::notify</model>
|
159 |
+
</run>
|
160 |
+
</intelivemetrics_slack_daily_stats>
|
161 |
+
</jobs>
|
162 |
+
</crontab>
|
163 |
+
</config>
|
app/code/community/Intelivemetrics/Slack/etc/system.xml
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
Copyright (c) 2015, Marcel Hauri
|
4 |
+
All rights reserved.
|
5 |
+
|
6 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
|
18 |
+
@copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
19 |
+
|
20 |
+
@category Notification
|
21 |
+
@package mhauri-slack
|
22 |
+
@author Marcel Hauri <marcel@hauri.me>
|
23 |
+
-->
|
24 |
+
<config>
|
25 |
+
<sections>
|
26 |
+
<slack translate="label" module="intelivemetrics_slack">
|
27 |
+
<class>separator-top</class>
|
28 |
+
<label>Slack</label>
|
29 |
+
<tab>service</tab>
|
30 |
+
<frontend_type>text</frontend_type>
|
31 |
+
<sort_order>40</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>0</show_in_website>
|
34 |
+
<show_in_store>0</show_in_store>
|
35 |
+
<groups>
|
36 |
+
<general>
|
37 |
+
<label>General</label>
|
38 |
+
<frontend_type>text</frontend_type>
|
39 |
+
<sort_order>10</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>0</show_in_website>
|
42 |
+
<show_in_store>0</show_in_store>
|
43 |
+
<fields>
|
44 |
+
<enable_notification translate="label">
|
45 |
+
<label>Enable Slack notifications</label>
|
46 |
+
<frontend_type>select</frontend_type>
|
47 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
48 |
+
<sort_order>10</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>0</show_in_website>
|
51 |
+
<show_in_store>0</show_in_store>
|
52 |
+
</enable_notification>
|
53 |
+
<enable_log translate="label">
|
54 |
+
<label>Log notifications</label>
|
55 |
+
<frontend_type>select</frontend_type>
|
56 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
57 |
+
<sort_order>20</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>0</show_in_website>
|
60 |
+
<show_in_store>0</show_in_store>
|
61 |
+
</enable_log>
|
62 |
+
<use_queue translate="label">
|
63 |
+
<label>Use Message Queue</label>
|
64 |
+
<frontend_type>select</frontend_type>
|
65 |
+
<comment>Message Queue is the prefered way for high traffic websites, but won't give you real-time notifications (cronjob must run!).</comment>
|
66 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
67 |
+
<sort_order>30</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>0</show_in_website>
|
70 |
+
<show_in_store>0</show_in_store>
|
71 |
+
</use_queue>
|
72 |
+
</fields>
|
73 |
+
</general>
|
74 |
+
<api>
|
75 |
+
<label>API Settings</label>
|
76 |
+
<frontend_type>text</frontend_type>
|
77 |
+
<sort_order>10</sort_order>
|
78 |
+
<show_in_default>1</show_in_default>
|
79 |
+
<show_in_website>0</show_in_website>
|
80 |
+
<show_in_store>0</show_in_store>
|
81 |
+
<fields>
|
82 |
+
<webhook_url translate="label">
|
83 |
+
<label>Webhook Url</label>
|
84 |
+
<frontend_type>text</frontend_type>
|
85 |
+
<sort_order>30</sort_order>
|
86 |
+
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>0</show_in_website>
|
88 |
+
<show_in_store>0</show_in_store>
|
89 |
+
</webhook_url>
|
90 |
+
<channel translate="label">
|
91 |
+
<label>Channel</label>
|
92 |
+
<frontend_type>text</frontend_type>
|
93 |
+
<sort_order>40</sort_order>
|
94 |
+
<show_in_default>1</show_in_default>
|
95 |
+
<show_in_website>0</show_in_website>
|
96 |
+
<show_in_store>0</show_in_store>
|
97 |
+
</channel>
|
98 |
+
<icon translate="label comment">
|
99 |
+
<label>Author Icon</label>
|
100 |
+
<comment>Allowed file types: PNG, GIF, JPG, JPEG. Allowed dimensions 16px X 16px</comment>
|
101 |
+
<frontend_type>image</frontend_type>
|
102 |
+
<backend_model>adminhtml/system_config_backend_image_favicon</backend_model>
|
103 |
+
<base_url type="media" scope_info="1">favicon</base_url>
|
104 |
+
<sort_order>50</sort_order>
|
105 |
+
<show_in_default>1</show_in_default>
|
106 |
+
<show_in_website>1</show_in_website>
|
107 |
+
<show_in_store>1</show_in_store>
|
108 |
+
</icon>
|
109 |
+
</fields>
|
110 |
+
</api>
|
111 |
+
<notification>
|
112 |
+
<label>Notification Settings</label>
|
113 |
+
<frontend_type>text</frontend_type>
|
114 |
+
<sort_order>100</sort_order>
|
115 |
+
<show_in_default>1</show_in_default>
|
116 |
+
<show_in_website>0</show_in_website>
|
117 |
+
<show_in_store>0</show_in_store>
|
118 |
+
<fields>
|
119 |
+
<new_order translate="label" module="intelivemetrics_slack">
|
120 |
+
<label>New Orders</label>
|
121 |
+
<frontend_type>select</frontend_type>
|
122 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
123 |
+
<sort_order>10</sort_order>
|
124 |
+
<show_in_default>1</show_in_default>
|
125 |
+
<show_in_website>0</show_in_website>
|
126 |
+
<show_in_store>0</show_in_store>
|
127 |
+
</new_order>
|
128 |
+
<new_invoice translate="label" module="intelivemetrics_slack">
|
129 |
+
<label>New Invoices</label>
|
130 |
+
<frontend_type>select</frontend_type>
|
131 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
132 |
+
<sort_order>12</sort_order>
|
133 |
+
<show_in_default>1</show_in_default>
|
134 |
+
<show_in_website>0</show_in_website>
|
135 |
+
<show_in_store>0</show_in_store>
|
136 |
+
</new_invoice>
|
137 |
+
<new_shipment translate="label" module="intelivemetrics_slack">
|
138 |
+
<label>New Shipments</label>
|
139 |
+
<frontend_type>select</frontend_type>
|
140 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
141 |
+
<sort_order>13</sort_order>
|
142 |
+
<show_in_default>1</show_in_default>
|
143 |
+
<show_in_website>0</show_in_website>
|
144 |
+
<show_in_store>0</show_in_store>
|
145 |
+
</new_shipment>
|
146 |
+
<new_creditmemo translate="label" module="intelivemetrics_slack">
|
147 |
+
<label>New Credit Memos</label>
|
148 |
+
<frontend_type>select</frontend_type>
|
149 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
150 |
+
<sort_order>14</sort_order>
|
151 |
+
<show_in_default>1</show_in_default>
|
152 |
+
<show_in_website>0</show_in_website>
|
153 |
+
<show_in_store>0</show_in_store>
|
154 |
+
</new_creditmemo>
|
155 |
+
<new_customer_account translate="label" module="intelivemetrics_slack">
|
156 |
+
<label>New Customer Account</label>
|
157 |
+
<frontend_type>select</frontend_type>
|
158 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
159 |
+
<sort_order>18</sort_order>
|
160 |
+
<show_in_default>1</show_in_default>
|
161 |
+
<show_in_website>0</show_in_website>
|
162 |
+
<show_in_store>0</show_in_store>
|
163 |
+
</new_customer_account>
|
164 |
+
<admin_user_login_success translate="label" module="intelivemetrics_slack">
|
165 |
+
<label>Admin User Login Success</label>
|
166 |
+
<frontend_type>select</frontend_type>
|
167 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
168 |
+
<sort_order>20</sort_order>
|
169 |
+
<show_in_default>1</show_in_default>
|
170 |
+
<show_in_website>0</show_in_website>
|
171 |
+
<show_in_store>0</show_in_store>
|
172 |
+
</admin_user_login_success>
|
173 |
+
<admin_user_login_failed translate="label" module="intelivemetrics_slack">
|
174 |
+
<label>Admin User Login Failed</label>
|
175 |
+
<frontend_type>select</frontend_type>
|
176 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
177 |
+
<sort_order>20</sort_order>
|
178 |
+
<show_in_default>1</show_in_default>
|
179 |
+
<show_in_website>0</show_in_website>
|
180 |
+
<show_in_store>0</show_in_store>
|
181 |
+
</admin_user_login_failed>
|
182 |
+
<daily_stats translate="label" module="intelivemetrics_slack">
|
183 |
+
<label>Daily Stats</label>
|
184 |
+
<frontend_type>select</frontend_type>
|
185 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
186 |
+
<comment>Cronjob must run in order for this to work Daily Stats to work!</comment>
|
187 |
+
<sort_order>50</sort_order>
|
188 |
+
<show_in_default>1</show_in_default>
|
189 |
+
<show_in_website>0</show_in_website>
|
190 |
+
<show_in_store>0</show_in_store>
|
191 |
+
</daily_stats>
|
192 |
+
</fields>
|
193 |
+
</notification>
|
194 |
+
</groups>
|
195 |
+
</slack>
|
196 |
+
</sections>
|
197 |
+
</config>
|
app/code/community/Intelivemetrics/Slack/sql/intelivemetrics_slack_setup/install-0.4.0.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2015, Marcel Hauri
|
4 |
+
* All rights reserved.
|
5 |
+
*
|
6 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
7 |
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
8 |
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
9 |
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
10 |
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
11 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
12 |
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
13 |
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
14 |
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
15 |
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
16 |
+
* POSSIBILITY OF SUCH DAMAGE.
|
17 |
+
*
|
18 |
+
* @copyright Copyright 2015, Marcel Hauri (https://github.com/mhauri/magento-slack/)
|
19 |
+
*
|
20 |
+
* @category Notification
|
21 |
+
* @package mhauri-slack
|
22 |
+
* @author Marcel Hauri <marcel@hauri.me>
|
23 |
+
*/
|
24 |
+
|
25 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
26 |
+
$installer = $this;
|
27 |
+
$installer->startSetup();
|
28 |
+
|
29 |
+
$table = $installer->getConnection()
|
30 |
+
->newTable($installer->getTable('intelivemetrics_slack/queue'))
|
31 |
+
->addColumn('message_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
32 |
+
'identity' => true,
|
33 |
+
'unsigned' => true,
|
34 |
+
'nullable' => false,
|
35 |
+
'primary' => true,
|
36 |
+
), 'Message Id')
|
37 |
+
->addColumn('message_params', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
38 |
+
'nullable' => false,
|
39 |
+
'default' => '',
|
40 |
+
), 'Message Parameters')
|
41 |
+
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
42 |
+
'nullable' => true,
|
43 |
+
), 'Created At')
|
44 |
+
->addColumn('processed_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
45 |
+
'nullable' => true,
|
46 |
+
), 'Processed At')
|
47 |
+
->setComment('Slack Message Queue');
|
48 |
+
|
49 |
+
$installer->getConnection()->createTable($table);
|
50 |
+
|
51 |
+
$installer->endSetup();
|
app/etc/modules/Intelivemetrics_Slack.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Intelivemetrics_Slack>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends></depends>
|
8 |
+
</Intelivemetrics_Slack>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Slack</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>MIT</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Magento activity in Slack</summary>
|
10 |
+
<description>Orders, Invoices, Shipments, New Customers, and more, directly in your favourite Slack channel.</description>
|
11 |
+
<notes>This is the first release</notes>
|
12 |
+
<authors><author><name>Eduard G. Dumitrescu</name><user>bregoiu</user><email>eddie.dumitrescu@gmail.com</email></author></authors>
|
13 |
+
<date>2015-05-28</date>
|
14 |
+
<time>12:24:08</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Intelivemetrics"><dir name="Slack"><dir name="Helper"><file name="Data.php" hash="458ed57e6ec081205bf68d1a55f4142e"/></dir><dir name="Model"><file name="Abstract.php" hash="45d300c4b9b40c8940b14b491681d47e"/><file name="Notification.php" hash="c1fec7e28db44d448c12f1eb30bd0a9c"/><dir name="Observers"><file name="Abstract.php" hash="f86aa41a54f1e840c253e7e191e59538"/><file name="AdminUserLoginFailed.php" hash="60191213630c28b7a62146c22cd82fef"/><file name="AdminUserLoginSuccess.php" hash="c43efd74af494719aa1fc48e8ae7110a"/><file name="DailyStats.php" hash="c4cd888f88d684bab62fd8e2211bb821"/><file name="Interface.php" hash="6d4996e4e5d815071b2f377b8dbe68d0"/><file name="NewCreditmemo.php" hash="5f8c5219720ca77e1c2ee2f31bb88fa7"/><file name="NewCustomer.php" hash="af00e41f97e6f133e66fb46b0198a125"/><file name="NewInvoice.php" hash="0664b32b9b571cdc4927673c206b146b"/><file name="NewOrder.php" hash="d0d7a9f6e8d80a069c7f843d8770bac1"/><file name="NewShipment.php" hash="28d34753f92ec7368ddd25769eff9c15"/></dir><file name="Queue.php" hash="6d1a3ef3a3f995c924e8ebe4396a4053"/><dir name="Resource"><dir name="Queue"><file name="Collection.php" hash="025cdeade0a997613663e3c2bda8bf10"/></dir><file name="Queue.php" hash="5afce1d6866689dc586ecda2500245c9"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="9dd77853d19351f70d8b2f9eca75c21f"/><file name="config.xml" hash="4cfc656c518cbe10ff78d59f5bccebf2"/><file name="system.xml" hash="dce8ddf6e6cd90d8d8581422e31fbf34"/></dir><dir name="sql"><dir name="intelivemetrics_slack_setup"><file name="install-0.4.0.php" hash="223e5c4eab9b7842a859b3dc072db96c"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Intelivemetrics_Slack.xml" hash="c9c1ad068381f13a506680f61ede49ba"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>7.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|