Version Notes
Install extension and configure at Promotions > Opt It.
Download this release
Release Info
Developer | Technivant |
Extension | Optit |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Interest.php +51 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Interest/Edit.php +43 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Interest/Edit/Form.php +54 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Interest/Grid.php +113 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Interest/Grid/Renderer/Action.php +45 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Keyword.php +20 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Keyword/Edit.php +37 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Keyword/Edit/Form.php +119 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Keyword/Grid.php +125 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Keyword/Grid/Renderer/Action.php +56 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Member.php +19 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Member/Grid.php +122 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Member/Grid/Renderer/Action.php +19 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Mms.php +43 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Mms/Edit.php +40 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Mms/Edit/Form.php +106 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Mms/Grid.php +58 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Sms.php +43 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Sms/Edit.php +40 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Sms/Edit/Form.php +93 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Sms/Grid.php +58 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription.php +141 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Edit.php +49 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Edit/Form.php +222 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Grid.php +109 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Grid/Renderer/Action.php +54 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Subscribe/Edit.php +47 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Subscribe/Edit/Form.php +56 -0
- app/code/local/Inchoo/Optit/Block/Adminhtml/Widget/Grid/Column/Renderer/Action.php +74 -0
- app/code/local/Inchoo/Optit/Helper/Data.php +7 -0
- app/code/local/Inchoo/Optit/Model/Abstract.php +59 -0
- app/code/local/Inchoo/Optit/Model/Client.php +20 -0
- app/code/local/Inchoo/Optit/Model/Collecition.php +13 -0
- app/code/local/Inchoo/Optit/Model/Interest.php +105 -0
- app/code/local/Inchoo/Optit/Model/Keyword.php +165 -0
- app/code/local/Inchoo/Optit/Model/Member.php +56 -0
- app/code/local/Inchoo/Optit/Model/Message.php +159 -0
- app/code/local/Inchoo/Optit/Model/Resource/Message.php +10 -0
- app/code/local/Inchoo/Optit/Model/Resource/Message/Collection.php +101 -0
- app/code/local/Inchoo/Optit/Model/Resource/Phone.php +28 -0
- app/code/local/Inchoo/Optit/Model/Subscription.php +234 -0
- app/code/local/Inchoo/Optit/Model/System/Config/Source/Billing/Type.php +13 -0
- app/code/local/Inchoo/Optit/Model/System/Config/Source/Customer/Gender.php +14 -0
- app/code/local/Inchoo/Optit/Model/System/Config/Source/Message/Keyword.php +40 -0
- app/code/local/Inchoo/Optit/Model/System/Config/Source/Subscribed/Message/Type.php +14 -0
- app/code/local/Inchoo/Optit/Model/System/Config/Source/Subscription/Interest.php +39 -0
- app/code/local/Inchoo/Optit/Model/System/Config/Source/Subscription/Phone.php +63 -0
- app/code/local/Inchoo/Optit/Model/System/Config/Source/Web/Form/Message/Type.php +13 -0
- app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/BulkController.php +115 -0
- app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/InterestController.php +213 -0
- app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/KeywordController.php +126 -0
- app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/MemberController.php +54 -0
- app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/MessageController.php +204 -0
- app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/SubscriptionController.php +151 -0
- app/code/local/Inchoo/Optit/etc/adminhtml.xml +96 -0
- app/code/local/Inchoo/Optit/etc/config.xml +71 -0
- app/code/local/Inchoo/Optit/etc/system.xml +35 -0
- app/code/local/Inchoo/Optit/sql/optit_setup/install-0.1.0.php +104 -0
- app/design/adminhtml/default/default/layout/optit.xml +111 -0
- app/design/adminhtml/default/default/template/optit/grid.phtml +216 -0
- app/etc/modules/Inchoo_Optit.xml +9 -0
- package.xml +20 -0
app/code/local/Inchoo/Optit/Block/Adminhtml/Interest.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inchoo_Optit_Block_Adminhtml_Interest extends Mage_Adminhtml_Block_Widget_Grid_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
$this->_blockGroup = 'optit';
|
8 |
+
$this->_controller = 'adminhtml_interest';
|
9 |
+
|
10 |
+
parent::__construct();
|
11 |
+
$this->removeButton('add');
|
12 |
+
$this->addButton('back', array(
|
13 |
+
'label' => $this->__('Back'),
|
14 |
+
'onclick' => "setLocation('{$this->getBackUrl()}')",
|
15 |
+
'class' => 'back'
|
16 |
+
), 0, 1);
|
17 |
+
$this->addButton('add', array(
|
18 |
+
'label' => $this->__('New Interest'),
|
19 |
+
'onclick' => "setLocation('{$this->getNewUrl()}')",
|
20 |
+
'class' => 'add'
|
21 |
+
), 0, 4);
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _prepareLayout()
|
25 |
+
{
|
26 |
+
return parent::_prepareLayout();
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getBackUrl()
|
30 |
+
{
|
31 |
+
return $this->getUrl('*/optit_keyword', array('keyword_name' => $this->_getKeywordName()));
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getNewUrl()
|
35 |
+
{
|
36 |
+
return $this->getUrl('*/*/new', array(
|
37 |
+
'keyword_id' => $this->getRequest()->getParam('keyword_id'),
|
38 |
+
'keyword_name' => $this->_getKeywordName(),
|
39 |
+
));
|
40 |
+
}
|
41 |
+
|
42 |
+
public function getHeaderText()
|
43 |
+
{
|
44 |
+
return $this->__("Interests for '%s'", $this->_getKeywordName());
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _getKeywordName()
|
48 |
+
{
|
49 |
+
return $this->getRequest()->getParam('keyword_name');
|
50 |
+
}
|
51 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Interest/Edit.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Interest_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = 'optit';
|
9 |
+
$this->_controller = 'adminhtml_interest';
|
10 |
+
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', $this->__('Save Interest'));
|
14 |
+
$this->_updateButton('back', 'onclick', "setLocation('{$this->getBackUrl()}')");
|
15 |
+
$this->_removeButton('delete');
|
16 |
+
$this->_removeButton('reset');
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getHeaderText()
|
20 |
+
{
|
21 |
+
return $this->__("New Interest for '%s'", $this->_getKeywordName());
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getBackUrl()
|
25 |
+
{
|
26 |
+
return $this->getUrl('*/optit_interest', array(
|
27 |
+
'keyword_id' => $this->getRequest()->getParam('keyword_id'),
|
28 |
+
'keyword_name' => $this->_getKeywordName()
|
29 |
+
));
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getSaveUrl()
|
33 |
+
{
|
34 |
+
return $this->getUrl('*/*/save', array(
|
35 |
+
'keyword_name' => $this->_getKeywordName(),
|
36 |
+
));
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function _getKeywordName()
|
40 |
+
{
|
41 |
+
return $this->getRequest()->getParam('keyword_name');
|
42 |
+
}
|
43 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Interest/Edit/Form.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inchoo_Optit_Block_Adminhtml_Interest_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->setId('optit_interest_form');
|
10 |
+
$this->setTitle($this->__('New Interest'));
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _prepareForm()
|
14 |
+
{
|
15 |
+
$form = new Varien_Data_Form(array(
|
16 |
+
'id' => 'edit_form',
|
17 |
+
'action' => $this->getData('action'),
|
18 |
+
'method' => 'post'
|
19 |
+
));
|
20 |
+
|
21 |
+
$fieldset = $form->addFieldset('base_fieldset', array(
|
22 |
+
'legend' => $this->__('Interest'),
|
23 |
+
'class' => 'fieldset',
|
24 |
+
));
|
25 |
+
|
26 |
+
$fieldset->addField('keyword_id', 'hidden', array(
|
27 |
+
'name' => 'keyword_id',
|
28 |
+
'value'=> $this->getRequest()->getParam('keyword_id'),
|
29 |
+
));
|
30 |
+
|
31 |
+
$fieldset->addField('name', 'text', array(
|
32 |
+
'name' => 'name',
|
33 |
+
'label' => $this->__('Name'),
|
34 |
+
'title' => $this->__('Name'),
|
35 |
+
'required' => true,
|
36 |
+
));
|
37 |
+
|
38 |
+
$fieldset->addField('description', 'text', array(
|
39 |
+
'name' => 'description',
|
40 |
+
'label' => $this->__('Description'),
|
41 |
+
'title' => $this->__('Description'),
|
42 |
+
));
|
43 |
+
|
44 |
+
if ($data = Mage::getSingleton('adminhtml/session')->getFormData()) {
|
45 |
+
$form->setValues($data);
|
46 |
+
Mage::getSingleton('adminhtml/session')->setFormData(null);
|
47 |
+
}
|
48 |
+
|
49 |
+
$form->setUseContainer(true);
|
50 |
+
$this->setForm($form);
|
51 |
+
|
52 |
+
return parent::_prepareForm();
|
53 |
+
}
|
54 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Interest/Grid.php
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inchoo_Optit_Block_Adminhtml_Interest_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->setId('optit_interest_grid');
|
10 |
+
$this->setSaveParametersInSession(true);
|
11 |
+
$this->setUseAjax(true);
|
12 |
+
$this->setFilterVisibility(false);
|
13 |
+
}
|
14 |
+
|
15 |
+
protected function _prepareCollection()
|
16 |
+
{
|
17 |
+
$collection = new Inchoo_Optit_Model_Collecition();
|
18 |
+
$data = $this->getData();
|
19 |
+
if (isset($data['interests']) && !empty($data['interests'])) {
|
20 |
+
foreach ($data['interests'] as $keyword) {
|
21 |
+
$keywordObj = new Varien_Object();
|
22 |
+
$keywordObj->setData($keyword['interest']);
|
23 |
+
$collection->addItem($keywordObj);
|
24 |
+
}
|
25 |
+
|
26 |
+
$totalPages = $data['total_pages'];
|
27 |
+
$currentPage = $data['current_page'];
|
28 |
+
|
29 |
+
if ($currentPage <= $totalPages) {
|
30 |
+
$collection->setCurPage($currentPage);
|
31 |
+
$collection->setSize(Inchoo_Optit_Model_Collecition::OPTIT_ITEMS_COLLECTION_SIZE * $totalPages);
|
32 |
+
} else {
|
33 |
+
$this->setVarNamePage(1);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
$this->setCollection($collection);
|
39 |
+
return parent::_prepareCollection();
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _preparePage()
|
43 |
+
{
|
44 |
+
$this->getCollection()->setPageSize((int) $this->getParam($this->getVarNameLimit(), $this->_defaultLimit));
|
45 |
+
// $this->getCollection()->setCurPage((int) $this->getParam($this->getVarNamePage(), $this->_defaultPage));
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function _prepareColumns()
|
49 |
+
{
|
50 |
+
$this->addColumn('id',
|
51 |
+
array(
|
52 |
+
'header'=> $this->__('ID'),
|
53 |
+
'align' =>'right',
|
54 |
+
'width' => '50px',
|
55 |
+
'index' => 'id',
|
56 |
+
'sortable' => false,
|
57 |
+
)
|
58 |
+
);
|
59 |
+
|
60 |
+
$this->addColumn('name',
|
61 |
+
array(
|
62 |
+
'header'=> $this->__('Name'),
|
63 |
+
'index' => 'name',
|
64 |
+
'sortable' => false,
|
65 |
+
)
|
66 |
+
);
|
67 |
+
|
68 |
+
$this->addColumn('description',
|
69 |
+
array(
|
70 |
+
'header'=> $this->__('Description'),
|
71 |
+
'index' => 'description',
|
72 |
+
'sortable' => false,
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
$this->addColumn('created_at',
|
77 |
+
array(
|
78 |
+
'header'=> $this->__('Created At'),
|
79 |
+
'index' => 'created_at',
|
80 |
+
'sortable' => false,
|
81 |
+
)
|
82 |
+
);
|
83 |
+
|
84 |
+
$this->addColumn('subscription_count',
|
85 |
+
array(
|
86 |
+
'header'=> $this->__('Subscription Count'),
|
87 |
+
'index' => 'mobile_subscription_count',
|
88 |
+
'sortable' => false,
|
89 |
+
)
|
90 |
+
);
|
91 |
+
|
92 |
+
$this->addColumn('status',
|
93 |
+
array(
|
94 |
+
'header'=> $this->__('Status'),
|
95 |
+
'index' => 'status',
|
96 |
+
'sortable' => false,
|
97 |
+
)
|
98 |
+
);
|
99 |
+
|
100 |
+
$this->addColumn('action',
|
101 |
+
array(
|
102 |
+
'header'=> $this->__('Actions'),
|
103 |
+
'index' => 'id',
|
104 |
+
'sortable' => false,
|
105 |
+
'filter' => false,
|
106 |
+
'no_link' => true,
|
107 |
+
'width' => '160px',
|
108 |
+
'renderer' => 'optit/adminhtml_interest_grid_renderer_action'
|
109 |
+
)
|
110 |
+
);
|
111 |
+
return parent::_prepareColumns();
|
112 |
+
}
|
113 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Interest/Grid/Renderer/Action.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inchoo_Optit_Block_Adminhtml_Interest_Grid_Renderer_Action extends Inchoo_Optit_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
4 |
+
{
|
5 |
+
public function render(Varien_Object $row)
|
6 |
+
{
|
7 |
+
$actions = array();
|
8 |
+
$actions[] = array(
|
9 |
+
'url' => $this->getUrl('*/optit_subscription/interest', array(
|
10 |
+
'interest_id' => $row->getId(),
|
11 |
+
'keyword_id' => $this->getRequest()->getParam('keyword_id'),
|
12 |
+
'keyword_name' => $this->getRequest()->getParam('keyword_name'),
|
13 |
+
'type_name' => $row->getName()
|
14 |
+
)),
|
15 |
+
'caption' => $this->__('View Subscriptions')
|
16 |
+
);
|
17 |
+
|
18 |
+
$actions[] = array(
|
19 |
+
'url' => $this->getUrl('*/optit_interest/subscribe', array(
|
20 |
+
'interest_id' => $row->getId(),
|
21 |
+
'keyword_id' => $this->getRequest()->getParam('keyword_id'),
|
22 |
+
'keyword_name' => $this->getRequest()->getParam('keyword_name'),
|
23 |
+
'type_name' => $row->getName(),
|
24 |
+
)),
|
25 |
+
'caption' => $this->__('Subscribe a Member')
|
26 |
+
);
|
27 |
+
|
28 |
+
if ($row->getStatus() == 'Active') {
|
29 |
+
$actions[] = array(
|
30 |
+
'url' => $this->getUrl('*/optit_message/sms', array(
|
31 |
+
'id' => $row->getId(),
|
32 |
+
'type' => Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_INTEREST,
|
33 |
+
'keyword_name' => $this->getRequest()->getParam('keyword_name'),
|
34 |
+
'type_name' => $row->getName(),
|
35 |
+
)),
|
36 |
+
'caption' => $this->__('Send Message'),
|
37 |
+
'confirm' => $this->__('Are you sure you want to send SMS to these subscribers?'),
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
$this->getColumn()->setActions($actions);
|
42 |
+
|
43 |
+
return parent::render($row);
|
44 |
+
}
|
45 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Keyword.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Keyword extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = 'optit';
|
9 |
+
$this->_controller = 'adminhtml_keyword';
|
10 |
+
$this->_headerText = 'Keywords';
|
11 |
+
|
12 |
+
parent::__construct();
|
13 |
+
$this->updateButton('add', 'label', $this->__('New Keyword'));
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _prepareLayout()
|
17 |
+
{
|
18 |
+
return parent::_prepareLayout();
|
19 |
+
}
|
20 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Keyword/Edit.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Keyword_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = 'optit';
|
9 |
+
$this->_controller = 'adminhtml_keyword';
|
10 |
+
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', $this->__('Save Keyword'));
|
14 |
+
$this->_removeButton('delete');
|
15 |
+
$this->_removeButton('delete');
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getHeaderText()
|
19 |
+
{
|
20 |
+
if (Mage::registry('optit_keyword')->getId()) {
|
21 |
+
return $this->__("Edit Keyword '%s'", $this->_getKeywordName());
|
22 |
+
}
|
23 |
+
else {
|
24 |
+
return $this->__("New Keyword");
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getSaveUrl()
|
29 |
+
{
|
30 |
+
return $this->getUrl('*/*/save', array('id ' => $this->getRequest()->getParam('id')));
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _getKeywordName()
|
34 |
+
{
|
35 |
+
return $this->getRequest()->getParam('keyword_name');
|
36 |
+
}
|
37 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Keyword/Edit/Form.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Keyword_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
|
10 |
+
$this->setId('optit_keyword_form');
|
11 |
+
$this->setTitle($this->__('Keyword Edit'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareForm()
|
15 |
+
{
|
16 |
+
$model = Mage::registry('optit_keyword');
|
17 |
+
|
18 |
+
$form = new Varien_Data_Form(array(
|
19 |
+
'id' => 'edit_form',
|
20 |
+
'action' => $this->getData('action'),
|
21 |
+
'method' => 'post'
|
22 |
+
));
|
23 |
+
|
24 |
+
$fieldset = $form->addFieldset('base_fieldset', array(
|
25 |
+
'legend' => $this->__('Keyword'),
|
26 |
+
'class' => 'fieldset',
|
27 |
+
));
|
28 |
+
|
29 |
+
$fieldset->addField('billing_type', 'select', array(
|
30 |
+
'name' => 'billing_type',
|
31 |
+
'label' => $this->__('Billing Type'),
|
32 |
+
'title' => $this->__('Billing Type'),
|
33 |
+
'values' => Mage::getSingleton('optit/system_config_source_billing_type')->toOptionArray(),
|
34 |
+
'required' => true,
|
35 |
+
));
|
36 |
+
|
37 |
+
if ($model->getId()) {
|
38 |
+
$fieldset->addField('id', 'hidden', array(
|
39 |
+
'name' => 'id',
|
40 |
+
));
|
41 |
+
|
42 |
+
$fieldset->addField('keyword_name', 'text', array(
|
43 |
+
'name' => 'keyword_name',
|
44 |
+
'label' => $this->__('Keyword Name'),
|
45 |
+
'title' => $this->__('Keyword Name'),
|
46 |
+
'disabled' => true,
|
47 |
+
));
|
48 |
+
} else {
|
49 |
+
$fieldset->addField('keyword', 'text', array(
|
50 |
+
'name' => 'keyword',
|
51 |
+
'label' => $this->__('Keyword Name'),
|
52 |
+
'title' => $this->__('Keyword Name'),
|
53 |
+
'required' => true,
|
54 |
+
));
|
55 |
+
}
|
56 |
+
|
57 |
+
$fieldset->addField('internal_name', 'text', array(
|
58 |
+
'name' => 'internal_name',
|
59 |
+
'label' => $this->__('Internal Name'),
|
60 |
+
'title' => $this->__('Internal Name'),
|
61 |
+
'required' => true,
|
62 |
+
));
|
63 |
+
|
64 |
+
// TODO: add interest field when interest is associated with keyword
|
65 |
+
|
66 |
+
$fieldset->addField('welcome_msg_type', 'select', array(
|
67 |
+
'name' => 'welcome_msg_type',
|
68 |
+
'label' => $this->__('Welcome Message Type'),
|
69 |
+
'title' => $this->__('Welcome Message Type'),
|
70 |
+
'values' => Mage::getSingleton('optit/system_config_source_web_form_message_type')->toOptionArray()
|
71 |
+
));
|
72 |
+
|
73 |
+
$fieldset->addField('welcome_msg', 'textarea', array(
|
74 |
+
'name' => 'welcome_msg',
|
75 |
+
'label' => $this->__('Welcome Message'),
|
76 |
+
'title' => $this->__('Welcome Message'),
|
77 |
+
'class' => 'validate-length maximum-length-93',
|
78 |
+
'note' => $this->__('Maximum length %d characters', 160)
|
79 |
+
|
80 |
+
));
|
81 |
+
|
82 |
+
$fieldset->addField('web_form_verification_msg_type', 'select', array(
|
83 |
+
'name' => 'web_form_verification_msg_type',
|
84 |
+
'label' => $this->__('Web Form Verification Message Type'),
|
85 |
+
'title' => $this->__('Web Form Verification Message Type'),
|
86 |
+
'values' => Mage::getSingleton('optit/system_config_source_web_form_message_type')->toOptionArray()
|
87 |
+
));
|
88 |
+
|
89 |
+
$fieldset->addField('web_form_verification_msg', 'textarea', array(
|
90 |
+
'name' => 'web_form_verification_msg',
|
91 |
+
'label' => $this->__('Web Form Verification Message'),
|
92 |
+
'title' => $this->__('Web Form Verification Message'),
|
93 |
+
'class' => 'validate-length maximum-length-120',
|
94 |
+
'note' => $this->__('Maximum length %d characters', 120)
|
95 |
+
|
96 |
+
));
|
97 |
+
|
98 |
+
$fieldset->addField('already_subscribed_msg_type', 'select', array(
|
99 |
+
'name' => 'already_subscribed_msg_type',
|
100 |
+
'label' => $this->__('Already Subscribed Message Type'),
|
101 |
+
'title' => $this->__('Already Subscribed Message Type'),
|
102 |
+
'values' => Mage::getSingleton('optit/system_config_source_subscribed_message_type')->toOptionArray()
|
103 |
+
));
|
104 |
+
|
105 |
+
$fieldset->addField('already_subscribed_msg', 'textarea', array(
|
106 |
+
'name' => 'already_subscribed_msg',
|
107 |
+
'label' => $this->__('Already Subscribed Message'),
|
108 |
+
'title' => $this->__('Already Subscribed Message'),
|
109 |
+
'class' => 'validate-length maximum-length-160',
|
110 |
+
'note' => $this->__('Maximum length %d characters', 160)
|
111 |
+
));
|
112 |
+
|
113 |
+
$form->setValues($model->getData());
|
114 |
+
$form->setUseContainer(true);
|
115 |
+
$this->setForm($form);
|
116 |
+
|
117 |
+
return parent::_prepareForm();
|
118 |
+
}
|
119 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Keyword/Grid.php
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Keyword_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
|
10 |
+
$this->setId('optit_keyword_grid');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
$this->setUseAjax(true);
|
13 |
+
$this->setFilterVisibility(false);
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _prepareCollection()
|
17 |
+
{
|
18 |
+
$collection = new Inchoo_Optit_Model_Collecition();
|
19 |
+
$data = $this->getData();
|
20 |
+
if (isset($data['keywords']) && !empty($data['keywords'])) {
|
21 |
+
foreach ($data['keywords'] as $keyword) {
|
22 |
+
$keywordObj = new Varien_Object();
|
23 |
+
$keywordObj->setData($keyword['keyword']);
|
24 |
+
$collection->addItem($keywordObj);
|
25 |
+
}
|
26 |
+
|
27 |
+
$totalPages = $data['total_pages'];
|
28 |
+
$currentPage = $data['current_page'];
|
29 |
+
|
30 |
+
if ($currentPage <= $totalPages) {
|
31 |
+
$collection->setCurPage($currentPage);
|
32 |
+
$collection->setSize(Inchoo_Optit_Model_Collecition::OPTIT_ITEMS_COLLECTION_SIZE * $totalPages);
|
33 |
+
} else {
|
34 |
+
$this->setVarNamePage(1);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
$this->setCollection($collection);
|
39 |
+
return parent::_prepareCollection();
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _preparePage()
|
43 |
+
{
|
44 |
+
$this->getCollection()->setPageSize((int)$this->getParam($this->getVarNameLimit(), $this->_defaultLimit));
|
45 |
+
// $this->getCollection()->setCurPage((int) $this->getParam($this->getVarNamePage(), $this->_defaultPage));
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function _prepareColumns()
|
49 |
+
{
|
50 |
+
$this->addColumn('id',
|
51 |
+
array(
|
52 |
+
'header' => $this->__('ID'),
|
53 |
+
'align' => 'right',
|
54 |
+
'width' => '50px',
|
55 |
+
'index' => 'id',
|
56 |
+
'sortable' => false,
|
57 |
+
)
|
58 |
+
);
|
59 |
+
|
60 |
+
$this->addColumn('keyword',
|
61 |
+
array(
|
62 |
+
'header' => $this->__('Keyword'),
|
63 |
+
'index' => 'keyword_name',
|
64 |
+
'sortable' => false,
|
65 |
+
)
|
66 |
+
);
|
67 |
+
|
68 |
+
$this->addColumn('name',
|
69 |
+
array(
|
70 |
+
'header' => $this->__('Name'),
|
71 |
+
'index' => 'internal_name',
|
72 |
+
'sortable' => false,
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
$this->addColumn('type',
|
77 |
+
array(
|
78 |
+
'header' => $this->__('Type'),
|
79 |
+
'index' => 'keyword_type',
|
80 |
+
'sortable' => false,
|
81 |
+
)
|
82 |
+
);
|
83 |
+
|
84 |
+
$this->addColumn('short_code',
|
85 |
+
array(
|
86 |
+
'header' => $this->__('Short Code'),
|
87 |
+
'index' => 'short_code',
|
88 |
+
'sortable' => false,
|
89 |
+
)
|
90 |
+
);
|
91 |
+
|
92 |
+
$this->addColumn('status',
|
93 |
+
array(
|
94 |
+
'header' => $this->__('Status'),
|
95 |
+
'index' => 'status',
|
96 |
+
'sortable' => false,
|
97 |
+
)
|
98 |
+
);
|
99 |
+
|
100 |
+
$this->addColumn('subscription_count',
|
101 |
+
array(
|
102 |
+
'header' => $this->__('Subscription Count'),
|
103 |
+
'index' => 'mobile_subscription_count',
|
104 |
+
'sortable' => false,
|
105 |
+
)
|
106 |
+
);
|
107 |
+
|
108 |
+
$this->addColumn('action',
|
109 |
+
array(
|
110 |
+
'header' => $this->__('Actions'),
|
111 |
+
'sortable' => false,
|
112 |
+
'filter' => false,
|
113 |
+
'no_link' => true,
|
114 |
+
'width' => '160px',
|
115 |
+
'renderer' => 'optit/adminhtml_keyword_grid_renderer_action'
|
116 |
+
)
|
117 |
+
);
|
118 |
+
return parent::_prepareColumns();
|
119 |
+
}
|
120 |
+
|
121 |
+
public function getRowUrl($row)
|
122 |
+
{
|
123 |
+
return $this->getUrl('*/optit_keyword/edit', array('id' => $row->getId()));
|
124 |
+
}
|
125 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Keyword/Grid/Renderer/Action.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Keyword_Grid_Renderer_Action extends Inchoo_Optit_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
5 |
+
{
|
6 |
+
public function render(Varien_Object $row)
|
7 |
+
{
|
8 |
+
$actions = array();
|
9 |
+
$actions[] = array(
|
10 |
+
'url' => $this->getUrl('*/optit_keyword/edit', array(
|
11 |
+
'id' => $row->getId(),
|
12 |
+
'keyword_name' => $row->getKeywordName(),
|
13 |
+
)),
|
14 |
+
'caption' => $this->__('Edit'),
|
15 |
+
);
|
16 |
+
|
17 |
+
$actions[] = array(
|
18 |
+
'url' => $this->getUrl('*/optit_subscription/', array(
|
19 |
+
'keyword_id' => $row->getId(),
|
20 |
+
'type_name' => $row->getKeywordName(),
|
21 |
+
)),
|
22 |
+
'caption' => $this->__('View Subscriptions'),
|
23 |
+
);
|
24 |
+
|
25 |
+
$actions[] = array(
|
26 |
+
'url' => $this->getUrl('*/optit_interest/', array('keyword_id' => $row->getId(), 'keyword_name' => $row->getKeywordName())),
|
27 |
+
'caption' => $this->__('View Interests'),
|
28 |
+
);
|
29 |
+
|
30 |
+
if ($row->getStatus() == 'Active') {
|
31 |
+
$actions[] = array(
|
32 |
+
'url' => $this->getUrl('*/optit_message/sms', array(
|
33 |
+
'id' => $row->getId(),
|
34 |
+
'type' => Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_KEYWORD,
|
35 |
+
'keyword_name' => $row->getKeywordName(),
|
36 |
+
)),
|
37 |
+
'caption' => $this->__('Send SMS'),
|
38 |
+
'confirm' => $this->__('Are you sure you want to send SMS to these subscribers?'),
|
39 |
+
);
|
40 |
+
|
41 |
+
$actions[] = array(
|
42 |
+
'url' => $this->getUrl('*/optit_message/mms', array(
|
43 |
+
'id' => $row->getId(),
|
44 |
+
'type' => Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_KEYWORD,
|
45 |
+
'keyword_name' => $row->getKeywordName(),
|
46 |
+
)),
|
47 |
+
'caption' => $this->__('Send MMS'),
|
48 |
+
'confirm' => $this->__('Are you sure you want to send MMS to these subscribers?'),
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
$this->getColumn()->setActions($actions);
|
53 |
+
|
54 |
+
return parent::render($row);
|
55 |
+
}
|
56 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Member.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inchoo_Optit_Block_Adminhtml_Member extends Mage_Adminhtml_Block_Widget_Grid_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
$this->_blockGroup = 'optit';
|
8 |
+
$this->_controller = 'adminhtml_member';
|
9 |
+
$this->_headerText = 'Members';
|
10 |
+
|
11 |
+
parent::__construct();
|
12 |
+
$this->removeButton('add');
|
13 |
+
}
|
14 |
+
|
15 |
+
protected function _prepareLayout()
|
16 |
+
{
|
17 |
+
return parent::_prepareLayout();
|
18 |
+
}
|
19 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Member/Grid.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Member_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
|
10 |
+
$this->setId('optit_member_grid');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
$this->setUseAjax(true);
|
13 |
+
$this->setFilterVisibility(false);
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _prepareCollection()
|
17 |
+
{
|
18 |
+
$collection = new Inchoo_Optit_Model_Collecition();
|
19 |
+
$data = $this->getData();
|
20 |
+
if (isset($data['members']) && !empty($data['members'])) {
|
21 |
+
foreach ($data['members'] as $member) {
|
22 |
+
$memberObj = new Varien_Object();
|
23 |
+
$memberObj->setData($member['member']);
|
24 |
+
$collection->addItem($memberObj);
|
25 |
+
}
|
26 |
+
|
27 |
+
$totalPages = $data['total_pages'];
|
28 |
+
$currentPage = $data['current_page'];
|
29 |
+
|
30 |
+
if ($currentPage <= $totalPages) {
|
31 |
+
$collection->setCurPage($currentPage);
|
32 |
+
$collection->setSize(Inchoo_Optit_Model_Collecition::OPTIT_ITEMS_COLLECTION_SIZE * $totalPages);
|
33 |
+
} else {
|
34 |
+
$this->setVarNamePage(1);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
$this->setCollection($collection);
|
39 |
+
return parent::_prepareCollection();
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _preparePage()
|
43 |
+
{
|
44 |
+
$this->getCollection()->setPageSize((int)$this->getParam($this->getVarNameLimit(), $this->_defaultLimit));
|
45 |
+
// $this->getCollection()->setCurPage((int) $this->getParam($this->getVarNamePage(), $this->_defaultPage));
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function _prepareColumns()
|
49 |
+
{
|
50 |
+
$this->addColumn('id',
|
51 |
+
array(
|
52 |
+
'header'=> $this->__('ID'),
|
53 |
+
'align' =>'right',
|
54 |
+
'width' => '50px',
|
55 |
+
'index' => 'id',
|
56 |
+
'sortable' => false,
|
57 |
+
)
|
58 |
+
);
|
59 |
+
|
60 |
+
$this->addColumn('first_name',
|
61 |
+
array(
|
62 |
+
'header'=> $this->__('First Name'),
|
63 |
+
'index' => 'first_name',
|
64 |
+
'sortable' => false,
|
65 |
+
)
|
66 |
+
);
|
67 |
+
|
68 |
+
$this->addColumn('last_name',
|
69 |
+
array(
|
70 |
+
'header'=> $this->__('Last Name'),
|
71 |
+
'index' => 'last_name',
|
72 |
+
'sortable' => false,
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
$this->addColumn('carrier_name',
|
77 |
+
array(
|
78 |
+
'header'=> $this->__('Carrier Name'),
|
79 |
+
'index' => 'carrier_name',
|
80 |
+
'sortable' => false,
|
81 |
+
)
|
82 |
+
);
|
83 |
+
|
84 |
+
$this->addColumn('phone',
|
85 |
+
array(
|
86 |
+
'header'=> $this->__('Phone'),
|
87 |
+
'index' => 'phone',
|
88 |
+
'sortable' => false,
|
89 |
+
)
|
90 |
+
);
|
91 |
+
|
92 |
+
$this->addColumn('created_at',
|
93 |
+
array(
|
94 |
+
'header'=> $this->__('Created At'),
|
95 |
+
'index' => 'created_at',
|
96 |
+
'sortable' => false,
|
97 |
+
)
|
98 |
+
);
|
99 |
+
|
100 |
+
$this->addColumn('mobile_status',
|
101 |
+
array(
|
102 |
+
'header'=> $this->__('Status'),
|
103 |
+
'index' => 'mobile_status',
|
104 |
+
'sortable' => false,
|
105 |
+
)
|
106 |
+
);
|
107 |
+
|
108 |
+
|
109 |
+
$this->addColumn('action',
|
110 |
+
array(
|
111 |
+
'header'=> $this->__('Actions'),
|
112 |
+
'index' => 'id',
|
113 |
+
'sortable' => false,
|
114 |
+
'filter' => false,
|
115 |
+
'no_link' => true,
|
116 |
+
'width' => '200px',
|
117 |
+
'renderer' => 'optit/adminhtml_member_grid_renderer_action'
|
118 |
+
)
|
119 |
+
);
|
120 |
+
return parent::_prepareColumns();
|
121 |
+
}
|
122 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Member/Grid/Renderer/Action.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Member_Grid_Renderer_Action extends Inchoo_Optit_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
5 |
+
{
|
6 |
+
public function render(Varien_Object $row)
|
7 |
+
{
|
8 |
+
$actions = array();
|
9 |
+
$actions[] = array(
|
10 |
+
'url' => $this->getUrl('*/optit_member/unsubscribe', array('phone' => $row->getPhone())),
|
11 |
+
'caption' => $this->__('Unsubscribe From All Keywords'),
|
12 |
+
'confirm' => $this->__('Are you sure you want to unsubscribe member from all keywords?')
|
13 |
+
);
|
14 |
+
|
15 |
+
$this->getColumn()->setActions($actions);
|
16 |
+
|
17 |
+
return parent::render($row);
|
18 |
+
}
|
19 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Mms.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Message_Mms extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = 'optit';
|
9 |
+
$this->_controller = 'adminhtml_message_mms';
|
10 |
+
$this->_headerText = 'MMS Messages';
|
11 |
+
|
12 |
+
parent::__construct();
|
13 |
+
$this->removeButton('add');
|
14 |
+
$confirmationMessage = Mage::helper('core')->jsQuoteEscape(
|
15 |
+
$this->__('Are you sure you want to clear this bulk list?')
|
16 |
+
);
|
17 |
+
$this->addButton('clear', array(
|
18 |
+
'label' => $this->__('Clear'),
|
19 |
+
'class' => 'delete',
|
20 |
+
'onclick' => "confirmSetLocation('{$confirmationMessage}', '{$this->getClearUrl()}')",
|
21 |
+
));
|
22 |
+
$this->addButton('send', array(
|
23 |
+
'label' => $this->__('Send'),
|
24 |
+
'class' => 'go',
|
25 |
+
'onclick' => "setLocation('{$this->getSendUrl()}')",
|
26 |
+
));
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _prepareLayout()
|
30 |
+
{
|
31 |
+
return parent::_prepareLayout();
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function getSendUrl()
|
35 |
+
{
|
36 |
+
return $this->getUrl('*/*/sendMms');
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function getClearUrl()
|
40 |
+
{
|
41 |
+
return $this->getUrl('*/*/clear', array('type' => Inchoo_Optit_Model_Message::MESSAGE_TYPE_MMS));
|
42 |
+
}
|
43 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Mms/Edit.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Message_Mms_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = 'optit';
|
9 |
+
$this->_controller = 'adminhtml_message_mms';
|
10 |
+
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->updateButton('save', 'label', $this->__('Send'));
|
14 |
+
$this->updateButton('save', 'class', 'go');
|
15 |
+
$this->removeButton('back');
|
16 |
+
$this->removeButton('delete');
|
17 |
+
$this->removeButton('reset');
|
18 |
+
|
19 |
+
if ($this->getRequest()->getParam('type') !== Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_INTEREST) {
|
20 |
+
$this->addButton('bulk', array(
|
21 |
+
'label' => $this->__('Add To Bulk'),
|
22 |
+
'class' => 'add',
|
23 |
+
'onclick' => "addToBulk();"
|
24 |
+
));
|
25 |
+
|
26 |
+
$this->_formScripts[] = "function addToBulk()" .
|
27 |
+
"{editForm.submit($('edit_form').action + 'bulk/true/')}";
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getHeaderText()
|
32 |
+
{
|
33 |
+
return $this->__("Send Message to '%s'", $this->getRequest()->getParam('type_name'));
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getSaveUrl()
|
37 |
+
{
|
38 |
+
return $this->getUrl('*/*/sendMms');
|
39 |
+
}
|
40 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Mms/Edit/Form.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Message_Mms_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
|
10 |
+
$this->setId('optit_message_mms');
|
11 |
+
$this->setTitle($this->__('New Message'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareForm()
|
15 |
+
{
|
16 |
+
$params = Mage::registry('params');
|
17 |
+
$form = new Varien_Data_Form(array(
|
18 |
+
'id' => 'edit_form',
|
19 |
+
'action' => $this->getData('action'),
|
20 |
+
'method' => 'post',
|
21 |
+
'enctype' => 'multipart/form-data',
|
22 |
+
));
|
23 |
+
|
24 |
+
$fieldset = $form->addFieldset('base_fieldset', array(
|
25 |
+
'legend' => $this->__('MMS'),
|
26 |
+
'class' => 'fieldset',
|
27 |
+
));
|
28 |
+
|
29 |
+
$fieldset->addField('message_type', 'hidden', array(
|
30 |
+
'name' => 'message_type',
|
31 |
+
'value'=> Inchoo_Optit_Model_Message::MESSAGE_TYPE_MMS,
|
32 |
+
));
|
33 |
+
|
34 |
+
if (isset($params['type'])) {
|
35 |
+
$fieldset->addField('id', 'hidden', array(
|
36 |
+
'name' => 'id',
|
37 |
+
'value'=> $params['id'],
|
38 |
+
));
|
39 |
+
|
40 |
+
if ($params['type'] == Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_MEMBER) {
|
41 |
+
$fieldset->addField('phone', 'hidden', array(
|
42 |
+
'name' => 'phone',
|
43 |
+
'value'=> $params['phone'],
|
44 |
+
));
|
45 |
+
}
|
46 |
+
|
47 |
+
$fieldset->addField('type', 'hidden', array(
|
48 |
+
'name' => 'type',
|
49 |
+
'value'=> $params['type'],
|
50 |
+
));
|
51 |
+
} else {
|
52 |
+
$fieldset->addField('id', 'select', array(
|
53 |
+
'name' => 'id',
|
54 |
+
'label' => $this->__('Keyword Id'),
|
55 |
+
'title' => $this->__('Keyword Id'),
|
56 |
+
'required' => true,
|
57 |
+
'values' => $this->getKeywords(),
|
58 |
+
'note' => $this->__('Please choose a keyword'),
|
59 |
+
));
|
60 |
+
|
61 |
+
$fieldset->addField('type', 'hidden', array(
|
62 |
+
'name' => 'type',
|
63 |
+
'value'=> 'keyword',
|
64 |
+
));
|
65 |
+
}
|
66 |
+
|
67 |
+
$fieldset->addField('title', 'text', array(
|
68 |
+
'name' => 'title',
|
69 |
+
'label' => $this->__('Title'),
|
70 |
+
'title' => $this->__('Title'),
|
71 |
+
'required' => true,
|
72 |
+
'note' => $this->__('Please enter a title of message. This does not appear in the text message and is just used in the application as a short description of your message.'),
|
73 |
+
));
|
74 |
+
|
75 |
+
$fieldset->addField('message', 'textarea', array(
|
76 |
+
'name' => 'message',
|
77 |
+
'label' => $this->__('Message'),
|
78 |
+
'title' => $this->__('Message'),
|
79 |
+
'required' => true,
|
80 |
+
'note' => $this->__('Please enter a text message. The message must be less than 160 characters including your keyword in the beginning of the message.'),
|
81 |
+
'class' => 'validate-length maximum-length-160'
|
82 |
+
));
|
83 |
+
|
84 |
+
$fieldset->addField('content_url', 'file', array(
|
85 |
+
'name' => 'content_url',
|
86 |
+
'label' => $this->__('Media'),
|
87 |
+
'title' => $this->__('Media'),
|
88 |
+
'note' => $this->__('Upload a media file to be sent with MMS. Allowed extensions: jpg, jpeg, png, gif, vnd, wap, wbpm, bpm, amr, x-wav, aac, qcp, 3gpp, 3gpp2'),
|
89 |
+
));
|
90 |
+
|
91 |
+
if ($data = Mage::getSingleton('adminhtml/session')->getFormData()) {
|
92 |
+
$form->setValues($data);
|
93 |
+
Mage::getSingleton('adminhtml/session')->setFormData(null);
|
94 |
+
}
|
95 |
+
|
96 |
+
$form->setUseContainer(true);
|
97 |
+
$this->setForm($form);
|
98 |
+
|
99 |
+
return parent::_prepareForm();
|
100 |
+
}
|
101 |
+
|
102 |
+
protected function getType()
|
103 |
+
{
|
104 |
+
return $this->getRequest()->getParam('type');
|
105 |
+
}
|
106 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Mms/Grid.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Message_Mms_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
|
10 |
+
$this->setId('optitBulkMmsGrid');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
$this->setUseAjax(true);
|
13 |
+
$this->setFilterVisibility(false);
|
14 |
+
$this->_emptyText = 'The bulk messaging list is empty. Please use appropriate message forms to create messages and add them to bulk.';
|
15 |
+
}
|
16 |
+
|
17 |
+
protected function _prepareCollection()
|
18 |
+
{
|
19 |
+
$collection = Mage::getModel('optit/message')->getCollection()
|
20 |
+
->addFieldToFilter('message_type', array('eq' => Inchoo_Optit_Model_Message::MESSAGE_TYPE_MMS))
|
21 |
+
->addMessageRecipients();
|
22 |
+
|
23 |
+
$this->setCollection($collection);
|
24 |
+
parent::_prepareCollection();
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _prepareColumns()
|
29 |
+
{
|
30 |
+
$this->addColumn('message_title',
|
31 |
+
array(
|
32 |
+
'header'=> $this->__('Title'),
|
33 |
+
'index' => 'title',
|
34 |
+
'width' => '10%',
|
35 |
+
'sortable' => false,
|
36 |
+
)
|
37 |
+
);
|
38 |
+
|
39 |
+
$this->addColumn('message',
|
40 |
+
array(
|
41 |
+
'header'=> $this->__('Message'),
|
42 |
+
'index' => 'message',
|
43 |
+
'width' => '30%',
|
44 |
+
'sortable' => false,
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
$this->addColumn('recipients',
|
49 |
+
array(
|
50 |
+
'header'=> $this->__('Recipients'),
|
51 |
+
'index' => 'recipients',
|
52 |
+
'sortable' => false,
|
53 |
+
)
|
54 |
+
);
|
55 |
+
|
56 |
+
return parent::_prepareColumns();
|
57 |
+
}
|
58 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Sms.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Message_Sms extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = 'optit';
|
9 |
+
$this->_controller = 'adminhtml_message_sms';
|
10 |
+
$this->_headerText = 'SMS Messages';
|
11 |
+
|
12 |
+
parent::__construct();
|
13 |
+
$this->removeButton('add');
|
14 |
+
$confirmationMessage = Mage::helper('core')->jsQuoteEscape(
|
15 |
+
$this->__('Are you sure you want to clear this bulk list?')
|
16 |
+
);
|
17 |
+
$this->addButton('clear', array(
|
18 |
+
'label' => $this->__('Clear'),
|
19 |
+
'class' => 'delete',
|
20 |
+
'onclick' => "confirmSetLocation('{$confirmationMessage}', '{$this->getClearUrl()}')",
|
21 |
+
));
|
22 |
+
$this->addButton('send', array(
|
23 |
+
'label' => $this->__('Send'),
|
24 |
+
'class' => 'go',
|
25 |
+
'onclick' => "setLocation('{$this->getSendUrl()}')",
|
26 |
+
));
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _prepareLayout()
|
30 |
+
{
|
31 |
+
return parent::_prepareLayout();
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function getSendUrl()
|
35 |
+
{
|
36 |
+
return $this->getUrl('*/*/sendSms');
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function getClearUrl()
|
40 |
+
{
|
41 |
+
return $this->getUrl('*/*/clear', array('type' => Inchoo_Optit_Model_Message::MESSAGE_TYPE_SMS));
|
42 |
+
}
|
43 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Sms/Edit.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Message_Sms_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = 'optit';
|
9 |
+
$this->_controller = 'adminhtml_message_sms';
|
10 |
+
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->updateButton('save', 'label', $this->__('Send'));
|
14 |
+
$this->updateButton('save', 'class', 'go');
|
15 |
+
$this->removeButton('back');
|
16 |
+
$this->removeButton('delete');
|
17 |
+
$this->removeButton('reset');
|
18 |
+
|
19 |
+
if ($this->getRequest()->getParam('type') !== Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_INTEREST) {
|
20 |
+
$this->addButton('bulk', array(
|
21 |
+
'label' => $this->__('Add To Bulk'),
|
22 |
+
'class' => 'add',
|
23 |
+
'onclick' => "addToBulk();"
|
24 |
+
));
|
25 |
+
|
26 |
+
$this->_formScripts[] = "function addToBulk()" .
|
27 |
+
"{editForm.submit($('edit_form').action + 'bulk/true/')}";
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getHeaderText()
|
32 |
+
{
|
33 |
+
return $this->__("Send Message to '%s'", $this->getRequest()->getParam('type_name'));
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getSaveUrl()
|
37 |
+
{
|
38 |
+
return $this->getUrl('*/*/sendSms');
|
39 |
+
}
|
40 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Sms/Edit/Form.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Message_Sms_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
|
10 |
+
$this->setId('optit_message_sms');
|
11 |
+
$this->setTitle($this->__('New Message'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareForm()
|
15 |
+
{
|
16 |
+
$params = Mage::registry('params');
|
17 |
+
$form = new Varien_Data_Form(array(
|
18 |
+
'id' => 'edit_form',
|
19 |
+
'action' => $this->getData('action'),
|
20 |
+
'method' => 'post'
|
21 |
+
));
|
22 |
+
|
23 |
+
$fieldset = $form->addFieldset('base_fieldset', array(
|
24 |
+
'legend' => $this->__('SMS'),
|
25 |
+
'class' => 'fieldset',
|
26 |
+
));
|
27 |
+
|
28 |
+
$fieldset->addField('message_type', 'hidden', array(
|
29 |
+
'name' => 'message_type',
|
30 |
+
'value'=> Inchoo_Optit_Model_Message::MESSAGE_TYPE_SMS,
|
31 |
+
));
|
32 |
+
|
33 |
+
if (isset($params['type'])) {
|
34 |
+
$fieldset->addField('id', 'hidden', array(
|
35 |
+
'name' => 'id',
|
36 |
+
'value'=> $params['id'],
|
37 |
+
));
|
38 |
+
|
39 |
+
if ($params['type'] == Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_MEMBER) {
|
40 |
+
$fieldset->addField('phone', 'hidden', array(
|
41 |
+
'name' => 'phone',
|
42 |
+
'value'=> $params['phone'],
|
43 |
+
));
|
44 |
+
}
|
45 |
+
|
46 |
+
$fieldset->addField('type', 'hidden', array(
|
47 |
+
'name' => 'type',
|
48 |
+
'value'=> $params['type'],
|
49 |
+
));
|
50 |
+
} else {
|
51 |
+
$fieldset->addField('id', 'select', array(
|
52 |
+
'name' => 'id',
|
53 |
+
'label' => $this->__('Keyword Id'),
|
54 |
+
'title' => $this->__('Keyword Id'),
|
55 |
+
'required' => true,
|
56 |
+
'values' => $this->getKeywords(),
|
57 |
+
'note' => $this->__('Please choose a keyword'),
|
58 |
+
));
|
59 |
+
|
60 |
+
$fieldset->addField('type', 'hidden', array(
|
61 |
+
'name' => 'type',
|
62 |
+
'value'=> 'keyword',
|
63 |
+
));
|
64 |
+
}
|
65 |
+
|
66 |
+
$fieldset->addField('title', 'text', array(
|
67 |
+
'name' => 'title',
|
68 |
+
'label' => $this->__('Title'),
|
69 |
+
'title' => $this->__('Title'),
|
70 |
+
'required' => true,
|
71 |
+
'note' => $this->__('Please enter a title of message. This does not appear in the text message and is just used in the application as a short description of your message.'),
|
72 |
+
));
|
73 |
+
|
74 |
+
$fieldset->addField('message', 'textarea', array(
|
75 |
+
'name' => 'message',
|
76 |
+
'label' => $this->__('Message'),
|
77 |
+
'title' => $this->__('Message'),
|
78 |
+
'required' => true,
|
79 |
+
'note' => $this->__('Please enter a text message. The message must be less than 160 characters including your keyword in the beginning of the message.'),
|
80 |
+
'class' => 'validate-length maximum-length-160'
|
81 |
+
));
|
82 |
+
|
83 |
+
if ($data = Mage::getSingleton('adminhtml/session')->getFormData()) {
|
84 |
+
$form->setValues($data);
|
85 |
+
Mage::getSingleton('adminhtml/session')->setFormData(null);
|
86 |
+
}
|
87 |
+
|
88 |
+
$form->setUseContainer(true);
|
89 |
+
$this->setForm($form);
|
90 |
+
|
91 |
+
return parent::_prepareForm();
|
92 |
+
}
|
93 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Message/Sms/Grid.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Message_Sms_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
|
10 |
+
$this->setId('optitBulkSmsGrid');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
$this->setUseAjax(true);
|
13 |
+
$this->setFilterVisibility(false);
|
14 |
+
$this->_emptyText = 'The bulk messaging list is empty. Please use appropriate message forms to create messages and add them to bulk.';
|
15 |
+
}
|
16 |
+
|
17 |
+
protected function _prepareCollection()
|
18 |
+
{
|
19 |
+
$collection = Mage::getModel('optit/message')->getCollection()
|
20 |
+
->addFieldToFilter('message_type', array('eq' => Inchoo_Optit_Model_Message::MESSAGE_TYPE_SMS))
|
21 |
+
->addMessageRecipients();
|
22 |
+
|
23 |
+
$this->setCollection($collection);
|
24 |
+
parent::_prepareCollection();
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _prepareColumns()
|
29 |
+
{
|
30 |
+
$this->addColumn('message_title',
|
31 |
+
array(
|
32 |
+
'header'=> $this->__('Title'),
|
33 |
+
'index' => 'title',
|
34 |
+
'width' => '10%',
|
35 |
+
'sortable' => false,
|
36 |
+
)
|
37 |
+
);
|
38 |
+
|
39 |
+
$this->addColumn('message',
|
40 |
+
array(
|
41 |
+
'header'=> $this->__('Message'),
|
42 |
+
'index' => 'message',
|
43 |
+
'width' => '30%',
|
44 |
+
'sortable' => false,
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
$this->addColumn('recipients',
|
49 |
+
array(
|
50 |
+
'header'=> $this->__('Recipients'),
|
51 |
+
'index' => 'recipients',
|
52 |
+
'sortable' => false,
|
53 |
+
)
|
54 |
+
);
|
55 |
+
|
56 |
+
return parent::_prepareColumns();
|
57 |
+
}
|
58 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Subscription extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = 'optit';
|
9 |
+
$this->_controller = 'adminhtml_subscription';
|
10 |
+
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$filterType = Mage::registry('filter_type');
|
14 |
+
|
15 |
+
if ($filterType == Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_KEYWORD) {
|
16 |
+
$this->removeButton('add');
|
17 |
+
$this->addButton('back', array(
|
18 |
+
'label' => $this->__('Back'),
|
19 |
+
'onclick' => "setLocation('{$this->getBackUrl()}')",
|
20 |
+
'class' => 'back'
|
21 |
+
), 0, 1);
|
22 |
+
$confirmationMessage = Mage::helper('core')->jsQuoteEscape(
|
23 |
+
$this->__('Are you sure you want to send SMS to these subscribers?')
|
24 |
+
);
|
25 |
+
$this->addButton('send_sms', array(
|
26 |
+
'label' => $this->__('Send SMS'),
|
27 |
+
'onclick' => "confirmSetLocation('{$confirmationMessage}', '{$this->getSendSmsUrl()}')",
|
28 |
+
'class' => 'go'
|
29 |
+
), 0, 2);
|
30 |
+
$confirmationMessage = Mage::helper('core')->jsQuoteEscape(
|
31 |
+
$this->__('Are you sure you want to send MMS to these subscribers?')
|
32 |
+
);
|
33 |
+
$this->addButton('send_mms', array(
|
34 |
+
'label' => $this->__('Send MMS'),
|
35 |
+
'onclick' => "confirmSetLocation('{$confirmationMessage}', '{$this->getSendMmsUrl()}')",
|
36 |
+
'class' => 'go'
|
37 |
+
), 0, 3);
|
38 |
+
$this->addButton('add', array(
|
39 |
+
'label' => $this->__('New Subscription'),
|
40 |
+
'onclick' => "setLocation('{$this->getNewUrl()}')",
|
41 |
+
'class' => 'add'
|
42 |
+
), 0, 4);
|
43 |
+
}
|
44 |
+
elseif ($filterType == Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_INTEREST) {
|
45 |
+
$this->removeButton('add');
|
46 |
+
$this->addButton('back', array(
|
47 |
+
'label' => $this->__('Back'),
|
48 |
+
'onclick' => "setLocation('{$this->getBackToInterestsUrl()}')",
|
49 |
+
'class' => 'back'
|
50 |
+
), 0, 1);
|
51 |
+
$confirmationMessage = Mage::helper('core')->jsQuoteEscape(
|
52 |
+
$this->__('Are you sure you want to send SMS to these subscribers?')
|
53 |
+
);
|
54 |
+
$this->addButton('send', array(
|
55 |
+
'label' => $this->__('Send Message'),
|
56 |
+
'onclick' => "confirmSetLocation('{$confirmationMessage}', '{$this->getSendSmsUrl()}')",
|
57 |
+
'class' => 'go'
|
58 |
+
), 0, 2);
|
59 |
+
$this->addButton('add', array(
|
60 |
+
'label' => $this->__('Subscribe Member To Interest'),
|
61 |
+
'onclick' => "setLocation('{$this->getSubscribeUrl()}')",
|
62 |
+
'class' => 'add'
|
63 |
+
), 0, 3);
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
protected function _prepareLayout()
|
68 |
+
{
|
69 |
+
return parent::_prepareLayout();
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getBackUrl()
|
73 |
+
{
|
74 |
+
return $this->getUrl('*/optit_keyword');
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getBackToInterestsUrl()
|
78 |
+
{
|
79 |
+
return $this->getUrl('*/optit_interest', array(
|
80 |
+
'keyword_id' => $this->getRequest()->getParam('keyword_id'),
|
81 |
+
'keyword_name' => $this->_getKeywordName(),
|
82 |
+
));
|
83 |
+
}
|
84 |
+
|
85 |
+
public function getNewUrl()
|
86 |
+
{
|
87 |
+
$filterId = Mage::registry('filter_id');
|
88 |
+
return $this->getUrl('*/*/new', array(
|
89 |
+
'keyword_id' => $filterId,
|
90 |
+
'keyword_name' => $this->_getSubscriptionTypeName()
|
91 |
+
));
|
92 |
+
}
|
93 |
+
|
94 |
+
public function getSendSmsUrl()
|
95 |
+
{
|
96 |
+
return $this->getUrl('*/optit_message/sms', array(
|
97 |
+
'id' => Mage::registry('filter_id'),
|
98 |
+
'type' => Mage::registry('filter_type'),
|
99 |
+
'type_name' => $this->_getSubscriptionTypeName(),
|
100 |
+
));
|
101 |
+
}
|
102 |
+
|
103 |
+
public function getSendMmsUrl()
|
104 |
+
{
|
105 |
+
return $this->getUrl('*/optit_message/mms', array(
|
106 |
+
'id' => Mage::registry('filter_id'),
|
107 |
+
'type' => Mage::registry('filter_type'),
|
108 |
+
'type_name' => $this->_getSubscriptionTypeName(),
|
109 |
+
));
|
110 |
+
}
|
111 |
+
|
112 |
+
public function getSubscribeUrl()
|
113 |
+
{
|
114 |
+
return $this->getUrl('*/optit_interest/subscribe',
|
115 |
+
array(
|
116 |
+
'interest_id' => $this->getRequest()->getParam('interest_id'),
|
117 |
+
'keyword_id' => $this->getRequest()->getParam('keyword_id'),
|
118 |
+
'keyword_name' => $this->_getKeywordName(),
|
119 |
+
'type_name' => $this->_getSubscriptionTypeName(),
|
120 |
+
));
|
121 |
+
}
|
122 |
+
|
123 |
+
public function getHeaderText()
|
124 |
+
{
|
125 |
+
return $this->__("Subscriptions for '%s'", $this->_getSubscriptionTypeName());
|
126 |
+
}
|
127 |
+
|
128 |
+
protected function _getKeywordName()
|
129 |
+
{
|
130 |
+
return $this->getRequest()->getParam('keyword_name');
|
131 |
+
}
|
132 |
+
|
133 |
+
protected function _getSubscriptionTypeName()
|
134 |
+
{
|
135 |
+
if ($text = $this->getRequest()->getParam('type_name')) {
|
136 |
+
return $text;
|
137 |
+
} else {
|
138 |
+
return $this->_getKeywordName();
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Edit.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Subscription_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = 'optit';
|
9 |
+
$this->_controller = 'adminhtml_subscription';
|
10 |
+
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', $this->__('Save Subscription'));
|
14 |
+
$this->_updateButton('back', 'onclick', "setLocation('{$this->getBackUrl()}')");
|
15 |
+
$this->_removeButton('delete');
|
16 |
+
$this->_removeButton('reset');
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getHeaderText()
|
20 |
+
{
|
21 |
+
return $this->__("New Subscription for '%s'", $this->_getKeywordName());
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getBackUrl()
|
25 |
+
{
|
26 |
+
return $this->getUrl('*/optit_subscription', array(
|
27 |
+
'keyword_id' => $this->getKeywordId(),
|
28 |
+
'type_name' => $this->_getKeywordName()
|
29 |
+
));
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getKeywordId()
|
33 |
+
{
|
34 |
+
return $this->getRequest()->getParam('keyword_id');
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getSaveUrl()
|
38 |
+
{
|
39 |
+
return $this->getUrl('*/*/save', array(
|
40 |
+
'keyword_name' => $this->getRequest()->getParam('keyword_name'),
|
41 |
+
'type_name' => $this->getRequest()->getParam('type_name'),
|
42 |
+
));
|
43 |
+
}
|
44 |
+
|
45 |
+
protected function _getKeywordName()
|
46 |
+
{
|
47 |
+
return $this->getRequest()->getParam('keyword_name');
|
48 |
+
}
|
49 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Edit/Form.php
ADDED
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Subscription_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
|
10 |
+
$this->setId('optit_keyword_form');
|
11 |
+
$this->setTitle($this->__('New Subscription'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareForm()
|
15 |
+
{
|
16 |
+
$form = new Varien_Data_Form(array(
|
17 |
+
'id' => 'edit_form',
|
18 |
+
'action' => $this->getData('action'),
|
19 |
+
'method' => 'post'
|
20 |
+
));
|
21 |
+
|
22 |
+
$fieldset = $form->addFieldset('base_fieldset', array(
|
23 |
+
'legend' => $this->__('Subscription'),
|
24 |
+
'class' => 'fieldset',
|
25 |
+
));
|
26 |
+
|
27 |
+
$fieldset->addField('keyword_id', 'hidden', array(
|
28 |
+
'name' => 'keyword_id',
|
29 |
+
'value'=> $this->_getKeywordId(),
|
30 |
+
));
|
31 |
+
|
32 |
+
$choose = $fieldset->addField('subscription', 'select', array(
|
33 |
+
'name' => 'subscription',
|
34 |
+
'label' => $this->__('Subscription by'),
|
35 |
+
'title' => $this->__('Subscription by'),
|
36 |
+
'values' => array(
|
37 |
+
'phone' => 'Phone',
|
38 |
+
'member_id' => 'Member Id'
|
39 |
+
),
|
40 |
+
));
|
41 |
+
|
42 |
+
$phone = $fieldset->addField('phone', 'text', array(
|
43 |
+
'name' => 'phone',
|
44 |
+
'label' => $this->__('Phone'),
|
45 |
+
'title' => $this->__('Phone'),
|
46 |
+
'required' => true,
|
47 |
+
'note' => $this->__('Mobile phone number of the member with country code - 1 for U.S. phone numbers. Example: 12225551212'),
|
48 |
+
));
|
49 |
+
|
50 |
+
$memberId = $fieldset->addField('member_id', 'text', array(
|
51 |
+
'name' => 'member_id',
|
52 |
+
'label' => $this->__('Member Id'),
|
53 |
+
'title' => $this->__('Member Id'),
|
54 |
+
'required' => true,
|
55 |
+
'note' => $this->__('Id number of the member'),
|
56 |
+
));
|
57 |
+
|
58 |
+
$interestId = $fieldset->addField('interest_id', 'multiselect', array(
|
59 |
+
'name' => 'interest_id',
|
60 |
+
'label' => $this->__('Interest'),
|
61 |
+
'title' => $this->__('Interest'),
|
62 |
+
'values' => Mage::getSingleton('optit/system_config_source_subscription_interest')->toOptionArray($this->_getKeywordId()),
|
63 |
+
'note' => $this->__('Add this user to one or many interests.'),
|
64 |
+
));
|
65 |
+
|
66 |
+
$firstName = $fieldset->addField('first_name', 'text', array(
|
67 |
+
'name' => 'first_name',
|
68 |
+
'label' => $this->__('First Name'),
|
69 |
+
'title' => $this->__('First Name'),
|
70 |
+
));
|
71 |
+
|
72 |
+
$lastName = $fieldset->addField('last_name', 'text', array(
|
73 |
+
'name' => 'last_name',
|
74 |
+
'label' => $this->__('Last Name'),
|
75 |
+
'title' => $this->__('Last Name'),
|
76 |
+
));
|
77 |
+
|
78 |
+
$address1 = $fieldset->addField('address1', 'text', array(
|
79 |
+
'name' => 'address1',
|
80 |
+
'label' => $this->__('Address'),
|
81 |
+
'title' => $this->__('Address'),
|
82 |
+
));
|
83 |
+
|
84 |
+
$address2 = $fieldset->addField('address2', 'text', array(
|
85 |
+
'name' => 'address2',
|
86 |
+
'label' => $this->__('Additional Address'),
|
87 |
+
'title' => $this->__('Additional Address'),
|
88 |
+
));
|
89 |
+
|
90 |
+
$city = $fieldset->addField('city', 'text', array(
|
91 |
+
'name' => 'city',
|
92 |
+
'label' => $this->__('City'),
|
93 |
+
'title' => $this->__('City'),
|
94 |
+
));
|
95 |
+
|
96 |
+
$state = $fieldset->addField('state', 'text', array(
|
97 |
+
'name' => 'state',
|
98 |
+
'label' => $this->__('State'),
|
99 |
+
'title' => $this->__('State'),
|
100 |
+
'note' => $this->__('State of the member as a two character abbreviation'),
|
101 |
+
));
|
102 |
+
|
103 |
+
$zip = $fieldset->addField('zip', 'text', array(
|
104 |
+
'name' => 'zip',
|
105 |
+
'label' => $this->__('Zip'),
|
106 |
+
'title' => $this->__('Zip'),
|
107 |
+
));
|
108 |
+
|
109 |
+
$gender = $fieldset->addField('gender', 'select', array(
|
110 |
+
'name' => 'gender',
|
111 |
+
'label' => $this->__('Gender'),
|
112 |
+
'title' => $this->__('Gender'),
|
113 |
+
'values' => Mage::getSingleton('optit/system_config_source_customer_gender')->toOptionArray(),
|
114 |
+
));
|
115 |
+
|
116 |
+
$birthDate = $fieldset->addField('birth_date', 'date', array(
|
117 |
+
'name' => 'birth_date',
|
118 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
119 |
+
'label' => $this->__('Birth Date'),
|
120 |
+
'title' => $this->__('Birth Date'),
|
121 |
+
'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
|
122 |
+
));
|
123 |
+
|
124 |
+
$email = $fieldset->addField('email_address', 'text', array(
|
125 |
+
'name' => 'email_address',
|
126 |
+
'label' => $this->__('Email'),
|
127 |
+
'title' => $this->__('Email'),
|
128 |
+
'class' => 'validate-email',
|
129 |
+
));
|
130 |
+
|
131 |
+
$form->setUseContainer(true);
|
132 |
+
$this->setForm($form);
|
133 |
+
$this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
|
134 |
+
->addFieldMap($choose->getHtmlId(), $choose->getName())
|
135 |
+
->addFieldMap($phone->getHtmlId(), $phone->getName())
|
136 |
+
->addFieldMap($interestId->getHtmlId(), $interestId->getName())
|
137 |
+
->addFieldMap($firstName->getHtmlId(), $firstName->getName())
|
138 |
+
->addFieldMap($lastName->getHtmlId(), $lastName->getName())
|
139 |
+
->addFieldMap($address1->getHtmlId(), $address1->getName())
|
140 |
+
->addFieldMap($address2->getHtmlId(), $address2->getName())
|
141 |
+
->addFieldMap($city->getHtmlId(), $city->getName())
|
142 |
+
->addFieldMap($state->getHtmlId(), $state->getName())
|
143 |
+
->addFieldMap($zip->getHtmlId(), $zip->getName())
|
144 |
+
->addFieldMap($gender->getHtmlId(), $gender->getName())
|
145 |
+
->addFieldMap($birthDate->getHtmlId(), $birthDate->getName())
|
146 |
+
->addFieldMap($email->getHtmlId(), $email->getName())
|
147 |
+
->addFieldMap($memberId->getHtmlId(), $memberId->getName())
|
148 |
+
->addFieldDependence(
|
149 |
+
$phone->getName(),
|
150 |
+
$choose->getName(),
|
151 |
+
'phone'
|
152 |
+
)
|
153 |
+
->addFieldDependence(
|
154 |
+
$interestId->getName(),
|
155 |
+
$choose->getName(),
|
156 |
+
'phone'
|
157 |
+
)
|
158 |
+
->addFieldDependence(
|
159 |
+
$firstName->getName(),
|
160 |
+
$choose->getName(),
|
161 |
+
'phone'
|
162 |
+
)
|
163 |
+
->addFieldDependence(
|
164 |
+
$lastName->getName(),
|
165 |
+
$choose->getName(),
|
166 |
+
'phone'
|
167 |
+
)
|
168 |
+
->addFieldDependence(
|
169 |
+
$address1->getName(),
|
170 |
+
$choose->getName(),
|
171 |
+
'phone'
|
172 |
+
)
|
173 |
+
->addFieldDependence(
|
174 |
+
$address2->getName(),
|
175 |
+
$choose->getName(),
|
176 |
+
'phone'
|
177 |
+
)
|
178 |
+
->addFieldDependence(
|
179 |
+
$city->getName(),
|
180 |
+
$choose->getName(),
|
181 |
+
'phone'
|
182 |
+
)
|
183 |
+
->addFieldDependence(
|
184 |
+
$state->getName(),
|
185 |
+
$choose->getName(),
|
186 |
+
'phone'
|
187 |
+
)
|
188 |
+
->addFieldDependence(
|
189 |
+
$zip->getName(),
|
190 |
+
$choose->getName(),
|
191 |
+
'phone'
|
192 |
+
)
|
193 |
+
->addFieldDependence(
|
194 |
+
$gender->getName(),
|
195 |
+
$choose->getName(),
|
196 |
+
'phone'
|
197 |
+
)
|
198 |
+
->addFieldDependence(
|
199 |
+
$birthDate->getName(),
|
200 |
+
$choose->getName(),
|
201 |
+
'phone'
|
202 |
+
)
|
203 |
+
->addFieldDependence(
|
204 |
+
$email->getName(),
|
205 |
+
$choose->getName(),
|
206 |
+
'phone'
|
207 |
+
)
|
208 |
+
->addFieldDependence(
|
209 |
+
$memberId->getName(),
|
210 |
+
$choose->getName(),
|
211 |
+
'member_id'
|
212 |
+
)
|
213 |
+
);
|
214 |
+
|
215 |
+
return parent::_prepareForm();
|
216 |
+
}
|
217 |
+
|
218 |
+
protected function _getKeywordId()
|
219 |
+
{
|
220 |
+
return $this->getRequest()->getParam('keyword_id');
|
221 |
+
}
|
222 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Grid.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Subscription_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
|
10 |
+
$this->setId('optit_subscription_grid');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
$this->setUseAjax(true);
|
13 |
+
$this->setFilterVisibility(false);
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _prepareCollection()
|
17 |
+
{
|
18 |
+
$collection = new Inchoo_Optit_Model_Collecition();
|
19 |
+
$filterId = Mage::registry('filter_id');
|
20 |
+
$filterType = Mage::registry('filter_type');
|
21 |
+
|
22 |
+
$data = Mage::getModel('optit/subscription')->getAllSubscriptions($filterType, $filterId);
|
23 |
+
if (isset($data['subscriptions']) && !empty($data['subscriptions'])) {
|
24 |
+
foreach ($data['subscriptions'] as $subscription) {
|
25 |
+
$subscribeObj = new Varien_Object();
|
26 |
+
$subscribeObj->setData($subscription['subscription']);
|
27 |
+
$collection->addItem($subscribeObj);
|
28 |
+
}
|
29 |
+
|
30 |
+
$totalPages = $data['total_pages'];
|
31 |
+
$currentPage = $data['current_page'];
|
32 |
+
|
33 |
+
if ($currentPage <= $totalPages) {
|
34 |
+
$collection->setCurPage($currentPage);
|
35 |
+
$collection->setSize(Inchoo_Optit_Model_Collecition::OPTIT_ITEMS_COLLECTION_SIZE * $totalPages);
|
36 |
+
} else {
|
37 |
+
$this->setVarNamePage(1);
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
$this->setCollection($collection);
|
43 |
+
return parent::_prepareCollection();
|
44 |
+
}
|
45 |
+
|
46 |
+
protected function _preparePage()
|
47 |
+
{
|
48 |
+
$this->getCollection()->setPageSize((int)$this->getParam($this->getVarNameLimit(), $this->_defaultLimit));
|
49 |
+
// $this->getCollection()->setCurPage((int) $this->getParam($this->getVarNamePage(), $this->_defaultPage));
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function _prepareColumns()
|
53 |
+
{
|
54 |
+
$this->addColumn('member_id',
|
55 |
+
array(
|
56 |
+
'header'=> $this->__('Member ID'),
|
57 |
+
'align' =>'right',
|
58 |
+
'width' => '50px',
|
59 |
+
'index' => 'member_id',
|
60 |
+
'sortable' => false,
|
61 |
+
)
|
62 |
+
);
|
63 |
+
|
64 |
+
$this->addColumn('phone',
|
65 |
+
array(
|
66 |
+
'header'=> $this->__('Phone'),
|
67 |
+
'index' => 'phone',
|
68 |
+
'sortable' => false,
|
69 |
+
)
|
70 |
+
);
|
71 |
+
|
72 |
+
$this->addColumn('type',
|
73 |
+
array(
|
74 |
+
'header'=> $this->__('Subscription Type'),
|
75 |
+
'index' => 'type',
|
76 |
+
'sortable' => false,
|
77 |
+
)
|
78 |
+
);
|
79 |
+
|
80 |
+
$this->addColumn('signup_date',
|
81 |
+
array(
|
82 |
+
'header'=> $this->__('Signup Date'),
|
83 |
+
'index' => 'signup_date',
|
84 |
+
'sortable' => false,
|
85 |
+
)
|
86 |
+
);
|
87 |
+
|
88 |
+
$this->addColumn('created_at',
|
89 |
+
array(
|
90 |
+
'header'=> $this->__('Created'),
|
91 |
+
'index' => 'created_at',
|
92 |
+
'sortable' => false,
|
93 |
+
)
|
94 |
+
);
|
95 |
+
|
96 |
+
$this->addColumn('action',
|
97 |
+
array(
|
98 |
+
'header'=> $this->__('Actions'),
|
99 |
+
'index' => 'id',
|
100 |
+
'sortable' => false,
|
101 |
+
'filter' => false,
|
102 |
+
'no_link' => true,
|
103 |
+
'width' => '160px',
|
104 |
+
'renderer' => 'optit/adminhtml_subscription_grid_renderer_action'
|
105 |
+
)
|
106 |
+
);
|
107 |
+
return parent::_prepareColumns();
|
108 |
+
}
|
109 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Grid/Renderer/Action.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Subscription_Grid_Renderer_Action extends Inchoo_Optit_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
5 |
+
{
|
6 |
+
public function render(Varien_Object $row)
|
7 |
+
{
|
8 |
+
$actions = array();
|
9 |
+
if (Mage::registry('filter_type') == Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_KEYWORD) {
|
10 |
+
$actions[] = array(
|
11 |
+
'url' => $this->getUrl('*/optit_subscription/unsubscribe', array(
|
12 |
+
'filter_id' => Mage::registry('filter_id'),
|
13 |
+
'phone' => $row->getPhone(),
|
14 |
+
'type_name' => $this->getRequest()->getParam('type_name'),
|
15 |
+
)),
|
16 |
+
'caption' => $this->__('Unsubscribe'),
|
17 |
+
'confirm' => $this->__('Are you sure you want to unsubscribe this subscriber?'),
|
18 |
+
);
|
19 |
+
} elseif (Mage::registry('filter_type') == Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_INTEREST) {
|
20 |
+
$actions[] = array(
|
21 |
+
'url' => $this->getUrl('*/optit_interest/unsubscribe', array(
|
22 |
+
'filter_id' => Mage::registry('filter_id'),
|
23 |
+
'phone' => $row->getPhone(),
|
24 |
+
'interest_id' => $this->getRequest()->getParam('interest_id'),
|
25 |
+
'keyword_id' => $this->_getKeywordId(),
|
26 |
+
'keyword_name' => $this->getRequest()->getParam('keyword_name'),
|
27 |
+
'type_name' => $this->getRequest()->getParam('type_name'),
|
28 |
+
)),
|
29 |
+
'caption' => $this->__('Unsubscribe'),
|
30 |
+
'confirm' => $this->__('Are you sure you want to unsubscribe this subscriber?'),
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
$actions[] = array(
|
35 |
+
'url' => $this->getUrl('*/optit_message/sms', array(
|
36 |
+
'phone' => $row->getPhone(),
|
37 |
+
'id' => $this->_getKeywordId(),
|
38 |
+
'type' => Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_MEMBER,
|
39 |
+
'type_name' => $row->getPhone(),
|
40 |
+
)),
|
41 |
+
'caption' => $this->__('Send Message'),
|
42 |
+
'confirm' => $this->__('Are you sure you want to send SMS to this subscriber?'),
|
43 |
+
);
|
44 |
+
|
45 |
+
$this->getColumn()->setActions($actions);
|
46 |
+
|
47 |
+
return parent::render($row);
|
48 |
+
}
|
49 |
+
|
50 |
+
protected function _getKeywordId()
|
51 |
+
{
|
52 |
+
return $this->getRequest()->getParam('keyword_id');
|
53 |
+
}
|
54 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Subscribe/Edit.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Block_Adminhtml_Subscription_Subscribe_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = 'optit';
|
9 |
+
$this->_controller = 'adminhtml_subscription_subscribe';
|
10 |
+
|
11 |
+
parent::__construct();
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', $this->__('Save Subscription'));
|
14 |
+
$this->_updateButton('back', 'onclick', "setLocation('{$this->getBackUrl()}')");
|
15 |
+
$this->removeButton('delete');
|
16 |
+
$this->removeButton('reset');
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getHeaderText()
|
20 |
+
{
|
21 |
+
return $this->__("New Subscription For '%s'", $this->_getSubscriptionTypeName());
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getBackUrl()
|
25 |
+
{
|
26 |
+
return $this->getUrl('*/optit_subscription/interest', array(
|
27 |
+
'interest_id' => $this->getRequest()->getParam('interest_id'),
|
28 |
+
'keyword_id' => $this->getRequest()->getParam('keyword_id'),
|
29 |
+
'keyword_name' => $this->getRequest()->getParam('keyword_name'),
|
30 |
+
'type_name' => $this->getRequest()->getParam('type_name'),
|
31 |
+
));
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getSaveUrl()
|
35 |
+
{
|
36 |
+
return $this->getUrl('*/*/subscribeSave', array(
|
37 |
+
'id' => $this->getRequest()->getParam('id'),
|
38 |
+
'keyword_name' => $this->getRequest()->getParam('keyword_name'),
|
39 |
+
'type_name' => $this->getRequest()->getParam('type_name'),
|
40 |
+
));
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _getSubscriptionTypeName()
|
44 |
+
{
|
45 |
+
return $this->getRequest()->getParam('type_name');
|
46 |
+
}
|
47 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Subscription/Subscribe/Edit/Form.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inchoo_Optit_Block_Adminhtml_Subscription_Subscribe_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->setId('optit_subscription_subscribe_form');
|
10 |
+
$this->setTitle($this->__('New Subscription'));
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _prepareForm()
|
14 |
+
{
|
15 |
+
$keywordId = $this->_getKeywordId();
|
16 |
+
$interestId = $this->getRequest()->getParam('interest_id');
|
17 |
+
$form = new Varien_Data_Form(array(
|
18 |
+
'id' => 'edit_form',
|
19 |
+
'action' => $this->getData('action'),
|
20 |
+
'method' => 'post',
|
21 |
+
));
|
22 |
+
|
23 |
+
$fieldset = $form->addFieldset('base_fieldset', array(
|
24 |
+
'legend' => $this->__('Subscription'),
|
25 |
+
'class' => 'fieldset',
|
26 |
+
));
|
27 |
+
|
28 |
+
$fieldset->addField('interest_id', 'hidden', array(
|
29 |
+
'name' => 'interest_id',
|
30 |
+
'value'=> $interestId,
|
31 |
+
));
|
32 |
+
|
33 |
+
$fieldset->addField('keyword_id', 'hidden', array(
|
34 |
+
'name' => 'keyword_id',
|
35 |
+
'value'=> $keywordId,
|
36 |
+
));
|
37 |
+
|
38 |
+
$fieldset->addField('phone', 'select', array(
|
39 |
+
'name' => 'phone',
|
40 |
+
'label' => $this->__('Phone Number'),
|
41 |
+
'title' => $this->__('Phone Number'),
|
42 |
+
'values' => $this->getData('phones'),
|
43 |
+
));
|
44 |
+
|
45 |
+
$form->setUseContainer(true);
|
46 |
+
$this->setForm($form);
|
47 |
+
|
48 |
+
return parent::_prepareForm();
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function _getKeywordId()
|
52 |
+
{
|
53 |
+
$a = $this->getRequest()->getParam('keyword_id');
|
54 |
+
return $a;
|
55 |
+
}
|
56 |
+
}
|
app/code/local/Inchoo/Optit/Block/Adminhtml/Widget/Grid/Column/Renderer/Action.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Grid column widget for rendering action grid cells
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Inchoo_Optit_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
35 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
|
36 |
+
{
|
37 |
+
|
38 |
+
const DEFAULT_ACTIONS_LABEL = "Actions";
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Renders column, with default label
|
42 |
+
*
|
43 |
+
* @param Varien_Object $row
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function render(Varien_Object $row)
|
47 |
+
{
|
48 |
+
$actions = $this->getColumn()->getActions();
|
49 |
+
if ( empty($actions) || !is_array($actions) ) {
|
50 |
+
return ' ';
|
51 |
+
}
|
52 |
+
|
53 |
+
if(sizeof($actions)==1 && !$this->getColumn()->getNoLink()) {
|
54 |
+
foreach ($actions as $action) {
|
55 |
+
if ( is_array($action) ) {
|
56 |
+
return $this->_toLinkHtml($action, $row);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
$out = '<select class="action-select" onchange="varienGridAction.execute(this);">'
|
62 |
+
. '<option value="">' . self::DEFAULT_ACTIONS_LABEL . '</option>';
|
63 |
+
$i = 0;
|
64 |
+
foreach ($actions as $action){
|
65 |
+
$i++;
|
66 |
+
if ( is_array($action) ) {
|
67 |
+
$out .= $this->_toOptionHtml($action, $row);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
$out .= '</select>';
|
71 |
+
return $out;
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
app/code/local/Inchoo/Optit/Helper/Data.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Helper_Data extends Mage_Core_Helper_Abstract
|
5 |
+
{
|
6 |
+
|
7 |
+
}
|
app/code/local/Inchoo/Optit/Model/Abstract.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
abstract class Inchoo_Optit_Model_Abstract extends Mage_Core_Model_Abstract
|
5 |
+
{
|
6 |
+
const FORMAT_JSON = 'json';
|
7 |
+
|
8 |
+
const FORMAT_XML = 'xml';
|
9 |
+
|
10 |
+
protected $_format;
|
11 |
+
|
12 |
+
protected $_defaultGatewayUrl = 'http://api.optitmobile.com/1/';
|
13 |
+
|
14 |
+
protected $_client;
|
15 |
+
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_format = self::FORMAT_JSON;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getClient()
|
22 |
+
{
|
23 |
+
if (is_null($this->_client)) {
|
24 |
+
$this->_client = Mage::getModel('optit/client');
|
25 |
+
}
|
26 |
+
|
27 |
+
return $this->_client;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function decodeAndCheck($data, $encoding = self::FORMAT_JSON)
|
31 |
+
{
|
32 |
+
if ($encoding == self::FORMAT_JSON) {
|
33 |
+
$data = Mage::helper('core')->jsonDecode($data);
|
34 |
+
} elseif ($encoding == self::FORMAT_XML) {
|
35 |
+
// TODO: simplexml
|
36 |
+
}
|
37 |
+
|
38 |
+
if (isset($data['Error'])) {
|
39 |
+
Mage::throwException($data['Error']['Message']);
|
40 |
+
}
|
41 |
+
|
42 |
+
return $data;
|
43 |
+
}
|
44 |
+
|
45 |
+
protected function _composeUri($path, $params = array())
|
46 |
+
{
|
47 |
+
$path .= '.%s';
|
48 |
+
$params[] = $this->_format;
|
49 |
+
return $this->_defaultGatewayUrl . vsprintf($path, $params);
|
50 |
+
}
|
51 |
+
|
52 |
+
public function checkStatus($status)
|
53 |
+
{
|
54 |
+
if ($status != 200) {
|
55 |
+
Mage::throwException('Something went wrong!');
|
56 |
+
};
|
57 |
+
|
58 |
+
}
|
59 |
+
}
|
app/code/local/Inchoo/Optit/Model/Client.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_Client extends Zend_Http_Client
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setBasicAuthentication();
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function setBasicAuthentication()
|
13 |
+
{
|
14 |
+
$username = Mage::getStoreConfig('promo/optit/optit_username');
|
15 |
+
$password = Mage::getStoreConfig('promo/optit/optit_password');
|
16 |
+
|
17 |
+
$this->setAuth($username, $password);
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
app/code/local/Inchoo/Optit/Model/Collecition.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_Collecition extends Varien_Data_Collection
|
5 |
+
{
|
6 |
+
const OPTIT_ITEMS_COLLECTION_SIZE = 20;
|
7 |
+
|
8 |
+
public function setSize($size)
|
9 |
+
{
|
10 |
+
$this->_totalRecords = $size;
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
}
|
app/code/local/Inchoo/Optit/Model/Interest.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_Interest extends Inchoo_Optit_Model_Abstract
|
5 |
+
{
|
6 |
+
protected $_urlKey = 'interests';
|
7 |
+
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Get a list of interests for an individual keyword.
|
11 |
+
* Parameters:
|
12 |
+
* name - name of the interest
|
13 |
+
* page - the number of the page result that you are requesting.
|
14 |
+
* Method: GET
|
15 |
+
* http://api.optitmobile.com/1/keywords/{keyword_id}/interests.{format}
|
16 |
+
*
|
17 |
+
* @param int $keywordId
|
18 |
+
* @param array $params
|
19 |
+
* @return Zend_Http_Response
|
20 |
+
* @throws Zend_Http_Client_Exception
|
21 |
+
*/
|
22 |
+
public function getAllInterests($keywordId, $params = array())
|
23 |
+
{
|
24 |
+
$uri = $this->_composeUri(
|
25 |
+
'keywords/%s/' . $this->_urlKey,
|
26 |
+
array($keywordId)
|
27 |
+
);
|
28 |
+
|
29 |
+
if (!empty($params)) {
|
30 |
+
$this->getClient()->setParameterGet($params);
|
31 |
+
}
|
32 |
+
|
33 |
+
$response = $this->getClient()->setUri($uri)->request(Zend_Http_Client::GET);
|
34 |
+
return $this->decodeAndCheck($response->getBody());
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Get a list of interests for an individual keyword and subscribers phone number.
|
39 |
+
* Parameters:
|
40 |
+
* page - the number of the page result that you are requesting.
|
41 |
+
* Method: GET
|
42 |
+
* http://api.optitmobile.com/1/keywords/{keyword_id}/subscriptions/{phone}/interests.{format}
|
43 |
+
*
|
44 |
+
* @param int $keywordId
|
45 |
+
* @param string $phone
|
46 |
+
* @param int $page
|
47 |
+
* @return Zend_Http_Response
|
48 |
+
* @throws Zend_Http_Client_Exception
|
49 |
+
*/
|
50 |
+
public function getInterestByPhoneNumber($keywordId, $phone, $page = 1)
|
51 |
+
{
|
52 |
+
$uri = $this->_composeUri(
|
53 |
+
'keywords/%s/subscriptions/%s/' . $this->_urlKey,
|
54 |
+
array($keywordId, $phone)
|
55 |
+
);
|
56 |
+
|
57 |
+
$response = $this->getClient()->setUri($uri)->setParameterGet($page)->request(Zend_Http_Client::GET);
|
58 |
+
return $this->decodeAndCheck($response->getBody());
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Get an individual interest for a keyword.
|
63 |
+
* Method: GET
|
64 |
+
* http://api.optitmobile.com/1/interests/{interest_id}.{format}
|
65 |
+
*
|
66 |
+
* @param int $interestId
|
67 |
+
* @return Zend_Http_Response
|
68 |
+
*/
|
69 |
+
public function getInterest($interestId)
|
70 |
+
{
|
71 |
+
$uri = $this->_composeUri(
|
72 |
+
$this->_urlKey . '/%s',
|
73 |
+
array($interestId)
|
74 |
+
);
|
75 |
+
|
76 |
+
$response = $this->getClient()->setUri($uri)->request(Zend_Http_Client::GET);
|
77 |
+
return $this->decodeAndCheck($response->getBody());
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Create a new interest associated to a keyword.
|
82 |
+
* Parameters:
|
83 |
+
* name - name of the interest. (Required)
|
84 |
+
* description - description of the interest
|
85 |
+
* Method: POST
|
86 |
+
* http://api.optitmobile.com/1/keywords/{keyword_id}/interests.{format}
|
87 |
+
*
|
88 |
+
* @param int $keywordId
|
89 |
+
* @param array $params
|
90 |
+
* @return Zend_Http_Response
|
91 |
+
* @throws Zend_Http_Client_Exception
|
92 |
+
*/
|
93 |
+
public function createInterest($keywordId, $params = array())
|
94 |
+
{
|
95 |
+
$uri = $this->_composeUri(
|
96 |
+
'keywords/%s/' . $this->_urlKey,
|
97 |
+
array($keywordId)
|
98 |
+
);
|
99 |
+
|
100 |
+
$response = $this->getClient()->setUri($uri)->setParameterPost($params)->request(Zend_Http_Client::POST);
|
101 |
+
return $this->decodeAndCheck($response->getBody());
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
}
|
app/code/local/Inchoo/Optit/Model/Keyword.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_Keyword extends Inchoo_Optit_Model_Abstract
|
5 |
+
{
|
6 |
+
protected $_urlKey = 'keywords';
|
7 |
+
|
8 |
+
protected $_idFieldName = 'id';
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Get the list of keywords.
|
12 |
+
* Parameters:
|
13 |
+
* keyword - the name of a keyword
|
14 |
+
* short_code - the 5 or 6 digit short code of a keyword
|
15 |
+
* page - the number of the page result that you are requesting.
|
16 |
+
* Method: GET
|
17 |
+
* http://api.optitmobile.com/1/keywords.{format}
|
18 |
+
*
|
19 |
+
* @param array $params
|
20 |
+
* @return mixed
|
21 |
+
* @throws Zend_Http_Client_Exception
|
22 |
+
*/
|
23 |
+
public function getAllKeywords($params = array())
|
24 |
+
{
|
25 |
+
$uri = $this->_composeUri(
|
26 |
+
$this->_urlKey
|
27 |
+
);
|
28 |
+
|
29 |
+
if (!empty($params)) {
|
30 |
+
$this->getClient()->setParameterGet($params);
|
31 |
+
}
|
32 |
+
|
33 |
+
$response = $this->getClient()->setUri($uri)->request(Zend_Http_Client::GET);
|
34 |
+
return $this->decodeAndCheck($response->getBody());
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Get an individual keyword.
|
39 |
+
* Method: GET
|
40 |
+
* http://api.optitmobile.com/1/keywords/{keyword_id}.{format}
|
41 |
+
*
|
42 |
+
* @param int $keywordId
|
43 |
+
* @return mixed
|
44 |
+
* @throws Zend_Http_Client_Exception
|
45 |
+
*/
|
46 |
+
protected function _getKeyword($keywordId)
|
47 |
+
{
|
48 |
+
$uri = $this->_composeUri(
|
49 |
+
$this->_urlKey . '/%s',
|
50 |
+
array($keywordId)
|
51 |
+
);
|
52 |
+
|
53 |
+
$response = $this->getClient()->setUri($uri)->request(Zend_Http_Client::GET);
|
54 |
+
return $this->decodeAndCheck($response->getBody());
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Checks to see if a keyword is already being used on the short code in your account.
|
59 |
+
* If it does not already exist, you will be allowed to add it to your account.
|
60 |
+
* Parameters:
|
61 |
+
* keyword - the name of a keyword. (Required)
|
62 |
+
* Method: GET
|
63 |
+
* http://api.optitmobile.com/1/keywords/exists.{format}
|
64 |
+
*
|
65 |
+
* @param string $keywordName
|
66 |
+
* @return mixed
|
67 |
+
* @throws Zend_Http_Client_Exception
|
68 |
+
*/
|
69 |
+
public function checkIfExists($keywordName)
|
70 |
+
{
|
71 |
+
$uri = $this->_composeUri(
|
72 |
+
$this->_urlKey . '/%s',
|
73 |
+
array('exists')
|
74 |
+
);
|
75 |
+
|
76 |
+
$response = $this->getClient()->setUri($uri)->setParameterGet(array('keyword' => $keywordName))->request(Zend_Http_Client::GET);
|
77 |
+
$response = $this->decodeAndCheck($response->getBody());
|
78 |
+
return $response['keyword']['exists'];
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Adds a new keyword for the short code assigned to your account. This will default to a Subscription keyword type
|
83 |
+
* and will use the standard Opt It messaging unless other message parameters are included in your POST. Your
|
84 |
+
* account will be billed based on your account plan and the billing type you submit.
|
85 |
+
* Parameters:
|
86 |
+
* billing_type - the plan type for this keyword. Values: [unlimited, per-message] (Required)
|
87 |
+
* keyword - the name of the keyword. (Required)
|
88 |
+
* internal_name - the internal name of the keyword. This name is only used for reference purposes inside the application. (Required)
|
89 |
+
* interest_id - the interest_id that users wil be added to when they subscribe. It is the ID attribute in the Interest entity and can be viewed using the Get Interest method.
|
90 |
+
* welcome_msg_type - the type of welcome messaage for this keyword. This message is sent after a successful subcription for a member. Defaults to standard. Values: [standard, semi-custom]
|
91 |
+
* welcome_msg - the actual text to be sent in the welcome message. Welcome_msg_type must exist in the POST and be equal to "semi-custom". Max 93 characters.
|
92 |
+
* web_form_verification_msg_type - the type of web form verification messaage for this keyword. This message is sent when someone subscribes using a web form or using the API and asks the member to verify that they would like to subscribe. It prevents someone other than the phone owner from subscribing the member's phone number to a keyword. Defaults to standard. Values: [standard, semi-custom]
|
93 |
+
* web_form_verification_msg - the actual text to be sent in the web form verification message. Web_form_verification_msg_type must exist in the POST and be equal to "semi-custom". Max 120 characters.
|
94 |
+
* already_subscribed_msg_type - the type of already subscribed messaage for this keyword. This message is sent when a member tries to subscribe and they are already subscribed to the keyword. Defaults to standard. Values: [standard, custom, none]
|
95 |
+
* already_subscribed_msg - the actual text to be sent in the already subscribed message. Already_subscribed_msg_type must exist in the POST and be equal to "custom". Max 160 characters.
|
96 |
+
* Method: POST
|
97 |
+
* http://api.optitmobile.com/1/keywords.{format}
|
98 |
+
*
|
99 |
+
* @param array $params
|
100 |
+
* @return mixed
|
101 |
+
* @throws Zend_Http_Client_Exception
|
102 |
+
*/
|
103 |
+
protected function _createKeyword($params)
|
104 |
+
{
|
105 |
+
$uri = $this->_composeUri(
|
106 |
+
$this->_urlKey
|
107 |
+
);
|
108 |
+
|
109 |
+
$response = $this->getClient()->setUri($uri)->setParameterPost($params)->request(Zend_Http_Client::POST);
|
110 |
+
return $this->decodeAndCheck($response->getBody());
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
*
|
115 |
+
* Parameters
|
116 |
+
* billing_type - the plan type for this keyword. Values: [unlimited, per-message] (Required)
|
117 |
+
* internal_name - the internal name of the keyword. This name is only used for reference purposes inside the application. (Required)
|
118 |
+
* interest_id - the interest_id that users wil be added to when they subscribe. It is the ID attribute in the Interest entity and can be viewed using the Get Interest method.
|
119 |
+
* welcome_msg_type - the type of welcome messaage for this keyword. This message is sent after a successful subcription for a member. Defaults to standard. Values: [standard, semi-custom]
|
120 |
+
* welcome_msg - the actual text to be sent in the welcome message. Welcome_msg_type must exist in the POST and be equal to "semi-custom". Max 93 characters.
|
121 |
+
* web_form_verification_msg_type - the type of web form verification messaage for this keyword. This message is sent when someone subscribes using a web form or using the API and asks the member to verify that they would like to subscribe. It prevents someone other than the phone owner from subscribing the member's phone number to a keyword. Defaults to standard. Values: [standard, semi-custom]
|
122 |
+
* web_form_verification_msg - the actual text to be sent in the web form verification message. Web_form_verification_msg_type must exist in the POST and be equal to "semi-custom". Max 120 characters.
|
123 |
+
* already_subscribed_msg_type - the type of already subscribed messaage for this keyword. This message is sent when a member tries to subscribe and they are already subscribed to the keyword. Defaults to standard. Values: [standard, custom, none]
|
124 |
+
* already_subscribed_msg - the actual text to be sent in the already subscribed message. Already_subscribed_msg_type must exist in the POST and be equal to "custom". Max 160 characters.
|
125 |
+
* Method: PUT
|
126 |
+
* http://api.optitmobile.com/1/keywords/{keyword_id}.{format}
|
127 |
+
*
|
128 |
+
* @param int $keywordId
|
129 |
+
* @param array $params
|
130 |
+
* @return mixed
|
131 |
+
* @throws Zend_Http_Client_Exception
|
132 |
+
*/
|
133 |
+
public function updateKeyword($keywordId, $params)
|
134 |
+
{
|
135 |
+
$uri = $this->_composeUri(
|
136 |
+
$this->_urlKey .'/%s',
|
137 |
+
array($keywordId)
|
138 |
+
);
|
139 |
+
|
140 |
+
$response = $this->getClient()->setUri($uri)->setParameterPost($params)->request(Zend_Http_Client::PUT);
|
141 |
+
return $this->decodeAndCheck($response->getBody());
|
142 |
+
}
|
143 |
+
|
144 |
+
public function loadKeyword($keywordId)
|
145 |
+
{
|
146 |
+
$response = $this->_getKeyword($keywordId);
|
147 |
+
|
148 |
+
if (isset($response['keyword'])) {
|
149 |
+
$this->setData($response['keyword']);
|
150 |
+
}
|
151 |
+
|
152 |
+
return $this;
|
153 |
+
}
|
154 |
+
|
155 |
+
public function saveKeyword($params)
|
156 |
+
{
|
157 |
+
if (!isset($params['id']) && !$this->checkIfExists($params['keyword'])) {
|
158 |
+
$keyword = $this->_createKeyword($params);
|
159 |
+
return $keyword;
|
160 |
+
}
|
161 |
+
|
162 |
+
$keyword = $this->updateKeyword($params['id'], $params);
|
163 |
+
return $keyword;
|
164 |
+
}
|
165 |
+
}
|
app/code/local/Inchoo/Optit/Model/Member.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_Member extends Inchoo_Optit_Model_Abstract
|
5 |
+
{
|
6 |
+
protected $_urlKey = 'members';
|
7 |
+
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Get a list of members information.
|
11 |
+
* Parameters:
|
12 |
+
* phone - mobile phone number of the member with country code - 1 for U.S. phone numbers. Example: 12225551212
|
13 |
+
* first_name - first name of the member
|
14 |
+
* last_name - last name of the member
|
15 |
+
* zip - zip code or postal code of the member
|
16 |
+
* gender - gender of the member (male or female)
|
17 |
+
* Method: GET
|
18 |
+
* http://api.optitmobile.com/1/members.{format}
|
19 |
+
*
|
20 |
+
* @param array $params
|
21 |
+
* @return Zend_Http_Response
|
22 |
+
*/
|
23 |
+
public function getAllMembers($params = array())
|
24 |
+
{
|
25 |
+
$uri = $this->_composeUri(
|
26 |
+
$this->_urlKey
|
27 |
+
);
|
28 |
+
|
29 |
+
if (!empty($params)) {
|
30 |
+
$this->getClient()->setParameterGet($params);
|
31 |
+
}
|
32 |
+
|
33 |
+
$response = $this->getClient()->setUri($uri)->request(Zend_Http_Client::GET);
|
34 |
+
return $this->decodeAndCheck($response->getBody());
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Get an individual members information.
|
39 |
+
* Method: GET
|
40 |
+
* http://api.optitmobile.com/1/members/{phone}.{format}
|
41 |
+
*
|
42 |
+
* @param string $phone
|
43 |
+
* @return Zend_Http_Response
|
44 |
+
*/
|
45 |
+
public function getMember($phone)
|
46 |
+
{
|
47 |
+
$uri = $this->_composeUri(
|
48 |
+
$this->_urlKey . '/%s',
|
49 |
+
array($phone)
|
50 |
+
);
|
51 |
+
|
52 |
+
$response = $this->getClient()->setUri($uri)->request(Zend_Http_Client::GET);
|
53 |
+
return $this->decodeAndCheck($response->getBody());
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
app/code/local/Inchoo/Optit/Model/Message.php
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_Message extends Inchoo_Optit_Model_Abstract
|
5 |
+
{
|
6 |
+
const MESSAGE_TYPE_SMS = 'SMS';
|
7 |
+
const MESSAGE_TYPE_MMS = 'MMS';
|
8 |
+
|
9 |
+
const MMS_MEDIA_DIRECTORY = 'optit';
|
10 |
+
|
11 |
+
protected $_urlKey = 'sendmessage';
|
12 |
+
|
13 |
+
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
$this->_init('optit/message');
|
17 |
+
parent::_construct();
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Send a text message to one or many members.
|
22 |
+
* Parameters:
|
23 |
+
* phone - mobile phone number of the member with country code - 1 for U.S. phone numbers. Comma separate for more than one phone number. (Required) Example: 12225551212,12225551211
|
24 |
+
* keyword_id - the keyword_id of the keyword the message is coming from and the member is subscribed to. It is the ID attribute in the Keyword entity and can be viewed using the Get Keyword method. (Required)
|
25 |
+
* title - the title of the message. This does not appear in the text message and is just used in the application as a short description of your message. (Required)
|
26 |
+
* message - the message being sent to the member. The message must be less than 160 characters including your keyword in the beginning of the message. (Required)
|
27 |
+
* Method: POST
|
28 |
+
* http://api.optitmobile.com/1/sendmessage.{format}
|
29 |
+
*
|
30 |
+
* @param array $params
|
31 |
+
* @return mixed
|
32 |
+
* @throws Zend_Http_Client_Exception
|
33 |
+
*/
|
34 |
+
public function sendMessageToMember($params)
|
35 |
+
{
|
36 |
+
$uri = $this->_composeUri(
|
37 |
+
$this->_urlKey
|
38 |
+
);
|
39 |
+
|
40 |
+
$response = $this->getClient()->setUri($uri)->setParameterPost($params)->request(Zend_Http_Client::POST);
|
41 |
+
return $this->decodeAndCheck($response->getBody());
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Send a text message to the subscribed members of one or more keywords. If a member is in multiple keywords,
|
46 |
+
* they will only receive the message once.
|
47 |
+
* Parameters:
|
48 |
+
* keyword_id - the keyword_id of the keyword the message is coming from and the member is subscribed to. It is the ID attribute in the Keyword entity and can be viewed using the Get Keyword method. (Required)
|
49 |
+
* title - the title of the message. This does not appear in the text message and is just used in the application as a short description of your message. (Required)
|
50 |
+
* message - the message being sent to the member. The message must be less than 160 characters including your keyword in the beginning of the message. (Required)
|
51 |
+
* Method: POST
|
52 |
+
* http://api.optitmobile.com/1/sendmessage/keywords.{format}
|
53 |
+
*
|
54 |
+
* @param $params
|
55 |
+
* @return mixed
|
56 |
+
* @throws Zend_Http_Client_Exception
|
57 |
+
*/
|
58 |
+
public function sendMessageToKeyword($params)
|
59 |
+
{
|
60 |
+
$uri = $this->_composeUri(
|
61 |
+
$this->_urlKey . '/keywords'
|
62 |
+
);
|
63 |
+
|
64 |
+
$response = $this->getClient()->setUri($uri)->setParameterPost($params)->request(Zend_Http_Client::POST);
|
65 |
+
return $this->decodeAndCheck($response->getBody());
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Send a text message to the subscribed members of one or more interests. If a member is in multiple interests,
|
70 |
+
* they will only receive the message once. Not all interests have to be associated to the same keyword.
|
71 |
+
* Parameters:
|
72 |
+
* interest_id - the interest_id of the interest the members are subscribed. It is the ID attribute in the Interest entity and can be viewed using the Get Interest method. (Required)
|
73 |
+
* title - the title of the message. This does not appear in the text message and is just used in the application as a short description of your message. (Required)
|
74 |
+
* message - the message being sent to the member. The message must be less than 160 characters including your keyword in the beginning of the message. (Required)
|
75 |
+
* Method: POST
|
76 |
+
* http://api.optitmobile.com/1/sendmessage/interests.{format}
|
77 |
+
*
|
78 |
+
* @param $params
|
79 |
+
* @return mixed
|
80 |
+
* @throws Zend_Http_Client_Exception
|
81 |
+
*/
|
82 |
+
public function sendMessageToInterest($params)
|
83 |
+
{
|
84 |
+
$uri = $this->_composeUri(
|
85 |
+
$this->_urlKey . '/interests'
|
86 |
+
);
|
87 |
+
|
88 |
+
$response = $this->getClient()->setUri($uri)->setParameterPost($params)->request(Zend_Http_Client::POST);
|
89 |
+
return $this->decodeAndCheck($response->getBody());
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Send an MMS message to all users subscribed to a given keyword.
|
94 |
+
* Parameters:
|
95 |
+
* keyword_id - the keyword_id of the keyword the message is coming from and the member is subscribed to. It is the ID attribute in the Keyword entity and can be viewed using the Get Keyword method. (Required)
|
96 |
+
* title - the title of the message. This does not appear in the text message and is just used in the application as a short description of your message. (Required)
|
97 |
+
* message - the message being sent to the member. The message must be less than 160 characters including your keyword in the beginning of the message. (Required)
|
98 |
+
* content_url - URL to the multimedia entity (image, video, audio)
|
99 |
+
* Method: POST
|
100 |
+
* http://api.optitmobile.com/1/sendmms/keywords.{format}
|
101 |
+
*
|
102 |
+
* @param $params
|
103 |
+
* @return mixed
|
104 |
+
* @throws Zend_Http_Client_Exception
|
105 |
+
*/
|
106 |
+
public function sendMmsToKeyword($params)
|
107 |
+
{
|
108 |
+
$uri = $this->_composeUri(
|
109 |
+
'sendmms/keywords'
|
110 |
+
);
|
111 |
+
|
112 |
+
$response = $this->getClient()->setUri($uri)->setParameterPost($params)->request(Zend_Http_Client::POST);
|
113 |
+
return $this->decodeAndCheck($response->getBody());
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Opt It SMS Bulk Send Message.
|
118 |
+
* http://api.optitmobile.com/1/sendmessage/bulk.{format}
|
119 |
+
*
|
120 |
+
* @param array $params
|
121 |
+
* @return mixed
|
122 |
+
* @throws Zend_Http_Client_Exception
|
123 |
+
*/
|
124 |
+
public function sendBulk($params = array())
|
125 |
+
{
|
126 |
+
$uri = $this->_composeUri(
|
127 |
+
$this->_urlKey . '/bulk'
|
128 |
+
);
|
129 |
+
|
130 |
+
$response = $this->getClient()->setUri($uri)->setParameterPost($params)->request(Zend_Http_Client::POST);
|
131 |
+
return $this->checkStatus($response->getStatus());
|
132 |
+
}
|
133 |
+
|
134 |
+
protected function _afterSave()
|
135 |
+
{
|
136 |
+
$data = array();
|
137 |
+
$phone = Mage::getResourceModel('optit/phone');
|
138 |
+
|
139 |
+
if ($this->getType() == Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_MEMBER) {
|
140 |
+
$phone->saveMemberPhoneNumber(array(
|
141 |
+
'message_id' => $this->getId(),
|
142 |
+
'phone_number' => $this->getPhone()
|
143 |
+
));
|
144 |
+
} elseif ($this->getType() == Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_KEYWORD) {
|
145 |
+
$phones = Mage::getSingleton('optit/system_config_source_subscription_phone')->toOptionArray($this->getEntityId());
|
146 |
+
if (empty($phones)) {
|
147 |
+
throw new Exception("There are no phone numbers to save.");
|
148 |
+
}
|
149 |
+
foreach ($phones['subscriptions'] as $value) {
|
150 |
+
$data[] = array(
|
151 |
+
'message_id' => $this->getId(),
|
152 |
+
'phone_number' => $value['subscription']['phone'],
|
153 |
+
);
|
154 |
+
}
|
155 |
+
$phone->saveKeywordPhoneNumbers($data);
|
156 |
+
}
|
157 |
+
parent::_afterSave();
|
158 |
+
}
|
159 |
+
}
|
app/code/local/Inchoo/Optit/Model/Resource/Message.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_Resource_Message extends Mage_Core_Model_Resource_Db_Abstract
|
5 |
+
{
|
6 |
+
public function _construct()
|
7 |
+
{
|
8 |
+
$this->_init('optit/bulk_keyword_messages', 'message_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Inchoo/Optit/Model/Resource/Message/Collection.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_Resource_Message_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
5 |
+
{
|
6 |
+
public function _construct()
|
7 |
+
{
|
8 |
+
$this->_init('optit/message');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function addMessageRecipients()
|
12 |
+
{
|
13 |
+
$this->getSelect()
|
14 |
+
->joinLeft(
|
15 |
+
array('phones' => $this->getTable('optit/bulk_message_phones')),
|
16 |
+
'phones.message_id=main_table.message_id',
|
17 |
+
array('recipients' => 'GROUP_CONCAT(phones.phone_number)'))
|
18 |
+
->group('main_table.message_id');
|
19 |
+
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _prepareForXml()
|
24 |
+
{
|
25 |
+
$data = array();
|
26 |
+
if (!$this->getSize()) {
|
27 |
+
Mage::throwException('No messages to send.');
|
28 |
+
}
|
29 |
+
|
30 |
+
foreach ($this as $key => $item) {
|
31 |
+
$data[$item->getEntityId()][$key] = array(
|
32 |
+
'message' => $item->getMessage(),
|
33 |
+
'phones' => explode(',', $item->getRecipients()),
|
34 |
+
'title' => $item->getTitle(),
|
35 |
+
);
|
36 |
+
if ($contentUrl = $item->getContentUrl()) {
|
37 |
+
$data[$item->getEntityId()][$key] = array_merge(
|
38 |
+
$data[$item->getEntityId()][$key],
|
39 |
+
array('content_url' => $contentUrl)
|
40 |
+
);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
$this->_data = $data;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function toSmsXml()
|
48 |
+
{
|
49 |
+
$this->_prepareForXml();
|
50 |
+
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><keywords/>');
|
51 |
+
foreach ($this->_data as $keywordId => $messages) {
|
52 |
+
$keywordObj = $xml->addChild('keyword');
|
53 |
+
$keywordObj->addAttribute('id', $keywordId);
|
54 |
+
$messagesObj = $keywordObj->addChild('messages');
|
55 |
+
foreach ($messages as $message) {
|
56 |
+
$messageObj = $messagesObj->addChild('message');
|
57 |
+
$messageObj->addAttribute('title', $message['title']);
|
58 |
+
$messageObj->addAttribute('text', $message['message']);
|
59 |
+
$recipientsObj = $messageObj->addChild('recipients');
|
60 |
+
foreach ($message['phones'] as $phone) {
|
61 |
+
$recipientsObj->addChild('phone', $phone);
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
return $xml->asXML();
|
67 |
+
}
|
68 |
+
|
69 |
+
public function toMmsXml()
|
70 |
+
{
|
71 |
+
$this->_prepareForXml();
|
72 |
+
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><keywords/>');
|
73 |
+
foreach ($this->_data as $keywordId => $messages) {
|
74 |
+
$keywordObj = $xml->addChild('keyword');
|
75 |
+
$keywordObj->addAttribute('id', $keywordId);
|
76 |
+
$messagesObj = $keywordObj->addChild('messages');
|
77 |
+
foreach ($messages as $message) {
|
78 |
+
$messageObj = $messagesObj->addChild('message');
|
79 |
+
$messageObj->addAttribute('title', $message['title']);
|
80 |
+
$messageObj->addAttribute('text', $message['message']);
|
81 |
+
if ($message['content_url']) {
|
82 |
+
$messageObj->addAttribute('content_url', $message['content_url']);
|
83 |
+
}
|
84 |
+
$recipientsObj = $messageObj->addChild('recipients');
|
85 |
+
foreach ($message['phones'] as $phone) {
|
86 |
+
$recipientsObj->addChild('phone', $phone);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
return $xml->asXML();
|
92 |
+
}
|
93 |
+
|
94 |
+
public function clear()
|
95 |
+
{
|
96 |
+
foreach ($this as $item) {
|
97 |
+
$item->delete();
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
}
|
app/code/local/Inchoo/Optit/Model/Resource/Phone.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_Resource_Phone extends Mage_Core_Model_Resource_Db_Abstract
|
5 |
+
{
|
6 |
+
protected $_isPkAutoIncrement = false;
|
7 |
+
|
8 |
+
public function _construct()
|
9 |
+
{
|
10 |
+
$this->_setMainTable('optit/bulk_message_phones');
|
11 |
+
}
|
12 |
+
|
13 |
+
public function saveMemberPhoneNumber($data)
|
14 |
+
{
|
15 |
+
return $this->_getWriteAdapter()->insert(
|
16 |
+
$this->getMainTable(),
|
17 |
+
$data
|
18 |
+
);
|
19 |
+
}
|
20 |
+
|
21 |
+
public function saveKeywordPhoneNumbers($data)
|
22 |
+
{
|
23 |
+
return $this->_getWriteAdapter()->insertMultiple(
|
24 |
+
$this->getMainTable(),
|
25 |
+
$data
|
26 |
+
);
|
27 |
+
}
|
28 |
+
}
|
app/code/local/Inchoo/Optit/Model/Subscription.php
ADDED
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_Subscription extends Inchoo_Optit_Model_Abstract
|
5 |
+
{
|
6 |
+
const SUBSCRIPTION_TYPE_KEYWORD = 'keyword';
|
7 |
+
const SUBSCRIPTION_TYPE_INTEREST = 'interest';
|
8 |
+
const SUBSCRIPTION_TYPE_MEMBER = 'member';
|
9 |
+
|
10 |
+
protected $_urlKey = 'subscriptions';
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Get all subscription by keyword or interest.
|
15 |
+
*
|
16 |
+
* @param string $type
|
17 |
+
* @param int $id
|
18 |
+
* @param array $params
|
19 |
+
* @return mixed
|
20 |
+
*/
|
21 |
+
public function getAllSubscriptions($type, $id, $params = array())
|
22 |
+
{
|
23 |
+
$response = '';
|
24 |
+
if ($type == self::SUBSCRIPTION_TYPE_KEYWORD) {
|
25 |
+
$response = $this->getSubscriptionsByKeyword($id, $params);
|
26 |
+
} elseif ($type == self::SUBSCRIPTION_TYPE_INTEREST) {
|
27 |
+
$response = $this->getSubscriptionsByInterest($id, $params);
|
28 |
+
}
|
29 |
+
|
30 |
+
return $response;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Get an individual subscription.
|
35 |
+
* Method: GET
|
36 |
+
* http://api.optitmobile.com/1/keywords/{keyword_id}/subscriptions/{phone}.{format}
|
37 |
+
*
|
38 |
+
* @param int $keywordId
|
39 |
+
* @param string $phone
|
40 |
+
* @return mixed
|
41 |
+
* @throws Zend_Http_Client_Exception
|
42 |
+
*/
|
43 |
+
public function getSubscription($keywordId, $phone)
|
44 |
+
{
|
45 |
+
$uri = $this->_composeUri(
|
46 |
+
'keywords/%s/' . $this->_urlKey . '/%s',
|
47 |
+
array($keywordId, $phone)
|
48 |
+
);
|
49 |
+
|
50 |
+
$response = $this->getClient()->setUri($uri)->request(Zend_Http_Client::GET);
|
51 |
+
return $this->decodeAndCheck($response->getBody());
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Subscribes a member to a keyword.
|
56 |
+
* Parameters:
|
57 |
+
* phone - mobile phone number of the member with country code - 1 for U.S. phone numbers. (Phone or member_id is required) Example: 12225551212
|
58 |
+
* member_id - the member_id of a member. It is the ID attribute in the Members entity and can be viewed using the Get Member method. (Phone or member_id is required)
|
59 |
+
* interest_id - add this user to one or many interests. For multiple interests, please comma separate the interest_ids. It is the ID attribute in the Interest entity and can be viewed using the Get Interest method.
|
60 |
+
* first_name - first name of the member
|
61 |
+
* last_name - last name of the member
|
62 |
+
* address1 - address line 1 of the member
|
63 |
+
* address2 - address line 2 of the member
|
64 |
+
* city - city of the member
|
65 |
+
* state - state of the member as a two character abbreviation
|
66 |
+
* zip - zip code or postal code of the member
|
67 |
+
* gender - gender of the member. Values: [male, female]
|
68 |
+
* birth_date - birthdate in the format yyyymmdd
|
69 |
+
* email_address - email address of the member
|
70 |
+
* Method: POST
|
71 |
+
* http://api.optitmobile.com/1/keywords/{keyword_id}/subscriptions.{format}
|
72 |
+
*
|
73 |
+
* @param int $keywordId
|
74 |
+
* @param array $params
|
75 |
+
* @return mixed
|
76 |
+
* @throws Zend_Http_Client_Exception
|
77 |
+
*/
|
78 |
+
public function subscribeMemberToKeyword($keywordId, $params)
|
79 |
+
{
|
80 |
+
$uri = $this->_composeUri(
|
81 |
+
'keywords/%s/' . $this->_urlKey,
|
82 |
+
array($keywordId)
|
83 |
+
);
|
84 |
+
|
85 |
+
$response = $this->getClient()->setUri($uri)->setParameterPost($params)->request(Zend_Http_Client::POST);
|
86 |
+
return $this->decodeAndCheck($response->getBody());
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Add a subscribed member to an interest.
|
91 |
+
* Parameters:
|
92 |
+
* phone - mobile phone number of the member with country code - 1 for U.S. phone numbers. (Phone or member_id is required) Example: 12225551212
|
93 |
+
* member_id - the member_id of a member. It is the ID attribute in the Members entity and can be viewed using the Get Member method. (Phone or member_id is required)
|
94 |
+
* Method: POST
|
95 |
+
* http://api.optitmobile.com/1/interests/{interest_id}/subscriptions.{format}
|
96 |
+
*
|
97 |
+
* @param $interestId
|
98 |
+
* @param array $params
|
99 |
+
* @return mixed
|
100 |
+
* @throws Zend_Http_Client_Exception
|
101 |
+
*/
|
102 |
+
public function subscribeMemberToInterest($interestId, $params = array())
|
103 |
+
{
|
104 |
+
$uri = $this->_composeUri(
|
105 |
+
'interests/%s/' . $this->_urlKey,
|
106 |
+
array($interestId)
|
107 |
+
);
|
108 |
+
|
109 |
+
$response = $this->getClient()->setUri($uri)->setParameterPost($params)->request(Zend_Http_Client::POST);
|
110 |
+
return $this->decodeAndCheck($response->getBody());
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Unsubscribe a member from all keywords.
|
115 |
+
* Method: DELETE
|
116 |
+
* http://api.optitmobile.com/1/subscription/{phone}.{format}
|
117 |
+
*
|
118 |
+
* @param string $phone
|
119 |
+
* @return mixed
|
120 |
+
* @throws Zend_Http_Client_Exception
|
121 |
+
*/
|
122 |
+
public function unsubscriberMemberFromAllKeywords($phone)
|
123 |
+
{
|
124 |
+
$uri = $this->_composeUri(
|
125 |
+
'subscription/%s',
|
126 |
+
array($phone)
|
127 |
+
);
|
128 |
+
|
129 |
+
$response = $this->getClient()->setUri($uri)->request(Zend_Http_Client::DELETE);
|
130 |
+
return $this->decodeAndCheck($response->getBody());
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Unsubscribe a member from one keyword
|
135 |
+
* Method: DELETE
|
136 |
+
* http://api.optitmobile.com/1/keywords/{keyword_id}/subscription/{phone}.{format}
|
137 |
+
*
|
138 |
+
* @param int $keywordId
|
139 |
+
* @param string $memberPhone
|
140 |
+
* @return mixed
|
141 |
+
* @throws Zend_Http_Client_Exception
|
142 |
+
*/
|
143 |
+
public function unsubscribeMemberFromKeyword($keywordId, $memberPhone)
|
144 |
+
{
|
145 |
+
$uri = $this->_composeUri(
|
146 |
+
'keywords/%s/subscription/%s',
|
147 |
+
array($keywordId, $memberPhone)
|
148 |
+
);
|
149 |
+
|
150 |
+
$response = $this->getClient()->setUri($uri)->request(Zend_Http_Client::DELETE);
|
151 |
+
return $this->decodeAndCheck($response->getBody());
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Delete a subscribed member from an interest.
|
156 |
+
* Method: DELETE
|
157 |
+
* http://api.optitmobile.com/1/interests/{interest_id}/subscriptions/{phone}.{format}
|
158 |
+
*
|
159 |
+
* @param int $interestId
|
160 |
+
* @param string $memberPhone
|
161 |
+
* @return mixed
|
162 |
+
* @throws Zend_Http_Client_Exception
|
163 |
+
*/
|
164 |
+
public function unsubscribeMemberFromInterest($interestId, $memberPhone)
|
165 |
+
{
|
166 |
+
$uri = $this->_composeUri(
|
167 |
+
'interests/%s/' . $this->_urlKey .'/%s',
|
168 |
+
array($interestId, $memberPhone)
|
169 |
+
);
|
170 |
+
|
171 |
+
$response = $this->getClient()->setUri($uri)->request(Zend_Http_Client::DELETE);
|
172 |
+
return $this->decodeAndCheck($response->getBody());
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Get a list of active subscriptions associated to an interest.
|
177 |
+
* Parameters:
|
178 |
+
* phone - mobile phone number of the member with country code - 1 for U.S. phone numbers. Example: 12225551212
|
179 |
+
* member_id - the member_id of a member. It is the ID attribute in the Members entity and can be viewed using the Get Member method.
|
180 |
+
* first_name - first name of the member
|
181 |
+
* last_name - last name of the member
|
182 |
+
* zip - zip code or postal code of the member
|
183 |
+
* gender - gender of the member. Values: [male, female]
|
184 |
+
* signup_date_start - yyyymmddhhmmss
|
185 |
+
* signup_date_end - yyyymmddhhmmss
|
186 |
+
* Method: GET
|
187 |
+
* http://api.optitmobile.com/1/interests/{interest_id}/subscriptions.{format}
|
188 |
+
*
|
189 |
+
* @param int $interestId
|
190 |
+
* @param array $params
|
191 |
+
* @return mixed
|
192 |
+
* @throws Zend_Http_Client_Exception
|
193 |
+
*/
|
194 |
+
public function getSubscriptionsByInterest($interestId, $params = array())
|
195 |
+
{
|
196 |
+
$uri = $this->_composeUri(
|
197 |
+
'interests/%s/' . $this->_urlKey,
|
198 |
+
array($interestId)
|
199 |
+
);
|
200 |
+
|
201 |
+
$response = $this->getClient()->setUri($uri)->setParameterGet($params)->request(Zend_Http_Client::GET);
|
202 |
+
return $this->decodeAndCheck($response->getBody());
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Get a list of subscribed members for an individual keyword.
|
207 |
+
* Parameters:
|
208 |
+
* phone - mobile phone number of the member with country code - 1 for U.S. phone numbers. Example: 12225551212
|
209 |
+
* member_id - the member_id of a member. It is the ID attribute in the Members entity and can be viewed using the Get Member method.
|
210 |
+
* first_name - first name of the member
|
211 |
+
* last_name - last name of the member
|
212 |
+
* zip - zip code or postal code of the member
|
213 |
+
* gender - gender of the member. Values: [male, female]
|
214 |
+
* signup_date_start - yyyymmddhhmmss
|
215 |
+
* signup_date_end - yyyymmddhhmmss
|
216 |
+
* Method: GET
|
217 |
+
* http://api.optitmobile.com/1/keywords/{keyword_id}/subscriptions.{format}
|
218 |
+
*
|
219 |
+
* @param $keywordId
|
220 |
+
* @param array $params
|
221 |
+
* @return mixed
|
222 |
+
* @throws Zend_Http_Client_Exception
|
223 |
+
*/
|
224 |
+
public function getSubscriptionsByKeyword($keywordId, $params = array())
|
225 |
+
{
|
226 |
+
$uri = $this->_composeUri(
|
227 |
+
'keywords/%s/' . $this->_urlKey,
|
228 |
+
array($keywordId)
|
229 |
+
);
|
230 |
+
|
231 |
+
$response = $this->getClient()->setUri($uri)->setParameterGet($params)->request(Zend_Http_Client::GET);
|
232 |
+
return $this->decodeAndCheck($response->getBody());
|
233 |
+
}
|
234 |
+
}
|
app/code/local/Inchoo/Optit/Model/System/Config/Source/Billing/Type.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_System_Config_Source_Billing_Type
|
5 |
+
{
|
6 |
+
public function toOptionArray()
|
7 |
+
{
|
8 |
+
return array(
|
9 |
+
array('value' => 'Unlimited', 'label' => Mage::helper('adminhtml')->__('Unlimited')),
|
10 |
+
array('value' => 'Per-message', 'label' => Mage::helper('adminhtml')->__('Per Message')),
|
11 |
+
);
|
12 |
+
}
|
13 |
+
}
|
app/code/local/Inchoo/Optit/Model/System/Config/Source/Customer/Gender.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_System_Config_Source_Customer_Gender
|
5 |
+
{
|
6 |
+
public function toOptionArray()
|
7 |
+
{
|
8 |
+
return array(
|
9 |
+
array('value' => '', 'label' => Mage::helper('adminhtml')->__('-- Please select --')),
|
10 |
+
array('value' => 'male', 'label' => Mage::helper('adminhtml')->__('Male')),
|
11 |
+
array('value' => 'female', 'label' => Mage::helper('adminhtml')->__('Female')),
|
12 |
+
);
|
13 |
+
}
|
14 |
+
}
|
app/code/local/Inchoo/Optit/Model/System/Config/Source/Message/Keyword.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_System_Config_Source_Message_Keyword
|
5 |
+
{
|
6 |
+
protected $_data = array();
|
7 |
+
|
8 |
+
protected $_key = 0;
|
9 |
+
|
10 |
+
|
11 |
+
public function toOptionArray()
|
12 |
+
{
|
13 |
+
$currentPage = 1;
|
14 |
+
$keywords = $this->_getKeywords($currentPage);
|
15 |
+
$totalPages = $keywords['total_pages'];
|
16 |
+
$this->_populateData($keywords);
|
17 |
+
|
18 |
+
while ($currentPage != $totalPages) {
|
19 |
+
$currentPage++;
|
20 |
+
$keywords = $this->_getKeywords($currentPage);
|
21 |
+
$this->_populateData($keywords);
|
22 |
+
}
|
23 |
+
|
24 |
+
return $this->_data;
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _getKeywords($page)
|
28 |
+
{
|
29 |
+
return Mage::getModel('optit/keyword')->getAllKeywords(array('page' => $page));
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _populateData($data)
|
33 |
+
{
|
34 |
+
foreach ($data['keywords'] as $key => $value) {
|
35 |
+
$this->_data[$this->_key]['value'] = $value['keyword']['id'];
|
36 |
+
$this->_data[$this->_key]['label'] = $value['keyword']['keyword_name'];
|
37 |
+
$this->_key++;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
app/code/local/Inchoo/Optit/Model/System/Config/Source/Subscribed/Message/Type.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_System_Config_Source_Subscribed_Message_Type
|
5 |
+
{
|
6 |
+
public function toOptionArray()
|
7 |
+
{
|
8 |
+
return array(
|
9 |
+
array('value' => 'standard', 'label' => Mage::helper('adminhtml')->__('Standard')),
|
10 |
+
array('value' => 'custom', 'label' => Mage::helper('adminhtml')->__('Custom')),
|
11 |
+
array('value' => 'none', 'label' => Mage::helper('adminhtml')->__('None')),
|
12 |
+
);
|
13 |
+
}
|
14 |
+
}
|
app/code/local/Inchoo/Optit/Model/System/Config/Source/Subscription/Interest.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_System_Config_Source_Subscription_Interest
|
5 |
+
{
|
6 |
+
protected $_data = array();
|
7 |
+
|
8 |
+
protected $_key = 0;
|
9 |
+
|
10 |
+
public function toOptionArray($keywordId)
|
11 |
+
{
|
12 |
+
$currentPage = 1;
|
13 |
+
$interests = $this->_getInterests($keywordId, $currentPage);
|
14 |
+
$totalPages = $interests['total_pages'];
|
15 |
+
$this->_populateData($interests);
|
16 |
+
|
17 |
+
while ($currentPage != $totalPages) {
|
18 |
+
$currentPage++;
|
19 |
+
$interests = $this->_getInterests($keywordId, $currentPage);
|
20 |
+
$this->_populateData($interests);
|
21 |
+
}
|
22 |
+
|
23 |
+
return $this->_data;
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function _getInterests($keywordId, $page)
|
27 |
+
{
|
28 |
+
return Mage::getModel('optit/interest')->getAllInterests($keywordId, array('page' => $page));
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _populateData($interests)
|
32 |
+
{
|
33 |
+
foreach ($interests['interests'] as $key => $value) {
|
34 |
+
$this->_data[$this->_key]['value'] = $value['interest']['id'];
|
35 |
+
$this->_data[$this->_key]['label'] = $value['interest']['name'];
|
36 |
+
$this->_key++;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
app/code/local/Inchoo/Optit/Model/System/Config/Source/Subscription/Phone.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_System_Config_Source_Subscription_Phone
|
5 |
+
{
|
6 |
+
protected $_data = array();
|
7 |
+
protected $_key = 0;
|
8 |
+
|
9 |
+
public function toOptionArray($keywordId, $interestId = null)
|
10 |
+
{
|
11 |
+
$data = array();
|
12 |
+
$subscribersPhones= array();
|
13 |
+
|
14 |
+
if (!is_null($interestId)) {
|
15 |
+
$subscribersKeyword = $this->_getAllSubscribersByKeyword($keywordId);
|
16 |
+
foreach ($subscribersKeyword['subscriptions'] as $value) {
|
17 |
+
$subscribersPhones[$value['subscription']['phone']] = $value['subscription']['phone'];
|
18 |
+
}
|
19 |
+
$subscribersInterest = Mage::getModel('optit/subscription')->getSubscriptionsByInterest($interestId);
|
20 |
+
foreach ($subscribersInterest['subscriptions'] as $value) {
|
21 |
+
unset($subscribersPhones[$value['subscription']['phone']]);
|
22 |
+
}
|
23 |
+
|
24 |
+
foreach ($subscribersPhones as $key => $phone) {
|
25 |
+
$data[$key]['value'] = $phone;
|
26 |
+
$data[$key]['label'] = $phone;
|
27 |
+
}
|
28 |
+
} else {
|
29 |
+
$data = $this->_getAllSubscribersByKeyword($keywordId);
|
30 |
+
}
|
31 |
+
|
32 |
+
return $data;
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _getAllSubscribersByKeyword($keywordId)
|
36 |
+
{
|
37 |
+
$currentPage = 1;
|
38 |
+
$phones = $this->_getPhones($keywordId, $currentPage);
|
39 |
+
$totalPages = $phones['total_pages'];
|
40 |
+
$this->_populateData($phones);
|
41 |
+
|
42 |
+
while ($currentPage != $totalPages) {
|
43 |
+
$currentPage++;
|
44 |
+
$phones = $this->_getPhones($keywordId, $currentPage);
|
45 |
+
$this->_populateData($phones);
|
46 |
+
}
|
47 |
+
|
48 |
+
return $this->_data;
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function _getPhones($keywordId, $currentPage)
|
52 |
+
{
|
53 |
+
return Mage::getModel('optit/subscription')->getSubscriptionsByKeyword($keywordId, array('page' => $currentPage));
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function _populateData($phones)
|
57 |
+
{
|
58 |
+
foreach ($phones['subscriptions'] as $key => $value) {
|
59 |
+
$this->_data['subscriptions'][$this->_key] = $value;
|
60 |
+
$this->_key++;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
app/code/local/Inchoo/Optit/Model/System/Config/Source/Web/Form/Message/Type.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Model_System_Config_Source_Web_Form_Message_Type
|
5 |
+
{
|
6 |
+
public function toOptionArray()
|
7 |
+
{
|
8 |
+
return array(
|
9 |
+
array('value' => 'standard', 'label' => Mage::helper('adminhtml')->__('Standard')),
|
10 |
+
array('value' => 'semi-custom', 'label' => Mage::helper('adminhtml')->__('Semi-custom')),
|
11 |
+
);
|
12 |
+
}
|
13 |
+
}
|
app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/BulkController.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Adminhtml_Optit_BulkController extends Mage_Adminhtml_Controller_Action
|
5 |
+
{
|
6 |
+
protected function _initAction()
|
7 |
+
{
|
8 |
+
$this->loadLayout()
|
9 |
+
->_setActiveMenu('promo/optit')
|
10 |
+
->_title($this->__('Opt It'))
|
11 |
+
->_title($this->__('Bulk Messaging'));
|
12 |
+
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function smsAction()
|
17 |
+
{
|
18 |
+
$this->_initAction();
|
19 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
20 |
+
$this->_forward('smsGrid');
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
$this->_title('SMS');
|
25 |
+
$this->renderLayout();
|
26 |
+
}
|
27 |
+
|
28 |
+
public function sendSmsAction()
|
29 |
+
{
|
30 |
+
try {
|
31 |
+
$collection = Mage::getModel('optit/message')->getCollection()
|
32 |
+
->addFieldToFilter('message_type', array('eq' => Inchoo_Optit_Model_Message::MESSAGE_TYPE_SMS))
|
33 |
+
->addMessageRecipients();
|
34 |
+
|
35 |
+
$model = Mage::getModel('optit/message');
|
36 |
+
|
37 |
+
$params = array(
|
38 |
+
'data' => $collection->toSmsXml()
|
39 |
+
);
|
40 |
+
|
41 |
+
$model->sendBulk($params);
|
42 |
+
$collection->clear();
|
43 |
+
$this->_getSession()->addSuccess('Messages successfully sent.');
|
44 |
+
} catch (Mage_Core_Exception $e) {
|
45 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
46 |
+
}
|
47 |
+
|
48 |
+
$this->_redirectReferer();
|
49 |
+
}
|
50 |
+
|
51 |
+
public function smsGridAction()
|
52 |
+
{
|
53 |
+
$this->loadLayout();
|
54 |
+
$this->renderLayout();
|
55 |
+
}
|
56 |
+
|
57 |
+
public function mmsAction()
|
58 |
+
{
|
59 |
+
$this->_initAction();
|
60 |
+
$this->_title('MMS');
|
61 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
62 |
+
$this->_forward('mmsGrid');
|
63 |
+
return;
|
64 |
+
}
|
65 |
+
|
66 |
+
$this->renderLayout();
|
67 |
+
}
|
68 |
+
|
69 |
+
public function sendMmsAction()
|
70 |
+
{
|
71 |
+
try {
|
72 |
+
$collection = Mage::getModel('optit/message')->getCollection()
|
73 |
+
->addFieldToFilter('message_type', array('eq' => Inchoo_Optit_Model_Message::MESSAGE_TYPE_MMS))
|
74 |
+
->addMessageRecipients();
|
75 |
+
|
76 |
+
$model = Mage::getModel('optit/message');
|
77 |
+
|
78 |
+
$params = array(
|
79 |
+
'data' => $collection->toMmsXml()
|
80 |
+
);
|
81 |
+
|
82 |
+
$model->sendBulk($params);
|
83 |
+
$collection->clear();
|
84 |
+
$this->_getSession()->addSuccess('Messages successfully sent.');
|
85 |
+
} catch (Mage_Core_Exception $e) {
|
86 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
87 |
+
}
|
88 |
+
|
89 |
+
$this->_redirectReferer();
|
90 |
+
}
|
91 |
+
|
92 |
+
public function mmsGridAction()
|
93 |
+
{
|
94 |
+
$this->loadLayout();
|
95 |
+
$this->renderLayout();
|
96 |
+
}
|
97 |
+
|
98 |
+
public function clearAction()
|
99 |
+
{
|
100 |
+
$type = $this->getRequest()->getParam('type');
|
101 |
+
|
102 |
+
try {
|
103 |
+
$collection = Mage::getModel('optit/message')->getCollection()
|
104 |
+
->addFieldToFilter('message_type', array('eq' => $type))
|
105 |
+
->addMessageRecipients();
|
106 |
+
|
107 |
+
$collection->clear();
|
108 |
+
$this->_getSession()->addSuccess('List cleared.');
|
109 |
+
} catch (Mage_Core_Exception $e) {
|
110 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
111 |
+
}
|
112 |
+
|
113 |
+
$this->_redirectReferer();
|
114 |
+
}
|
115 |
+
}
|
app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/InterestController.php
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Adminhtml_Optit_InterestController extends Mage_Adminhtml_Controller_Action
|
5 |
+
{
|
6 |
+
protected function _initAction()
|
7 |
+
{
|
8 |
+
$this->loadLayout()
|
9 |
+
->_setActiveMenu('promo/optit')
|
10 |
+
->_title($this->__('Opt It'))
|
11 |
+
->_title($this->__('Interests'));
|
12 |
+
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function indexAction()
|
17 |
+
{
|
18 |
+
$this->_initAction();
|
19 |
+
$request = $this->getRequest();
|
20 |
+
$grid = $this->getLayout()->getBlock('optit_interest')->getChild('grid');
|
21 |
+
|
22 |
+
if ($request->getQuery('ajax')) {
|
23 |
+
$this->_forward('grid');
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
|
27 |
+
$params = array('page' => $grid->getParam($grid->getVarNamePage(), 1));
|
28 |
+
|
29 |
+
$keywordId = $request->getParam('keyword_id');
|
30 |
+
if (!$keywordId) {
|
31 |
+
$this->_redirect('*/optit_keyword');
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
|
35 |
+
try {
|
36 |
+
$data = Mage::getModel('optit/interest')->getAllInterests($keywordId, $params);
|
37 |
+
if (!$this->validatePages($data)) {
|
38 |
+
$this->_redirect('*/optit_interest', array('keyword_id' => $keywordId));
|
39 |
+
return;
|
40 |
+
}
|
41 |
+
if ($grid) {
|
42 |
+
$grid->setData($data);
|
43 |
+
$grid->setPage($params);
|
44 |
+
}
|
45 |
+
} catch (Mage_Core_Exception $e) {
|
46 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
47 |
+
$this->_initLayoutMessages('adminhtml/session');
|
48 |
+
}
|
49 |
+
|
50 |
+
$this->renderLayout();
|
51 |
+
}
|
52 |
+
|
53 |
+
public function gridAction()
|
54 |
+
{
|
55 |
+
$this->loadLayout();
|
56 |
+
$grid = $this->getLayout()->getBlock('optit_keyword')->getChild('grid');
|
57 |
+
|
58 |
+
$params = array(
|
59 |
+
'page' => $grid->getVarNamePage()
|
60 |
+
);
|
61 |
+
|
62 |
+
$keywordId = $this->getRequest()->getParam('keyword_id');
|
63 |
+
|
64 |
+
try {
|
65 |
+
$data = Mage::getModel('optit/interest')->getAllInterests($keywordId, $params);
|
66 |
+
if ($grid) {
|
67 |
+
$grid->setData($data);
|
68 |
+
}
|
69 |
+
} catch (Mage_Core_Exception $e) {
|
70 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
71 |
+
$this->_initLayoutMessages('adminhtml/session');
|
72 |
+
}
|
73 |
+
$this->renderLayout();
|
74 |
+
}
|
75 |
+
|
76 |
+
public function newAction()
|
77 |
+
{
|
78 |
+
$this->_initAction();
|
79 |
+
$this->_title($this->__('New Interest'));
|
80 |
+
$this->_addBreadcrumb($this->__('New Interest'), $this->__('New Interest'))
|
81 |
+
->_addContent($this->getLayout()->createBlock('optit/adminhtml_interest_edit'))
|
82 |
+
->renderLayout();
|
83 |
+
}
|
84 |
+
|
85 |
+
public function saveAction()
|
86 |
+
{
|
87 |
+
$request = $this->getRequest();
|
88 |
+
$params = $request->getPost();
|
89 |
+
$keywordId = $request->getParam('keyword_id');
|
90 |
+
|
91 |
+
$interest = Mage::getModel('optit/interest');
|
92 |
+
|
93 |
+
try {
|
94 |
+
$this->_validateInterestRequired($params);
|
95 |
+
$interest->createInterest($keywordId, $params);
|
96 |
+
$this->_getSession()->addSuccess($this->__('Interest created.'));
|
97 |
+
} catch (Mage_Core_Exception $e) {
|
98 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
99 |
+
$this->_getSession()->setData('form_data', $params);
|
100 |
+
}
|
101 |
+
$this->_redirect('*/*/', array(
|
102 |
+
'keyword_id' => $request->getParam('keyword_id'),
|
103 |
+
'keyword_name' => $request->getParam('keyword_name'),
|
104 |
+
'type_name' => $request->getParam('type_name'),
|
105 |
+
));
|
106 |
+
}
|
107 |
+
|
108 |
+
public function subscribeAction()
|
109 |
+
{
|
110 |
+
$this->_initAction();
|
111 |
+
$request = $this->getRequest();
|
112 |
+
$keywordId = $this->getRequest()->getParam('keyword_id');
|
113 |
+
$interestId = $this->getRequest()->getParam('interest_id');
|
114 |
+
$phones = Mage::getSingleton('optit/system_config_source_subscription_phone')->toOptionArray($keywordId, $interestId);
|
115 |
+
|
116 |
+
if (empty($phones)) {
|
117 |
+
Mage::getSingleton('adminhtml/session')->addError('There are no phone numbers subscribed to a keyword.');
|
118 |
+
$this->_redirect('*/optit_subscription/interest', array(
|
119 |
+
'interest_id' => $request->getParam('interest_id'),
|
120 |
+
'keyword_id' => $request->getParam('keyword_id'),
|
121 |
+
'keyword_name' => $request->getParam('keyword_name'),
|
122 |
+
'type_name' => $request->getParam('type_name'),
|
123 |
+
));
|
124 |
+
return;
|
125 |
+
}
|
126 |
+
$this->_title($this->__('Subscribe To Interest'));
|
127 |
+
$this->_addBreadcrumb($this->__('Subscribe To Interest'), $this->__('Subscribe To Interest'))
|
128 |
+
->_addContent($this->getLayout()->createBlock('optit/adminhtml_subscription_subscribe_edit', 'optit_interest_subscribe'));
|
129 |
+
|
130 |
+
if ($form = $this->getLayout()->getBlock('optit_interest_subscribe')->getChild('form')) {
|
131 |
+
$form->setPhones($phones);
|
132 |
+
}
|
133 |
+
$this->renderLayout();
|
134 |
+
}
|
135 |
+
|
136 |
+
public function subscribeSaveAction()
|
137 |
+
{
|
138 |
+
$request = $this->getRequest();
|
139 |
+
$params = $request->getPost();
|
140 |
+
$interestId = $request->getParam('interest_id');
|
141 |
+
|
142 |
+
$interest = Mage::getModel('optit/subscription');
|
143 |
+
|
144 |
+
try {
|
145 |
+
$this->_validateSubscribeRequired($params);
|
146 |
+
$interest->subscribeMemberToInterest($interestId, $params);
|
147 |
+
$this->_getSession()->addSuccess($this->__('Member Subscribed'));
|
148 |
+
} catch (Mage_Core_Exception $e) {
|
149 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
150 |
+
}
|
151 |
+
$this->_redirect('*/optit_subscription/interest/', array(
|
152 |
+
'interest_id' => $request->getParam('interest_id'),
|
153 |
+
'keyword_id' => $request->getParam('keyword_id'),
|
154 |
+
'keyword_name' => $this->getRequest()->getParam('keyword_name'),
|
155 |
+
'type_name' => $this->getRequest()->getParam('type_name'),
|
156 |
+
));
|
157 |
+
}
|
158 |
+
|
159 |
+
public function unsubscribeAction()
|
160 |
+
{
|
161 |
+
$request = $this->getRequest();
|
162 |
+
$interestId = $request->getParam('filter_id');
|
163 |
+
$phone = $request->getParam('phone');
|
164 |
+
|
165 |
+
$model = Mage::getModel('optit/subscription');
|
166 |
+
try {
|
167 |
+
$model->unsubscribeMemberFromInterest($interestId, $phone);
|
168 |
+
$this->_getSession()->addSuccess($this->__('Member Unsubscribed'));
|
169 |
+
} catch (Mage_Core_Exception $e) {
|
170 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
171 |
+
}
|
172 |
+
$this->_redirect('*/optit_subscription/interest', array(
|
173 |
+
'interest_id' => $this->getRequest()->getParam('interest_id'),
|
174 |
+
'keyword_id' => $this->getRequest()->getParam('keyword_id'),
|
175 |
+
'keyword_name' => $this->getRequest()->getParam('keyword_name'),
|
176 |
+
'type_name' => $this->getRequest()->getParam('type_name'),
|
177 |
+
));
|
178 |
+
}
|
179 |
+
|
180 |
+
protected function _validateSubscribeRequired($params)
|
181 |
+
{
|
182 |
+
$error = false;
|
183 |
+
if (!Zend_Validate::is($params['phone'], 'NotEmpty')) {
|
184 |
+
$error = true;
|
185 |
+
}
|
186 |
+
|
187 |
+
if ($error) {
|
188 |
+
Mage::throwException('Required parameters not set.');
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
protected function _validateInterestRequired($params)
|
193 |
+
{
|
194 |
+
$error = false;
|
195 |
+
if (!Zend_Validate::is($params['name'], 'NotEmpty')) {
|
196 |
+
$error = true;
|
197 |
+
}
|
198 |
+
|
199 |
+
if ($error) {
|
200 |
+
Mage::throwException('Required parameters not set.');
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
protected function validatePages($data)
|
205 |
+
{
|
206 |
+
if (Zend_Validate::is($data['current_page'], 'GreaterThan', array('min' => $data['total_pages']))) {
|
207 |
+
Mage::getSingleton('adminhtml/session')->unsetData('optit_interest_gridpage');
|
208 |
+
$this->_getSession()->addError('Requested page does not exist!');
|
209 |
+
return false;
|
210 |
+
}
|
211 |
+
return true;
|
212 |
+
}
|
213 |
+
}
|
app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/KeywordController.php
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Adminhtml_Optit_KeywordController extends Mage_Adminhtml_Controller_Action
|
5 |
+
{
|
6 |
+
protected function _initAction()
|
7 |
+
{
|
8 |
+
$this->loadLayout()
|
9 |
+
->_setActiveMenu('promo/optit')
|
10 |
+
->_title($this->__('Opt It'))
|
11 |
+
->_title($this->__('Keywords'));
|
12 |
+
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function indexAction()
|
17 |
+
{
|
18 |
+
$this->_initAction();
|
19 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
20 |
+
$this->_forward('grid');
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
try {
|
25 |
+
$data = Mage::getModel('optit/keyword')->getAllKeywords();
|
26 |
+
$grid = $this->getLayout()->getBlock('optit_keyword')->getChild('grid');
|
27 |
+
if ($grid) {
|
28 |
+
$grid->setData($data);
|
29 |
+
}
|
30 |
+
} catch (Mage_Core_Exception $e) {
|
31 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
32 |
+
$this->_initLayoutMessages('adminhtml/session');
|
33 |
+
}
|
34 |
+
$this->renderLayout();
|
35 |
+
}
|
36 |
+
|
37 |
+
public function newAction()
|
38 |
+
{
|
39 |
+
$this->_forward('edit');
|
40 |
+
}
|
41 |
+
|
42 |
+
public function editAction()
|
43 |
+
{
|
44 |
+
$this->_initAction();
|
45 |
+
|
46 |
+
$id = $this->getRequest()->getParam('id');
|
47 |
+
$model = Mage::getModel('optit/keyword');
|
48 |
+
|
49 |
+
if ($id) {
|
50 |
+
$model->loadKeyword($id);
|
51 |
+
|
52 |
+
if (!$model->getId()) {
|
53 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('This keyword no longer exists.'));
|
54 |
+
$this->_redirect('*/*/');
|
55 |
+
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
$this->_title($model->getId() ? $model->getKeywordName() : $this->__('New Keyword'));
|
61 |
+
$data = Mage::getSingleton('adminhtml/session')->getKeywordData(true);
|
62 |
+
if (!empty($data)) {
|
63 |
+
$model->setData($data);
|
64 |
+
}
|
65 |
+
|
66 |
+
Mage::register('optit_keyword', $model);
|
67 |
+
$this->_addBreadcrumb($id ? $this->__('Edit Keyword') : $this->__('New Keyword'), $id ? $this->__('Edit Keyword') : $this->__('New Keyword'))
|
68 |
+
->_addContent($this->getLayout()->createBlock('optit/adminhtml_keyword_edit'))
|
69 |
+
->renderLayout();
|
70 |
+
}
|
71 |
+
|
72 |
+
public function saveAction()
|
73 |
+
{
|
74 |
+
$request = $this->getRequest();
|
75 |
+
$params = $request->getParams();
|
76 |
+
$keywordId = $request->getParam('id');
|
77 |
+
|
78 |
+
$keyword = Mage::getModel('optit/keyword');
|
79 |
+
|
80 |
+
try {
|
81 |
+
if (!$keywordId) {
|
82 |
+
// new
|
83 |
+
$this->_validateNewRequired($params);
|
84 |
+
$keyword->setData('keyword', $params['keyword']);
|
85 |
+
} else {
|
86 |
+
// edit
|
87 |
+
$this->_validateEditRequired($params);
|
88 |
+
$keyword->loadKeyword($keywordId);
|
89 |
+
}
|
90 |
+
|
91 |
+
$keyword->saveKeyword($params);
|
92 |
+
$this->_getSession()->addSuccess($this->__('Keyword saved.'));
|
93 |
+
} catch (Mage_Core_Exception $e) {
|
94 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
95 |
+
$this->_getSession()->addData('keyword_data',
|
96 |
+
$this->getRequest()->getParams());
|
97 |
+
}
|
98 |
+
$this->_redirect('*/*/');
|
99 |
+
}
|
100 |
+
|
101 |
+
public function gridAction()
|
102 |
+
{
|
103 |
+
$this->loadLayout();
|
104 |
+
$this->renderLayout();
|
105 |
+
}
|
106 |
+
|
107 |
+
protected function _validateNewRequired($params)
|
108 |
+
{
|
109 |
+
if (!Zend_Validate::is($params['billing_type'], 'NotEmpty') ||
|
110 |
+
!Zend_Validate::is($params['keyword'], 'NotEmpty') ||
|
111 |
+
!Zend_Validate::is($params['internal_name'], 'NotEmpty')
|
112 |
+
) {
|
113 |
+
Mage::throwException('Required parameters not set.');
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
protected function _validateEditRequired($params)
|
118 |
+
{
|
119 |
+
if (!Zend_Validate::is($params['billing_type'], 'NotEmpty') ||
|
120 |
+
!Zend_Validate::is($params['internal_name'], 'NotEmpty')
|
121 |
+
) {
|
122 |
+
Mage::throwException('Required parameters not set.');
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
}
|
app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/MemberController.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Adminhtml_Optit_MemberController extends Mage_Adminhtml_Controller_Action
|
5 |
+
{
|
6 |
+
protected function _initAction()
|
7 |
+
{
|
8 |
+
$this->loadLayout()
|
9 |
+
->_setActiveMenu('promo/optit')
|
10 |
+
->_title($this->__('Opt It'))
|
11 |
+
->_title($this->__('Members'));
|
12 |
+
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function indexAction()
|
17 |
+
{
|
18 |
+
$this->_initAction();
|
19 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
20 |
+
$this->_forward('grid');
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
try {
|
25 |
+
$data = Mage::getModel('optit/member')->getAllMembers();
|
26 |
+
$grid = $this->getLayout()->getBlock('optit_member')->getChild('grid');
|
27 |
+
if ($grid) {
|
28 |
+
$grid->setData($data);
|
29 |
+
}
|
30 |
+
} catch (Mage_Core_Exception $e) {
|
31 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
32 |
+
$this->_initLayoutMessages('adminhtml/session');
|
33 |
+
}
|
34 |
+
|
35 |
+
$this->renderLayout();
|
36 |
+
}
|
37 |
+
|
38 |
+
public function unsubscribeAction()
|
39 |
+
{
|
40 |
+
$request = $this->getRequest();
|
41 |
+
$phone = $request->getParam('phone');
|
42 |
+
|
43 |
+
$model = Mage::getModel('optit/subscription');
|
44 |
+
|
45 |
+
try {
|
46 |
+
$model->unsubscriberMemberFromAllKeywords($phone);
|
47 |
+
$this->_getSession()->addSuccess($this->__('Member successfully unsubscribed from all keywords.'));
|
48 |
+
} catch (Mage_Core_Exception $e) {
|
49 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
50 |
+
$this->_getSession()->addError("{$phone} could not be unsubscribed. Maybe it did not have any associated subscriptions.");
|
51 |
+
}
|
52 |
+
$this->_redirect('*/*/');
|
53 |
+
}
|
54 |
+
}
|
app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/MessageController.php
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Adminhtml_Optit_MessageController extends Mage_Adminhtml_Controller_Action
|
5 |
+
{
|
6 |
+
protected function _initAction()
|
7 |
+
{
|
8 |
+
$this->loadLayout()
|
9 |
+
->_setActiveMenu('promo/optit')
|
10 |
+
->_title($this->__('Opt It'))
|
11 |
+
->_title($this->__('Message'));
|
12 |
+
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function indexAction()
|
17 |
+
{
|
18 |
+
$this->_initAction();
|
19 |
+
|
20 |
+
try {
|
21 |
+
} catch (Mage_Core_Exception $e) {
|
22 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
23 |
+
$this->_initLayoutMessages('adminhtml/session');
|
24 |
+
}
|
25 |
+
$this->renderLayout();
|
26 |
+
}
|
27 |
+
|
28 |
+
public function smsAction()
|
29 |
+
{
|
30 |
+
$this->_initAction();
|
31 |
+
$this->_title('SMS');
|
32 |
+
$params = $this->getRequest()->getParams();
|
33 |
+
|
34 |
+
try {
|
35 |
+
$data = Mage::getSingleton('optit/system_config_source_message_keyword')->toOptionArray();
|
36 |
+
$form = $this->getLayout()->getBlock('optit_send_sms')->getChild('form');
|
37 |
+
if ($form) {
|
38 |
+
$form->setKeywords($data);
|
39 |
+
Mage::register('params', $params);
|
40 |
+
}
|
41 |
+
} catch (Mage_Core_Exception $e) {
|
42 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
43 |
+
$this->_initLayoutMessages('adminhtml/session');
|
44 |
+
}
|
45 |
+
|
46 |
+
$this->renderLayout();
|
47 |
+
}
|
48 |
+
|
49 |
+
public function mmsAction()
|
50 |
+
{
|
51 |
+
$this->_initAction();
|
52 |
+
$this->_title('MMS');
|
53 |
+
$params = $this->getRequest()->getParams();
|
54 |
+
|
55 |
+
try {
|
56 |
+
$data = Mage::getSingleton('optit/system_config_source_message_keyword')->toOptionArray();
|
57 |
+
$form = $this->getLayout()->getBlock('optit_send_mms')->getChild('form');
|
58 |
+
if ($form) {
|
59 |
+
$form->setKeywords($data);
|
60 |
+
Mage::register('params', $params);
|
61 |
+
}
|
62 |
+
} catch (Mage_Core_Exception $e) {
|
63 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
64 |
+
$this->_initLayoutMessages('adminhtml/session');
|
65 |
+
}
|
66 |
+
|
67 |
+
$this->renderLayout();
|
68 |
+
}
|
69 |
+
|
70 |
+
public function sendSmsAction()
|
71 |
+
{
|
72 |
+
$request = $this->getRequest();
|
73 |
+
$type = $request->getPost('type');
|
74 |
+
$post = $request->getPost();
|
75 |
+
|
76 |
+
if (!$request->isPost()) {
|
77 |
+
$this->getResponse()->setRedirect($this->getUrl('*/*/', array('id' => $post['id'], 'type' => $type)));
|
78 |
+
}
|
79 |
+
|
80 |
+
if ($request->getParam('bulk')) {
|
81 |
+
$this->_forward('bulk');
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
+
$message = Mage::getModel('optit/message');
|
86 |
+
|
87 |
+
try {
|
88 |
+
$params = $this->_prepareForSend($post);
|
89 |
+
if ($type == Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_INTEREST) {
|
90 |
+
$message->sendMessageToInterest($params);
|
91 |
+
} elseif ($type == Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_MEMBER) {
|
92 |
+
$message->sendMessageToMember($params);
|
93 |
+
} else {
|
94 |
+
$message->sendMessageToKeyword($params);
|
95 |
+
}
|
96 |
+
$this->_getSession()->addSuccess($this->__('Message sent.'));
|
97 |
+
} catch (Mage_Core_Exception $e) {
|
98 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
99 |
+
$this->_getSession()->setData('form_data', $post);
|
100 |
+
}
|
101 |
+
|
102 |
+
$this->_redirectReferer();
|
103 |
+
}
|
104 |
+
|
105 |
+
public function sendMmsAction()
|
106 |
+
{
|
107 |
+
$request = $this->getRequest();
|
108 |
+
$type = $request->getPost('type');
|
109 |
+
$params = $this->_prepareForSend($request->getPost());
|
110 |
+
|
111 |
+
if (!$request->isPost()) {
|
112 |
+
$this->getResponse()->setRedirect($this->getUrl('*/*/', array('id' => $params['id'], 'type' => $type)));
|
113 |
+
}
|
114 |
+
|
115 |
+
if ($request->getParam('bulk')) {
|
116 |
+
$this->_forward('bulk');
|
117 |
+
return;
|
118 |
+
}
|
119 |
+
|
120 |
+
$destinationFolder = Mage::getBaseDir('media') . DS . 'optit';
|
121 |
+
|
122 |
+
$message = Mage::getModel('optit/message');
|
123 |
+
|
124 |
+
try {
|
125 |
+
$result = $this->_upload('content_url', $destinationFolder);
|
126 |
+
$params['content_url'] = Mage::getBaseUrl('media') .
|
127 |
+
Inchoo_Optit_Model_Message::MMS_MEDIA_DIRECTORY . $result['file'];
|
128 |
+
$message->sendMmsToKeyword($params);
|
129 |
+
$this->_getSession()->addSuccess($this->__('Message sent.'));
|
130 |
+
} catch (Mage_Core_Exception $e) {
|
131 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
132 |
+
$this->_getSession()->setData('form_data', $params);
|
133 |
+
} catch (Exception $e) {
|
134 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
135 |
+
$this->_getSession()->setData('form_data', $params);
|
136 |
+
}
|
137 |
+
|
138 |
+
$this->_redirectReferer();
|
139 |
+
}
|
140 |
+
|
141 |
+
public function bulkAction()
|
142 |
+
{
|
143 |
+
$request = $this->getRequest();
|
144 |
+
$params = $this->_prepareForSave($request->getPost());
|
145 |
+
$destinationFolder = Mage::getBaseDir('media') . DS . Inchoo_Optit_Model_Message::MMS_MEDIA_DIRECTORY;
|
146 |
+
|
147 |
+
$message = Mage::getModel('optit/message');
|
148 |
+
|
149 |
+
try {
|
150 |
+
if ($params['message_type'] != Inchoo_Optit_Model_Message::MESSAGE_TYPE_SMS) {
|
151 |
+
$result = $this->_upload('content_url', $destinationFolder);
|
152 |
+
$params['content_url'] = Mage::getBaseUrl('media') .
|
153 |
+
Inchoo_Optit_Model_Message::MMS_MEDIA_DIRECTORY . $result['file'];
|
154 |
+
}
|
155 |
+
$message->setData($params);
|
156 |
+
$message->save();
|
157 |
+
$this->_getSession()->addSuccess($this->__('Message added to bulk list.'));
|
158 |
+
} catch (Mage_Core_Exception $e) {
|
159 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
160 |
+
$this->_getSession()->setData('form_data', $params);
|
161 |
+
} catch (Exception $e) {
|
162 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
163 |
+
$this->_getSession()->setData('form_data', $params);
|
164 |
+
}
|
165 |
+
|
166 |
+
$this->_redirectReferer();
|
167 |
+
}
|
168 |
+
|
169 |
+
protected function _prepareForSend($params)
|
170 |
+
{
|
171 |
+
if ($params['type'] == Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_INTEREST) {
|
172 |
+
$params['interest_id'] = $params['id'];
|
173 |
+
} else {
|
174 |
+
$params['keyword_id'] = $params['id'];
|
175 |
+
}
|
176 |
+
|
177 |
+
unset($params['form_key'], $params['id'], $params['type'],$params['message_type']);
|
178 |
+
|
179 |
+
return $params;
|
180 |
+
}
|
181 |
+
|
182 |
+
protected function _prepareForSave($params)
|
183 |
+
{
|
184 |
+
$params['entity_id'] = $params['id'];
|
185 |
+
$params['entity_type_code'] = $params['type'];
|
186 |
+
|
187 |
+
return $params;
|
188 |
+
}
|
189 |
+
|
190 |
+
protected function _upload($fieldId, $destinationFolder)
|
191 |
+
{
|
192 |
+
$uploader = new Mage_Core_Model_File_Uploader($fieldId);
|
193 |
+
$uploader->setAllowedExtensions(
|
194 |
+
array('jpg', 'jpeg', 'png', 'gif', 'vnd', 'wap', 'wbpm', 'bpm', 'amr', 'x-wav', 'aac', 'qcp', '3gpp', '3gpp2')
|
195 |
+
);
|
196 |
+
$uploader->addValidateCallback('optit_send_mms',
|
197 |
+
Mage::helper('catalog/image'), 'validateUploadFile');
|
198 |
+
$uploader->setAllowRenameFiles(true);
|
199 |
+
$uploader->setFilesDispersion(true);
|
200 |
+
$result = $uploader->save($destinationFolder);
|
201 |
+
|
202 |
+
return $result;
|
203 |
+
}
|
204 |
+
}
|
app/code/local/Inchoo/Optit/controllers/Adminhtml/Optit/SubscriptionController.php
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Inchoo_Optit_Adminhtml_Optit_SubscriptionController extends Mage_Adminhtml_Controller_Action
|
5 |
+
{
|
6 |
+
protected function _initAction()
|
7 |
+
{
|
8 |
+
$this->loadLayout()
|
9 |
+
->_setActiveMenu('promo/optit')
|
10 |
+
->_title($this->__('Opt It'))
|
11 |
+
->_title($this->__('Keywords'))
|
12 |
+
->_title($this->__('Subscriptions'));
|
13 |
+
|
14 |
+
return $this;
|
15 |
+
}
|
16 |
+
|
17 |
+
public function indexAction()
|
18 |
+
{
|
19 |
+
$request = $this->getRequest();
|
20 |
+
|
21 |
+
if ($request->getQuery('ajax')) {
|
22 |
+
$this->_forward('grid');
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
|
26 |
+
$keywordId = $request->getParam('keyword_id');
|
27 |
+
if (!$keywordId) {
|
28 |
+
$this->_redirect('*/optit_keyword');
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
|
32 |
+
Mage::register('filter_id', $keywordId);
|
33 |
+
Mage::register('filter_type', Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_KEYWORD);
|
34 |
+
$this->_initAction();
|
35 |
+
$this->renderLayout();
|
36 |
+
}
|
37 |
+
|
38 |
+
public function unsubscribeAction()
|
39 |
+
{
|
40 |
+
$request = $this->getRequest();
|
41 |
+
$filterId = $request->getParam('filter_id');
|
42 |
+
$phone = $request->getParam('phone');
|
43 |
+
|
44 |
+
$model = Mage::getModel('optit/subscription');
|
45 |
+
|
46 |
+
try {
|
47 |
+
$model->unsubscribeMemberFromKeyword($filterId, $phone);
|
48 |
+
} catch (Mage_Core_Exception $e) {
|
49 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
50 |
+
}
|
51 |
+
$this->_redirect('*/*/', array(
|
52 |
+
'type_name' => $request->getParam('type_name')
|
53 |
+
));
|
54 |
+
}
|
55 |
+
|
56 |
+
public function gridAction()
|
57 |
+
{
|
58 |
+
$this->loadLayout();
|
59 |
+
$this->renderLayout();
|
60 |
+
}
|
61 |
+
|
62 |
+
public function newAction()
|
63 |
+
{
|
64 |
+
$request = $this->getRequest();
|
65 |
+
$keywordId = $request->getParam('keyword_id');
|
66 |
+
|
67 |
+
if (!$keywordId) {
|
68 |
+
$this->_redirect('*/optit_keyword');
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
Mage::register('filter_id', $keywordId);
|
73 |
+
Mage::register('filter_type', Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_KEYWORD);
|
74 |
+
$this->_initAction();
|
75 |
+
$this->_title($this->__('New Subscription'));
|
76 |
+
$this->_addBreadcrumb($this->__('New Subscription'), $this->__('New Subscription'))
|
77 |
+
->_addContent($this->getLayout()->createBlock('optit/adminhtml_subscription_edit'))
|
78 |
+
->renderLayout();
|
79 |
+
}
|
80 |
+
|
81 |
+
public function saveAction()
|
82 |
+
{
|
83 |
+
$request = $this->getRequest();
|
84 |
+
$params = $request->getPost();
|
85 |
+
$keywordId = $params['keyword_id'];
|
86 |
+
|
87 |
+
$subscription = Mage::getModel('optit/subscription');
|
88 |
+
|
89 |
+
try {
|
90 |
+
$this->_validateRequired($params);
|
91 |
+
$this->_checkInterests($params);
|
92 |
+
$params = $this->_formatBirthtDate($params);
|
93 |
+
$subscription->subscribeMemberToKeyword($keywordId, $params);
|
94 |
+
$this->_getSession()->addSuccess($this->__('Subscription saved.'));
|
95 |
+
$this->_getSession()->addNotice($this->__('If single opt-in is enabled, subscriber will be visible.'));
|
96 |
+
} catch (Mage_Core_Exception $e) {
|
97 |
+
$this->_getSession()->addError(nl2br($e->getMessage()));
|
98 |
+
$this->_getSession()->addData('form_data',
|
99 |
+
$this->getRequest()->getParams());
|
100 |
+
}
|
101 |
+
$this->_redirect('*/*/', array(
|
102 |
+
'keyword_id' => $request->getParam('keyword_id'),
|
103 |
+
'keyword_name' => $request->getParam('keyword_name'),
|
104 |
+
'type_name' => $request->getParam('type_name'),
|
105 |
+
));
|
106 |
+
}
|
107 |
+
|
108 |
+
protected function _validateRequired($params)
|
109 |
+
{
|
110 |
+
if ($params['subscription'] === 'member_id' && !Zend_Validate::is($params['member_id'], 'NotEmpty')) {
|
111 |
+
Mage::throwException('Required parameters not set.');
|
112 |
+
}
|
113 |
+
if ($params['subscription'] === 'phone' && !Zend_Validate::is($params['phone'], 'NotEmpty')) {
|
114 |
+
Mage::throwException('Required parameters not set.');
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
public function interestAction()
|
119 |
+
{
|
120 |
+
$request = $this->getRequest();
|
121 |
+
$interestId = $request->getParam('interest_id');
|
122 |
+
|
123 |
+
if (!$interestId) {
|
124 |
+
$this->_redirect('*/optit_keyword');
|
125 |
+
return;
|
126 |
+
}
|
127 |
+
|
128 |
+
Mage::register('filter_id', $interestId);
|
129 |
+
Mage::register('filter_type', Inchoo_Optit_Model_Subscription::SUBSCRIPTION_TYPE_INTEREST);
|
130 |
+
$this->_initAction();
|
131 |
+
$this->renderLayout();
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
protected function _checkInterests($params)
|
136 |
+
{
|
137 |
+
if (isset($params['interest_id'])) {
|
138 |
+
$params['interest_id'] = implode(',', $params['interest_id']);
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
protected function _formatBirthtDate($params)
|
143 |
+
{
|
144 |
+
if (isset($params['birth_date'])) {
|
145 |
+
$dateTimestamp = Mage::getModel('core/date')->timestamp(strtotime($params['birth_date']));
|
146 |
+
$params['birth_date'] = date('Ymd', $dateTimestamp);
|
147 |
+
}
|
148 |
+
|
149 |
+
return $params;
|
150 |
+
}
|
151 |
+
}
|
app/code/local/Inchoo/Optit/etc/adminhtml.xml
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<promo>
|
5 |
+
<children>
|
6 |
+
<optit>
|
7 |
+
<title>Opt It</title>
|
8 |
+
<sort_order>100</sort_order>
|
9 |
+
<children>
|
10 |
+
<optit_bulk>
|
11 |
+
<title>Bulk Messaging</title>
|
12 |
+
<sort_order>10</sort_order>
|
13 |
+
<children>
|
14 |
+
<optit_bulk_sms>
|
15 |
+
<title>SMS</title>
|
16 |
+
<sort_order>10</sort_order>
|
17 |
+
<action>adminhtml/optit_bulk/sms</action>
|
18 |
+
</optit_bulk_sms>
|
19 |
+
<optit_bulk_mms>
|
20 |
+
<title>MMS</title>
|
21 |
+
<sort_order>20</sort_order>
|
22 |
+
<action>adminhtml/optit_bulk/mms</action>
|
23 |
+
</optit_bulk_mms>
|
24 |
+
</children>
|
25 |
+
</optit_bulk>
|
26 |
+
<optit_keywords>
|
27 |
+
<title>Keywords</title>
|
28 |
+
<sort_order>20</sort_order>
|
29 |
+
<action>adminhtml/optit_keyword</action>
|
30 |
+
</optit_keywords>
|
31 |
+
<optit_members>
|
32 |
+
<title>Members</title>
|
33 |
+
<sort_order>30</sort_order>
|
34 |
+
<action>adminhtml/optit_member</action>
|
35 |
+
</optit_members>
|
36 |
+
<optit_send>
|
37 |
+
<title>Send Message</title>
|
38 |
+
<sort_order>40</sort_order>
|
39 |
+
<children>
|
40 |
+
<optit_send_sms>
|
41 |
+
<title>SMS</title>
|
42 |
+
<sort_order>10</sort_order>
|
43 |
+
<action>adminhtml/optit_message/sms</action>
|
44 |
+
</optit_send_sms>
|
45 |
+
<optit_send_mms>
|
46 |
+
<title>MMS</title>
|
47 |
+
<sort_order>20</sort_order>
|
48 |
+
<action>adminhtml/optit_message/mms</action>
|
49 |
+
</optit_send_mms>
|
50 |
+
</children>
|
51 |
+
</optit_send>
|
52 |
+
<optit_config>
|
53 |
+
<title>Settings</title>
|
54 |
+
<sort_order>50</sort_order>
|
55 |
+
<action>adminhtml/system_config/edit/section/promo</action>
|
56 |
+
</optit_config>
|
57 |
+
</children>
|
58 |
+
</optit>
|
59 |
+
</children>
|
60 |
+
</promo>
|
61 |
+
</menu>
|
62 |
+
<acl>
|
63 |
+
<resources>
|
64 |
+
<admin>
|
65 |
+
<children>
|
66 |
+
<promo>
|
67 |
+
<children>
|
68 |
+
<optit translate="title">
|
69 |
+
<title>Opt It</title>
|
70 |
+
<sort_order>10</sort_order>
|
71 |
+
<children>
|
72 |
+
<optit_keywords translate="title">
|
73 |
+
<title>Opt It Keywords</title>
|
74 |
+
<sort_order>0</sort_order>
|
75 |
+
</optit_keywords>
|
76 |
+
</children>
|
77 |
+
</optit>
|
78 |
+
</children>
|
79 |
+
</promo>
|
80 |
+
<system>
|
81 |
+
<children>
|
82 |
+
<config>
|
83 |
+
<children>
|
84 |
+
<optit>
|
85 |
+
<title>Opt It</title>
|
86 |
+
<sort_order>100</sort_order>
|
87 |
+
</optit>
|
88 |
+
</children>
|
89 |
+
</config>
|
90 |
+
</children>
|
91 |
+
</system>
|
92 |
+
</children>
|
93 |
+
</admin>
|
94 |
+
</resources>
|
95 |
+
</acl>
|
96 |
+
</config>
|
app/code/local/Inchoo/Optit/etc/config.xml
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Inchoo_Optit>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Inchoo_Optit>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<blocks>
|
10 |
+
<optit>
|
11 |
+
<class>Inchoo_Optit_Block</class>
|
12 |
+
</optit>
|
13 |
+
</blocks>
|
14 |
+
<helpers>
|
15 |
+
<optit>
|
16 |
+
<class>Inchoo_Optit_Helper</class>
|
17 |
+
</optit>
|
18 |
+
</helpers>
|
19 |
+
<models>
|
20 |
+
<optit>
|
21 |
+
<class>Inchoo_Optit_Model</class>
|
22 |
+
<resourceModel>optit_resource</resourceModel>
|
23 |
+
</optit>
|
24 |
+
<optit_resource>
|
25 |
+
<class>Inchoo_Optit_Model_Resource</class>
|
26 |
+
<entities>
|
27 |
+
<bulk_keyword_messages>
|
28 |
+
<table>optit_bulk_messages</table>
|
29 |
+
</bulk_keyword_messages>
|
30 |
+
<bulk_message_phones>
|
31 |
+
<table>optit_bulk_phones</table>
|
32 |
+
</bulk_message_phones>
|
33 |
+
</entities>
|
34 |
+
</optit_resource>
|
35 |
+
</models>
|
36 |
+
<resources>
|
37 |
+
<optit_setup>
|
38 |
+
<setup>
|
39 |
+
<module>Inchoo_Optit</module>
|
40 |
+
</setup>
|
41 |
+
</optit_setup>
|
42 |
+
</resources>
|
43 |
+
</global>
|
44 |
+
<admin>
|
45 |
+
<routers>
|
46 |
+
<adminhtml>
|
47 |
+
<args>
|
48 |
+
<modules>
|
49 |
+
<optit before="Mage_Adminhtml">Inchoo_Optit_Adminhtml</optit>
|
50 |
+
</modules>
|
51 |
+
</args>
|
52 |
+
</adminhtml>
|
53 |
+
</routers>
|
54 |
+
</admin>
|
55 |
+
<adminhtml>
|
56 |
+
<layout>
|
57 |
+
<updates>
|
58 |
+
<optit>
|
59 |
+
<file>optit.xml</file>
|
60 |
+
</optit>
|
61 |
+
</updates>
|
62 |
+
</layout>
|
63 |
+
</adminhtml>
|
64 |
+
<default>
|
65 |
+
<promo>
|
66 |
+
<optit>
|
67 |
+
<optit_password backend_model="adminhtml/system_config_backend_encrypted" />
|
68 |
+
</optit>
|
69 |
+
</promo>
|
70 |
+
</default>
|
71 |
+
</config>
|
app/code/local/Inchoo/Optit/etc/system.xml
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<promo>
|
5 |
+
<groups>
|
6 |
+
<optit translate="label" module="optit">
|
7 |
+
<label>Opt It</label>
|
8 |
+
<show_in_default>1</show_in_default>
|
9 |
+
<sort_order>10</sort_order>
|
10 |
+
<fields>
|
11 |
+
<optit_username translate="label comment">
|
12 |
+
<label>Username</label>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>10</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>0</show_in_store>
|
18 |
+
<comment>Opt It Username</comment>
|
19 |
+
</optit_username>
|
20 |
+
<optit_password translate="label comment">
|
21 |
+
<label>Password</label>
|
22 |
+
<frontend_type>obscure</frontend_type>
|
23 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
24 |
+
<sort_order>20</sort_order>
|
25 |
+
<show_in_default>1</show_in_default>
|
26 |
+
<show_in_website>1</show_in_website>
|
27 |
+
<show_in_store>0</show_in_store>
|
28 |
+
<comment>Opt It Password</comment>
|
29 |
+
</optit_password>
|
30 |
+
</fields>
|
31 |
+
</optit>
|
32 |
+
</groups>
|
33 |
+
</promo>
|
34 |
+
</sections>
|
35 |
+
</config>
|
app/code/local/Inchoo/Optit/sql/optit_setup/install-0.1.0.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/** @var $installer Mage_Catalog_Model_Resource_Setup */
|
4 |
+
|
5 |
+
$installer = $this;
|
6 |
+
$connection = $this->getConnection();
|
7 |
+
|
8 |
+
$installer->startSetup();
|
9 |
+
|
10 |
+
/** optit_bulk_messages */
|
11 |
+
if (!$connection->isTableExists($installer->getTable('optit/bulk_keyword_messages'))) {
|
12 |
+
$table = $this->getConnection()
|
13 |
+
->newTable($this->getTable('optit/bulk_keyword_messages'))
|
14 |
+
->addColumn(
|
15 |
+
'message_id',
|
16 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
17 |
+
null,
|
18 |
+
array(
|
19 |
+
'primary' => true,
|
20 |
+
'identity' => true,
|
21 |
+
'unsigned' => true,
|
22 |
+
'nullable' => false,
|
23 |
+
), 'Id')
|
24 |
+
->addColumn(
|
25 |
+
'message_type',
|
26 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
27 |
+
null,
|
28 |
+
array(
|
29 |
+
'nullable' => false,
|
30 |
+
), 'Message Type')
|
31 |
+
->addColumn(
|
32 |
+
'entity_id',
|
33 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
34 |
+
null,
|
35 |
+
array(
|
36 |
+
'unsigned' => true,
|
37 |
+
'nullable' => false,
|
38 |
+
), 'Entity Id')
|
39 |
+
->addColumn(
|
40 |
+
'entity_type_code',
|
41 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
42 |
+
null,
|
43 |
+
array(
|
44 |
+
'nullable' => false,
|
45 |
+
), 'Entity Type Code')
|
46 |
+
->addColumn(
|
47 |
+
'title',
|
48 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
49 |
+
null,
|
50 |
+
array(
|
51 |
+
'nullable' => false,
|
52 |
+
), 'Title')
|
53 |
+
->addColumn(
|
54 |
+
'message',
|
55 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
56 |
+
null,
|
57 |
+
array(
|
58 |
+
'nullable' => false,
|
59 |
+
), 'Message')
|
60 |
+
->addColumn(
|
61 |
+
'content_url',
|
62 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
63 |
+
null,
|
64 |
+
array(
|
65 |
+
'nullable' => true,
|
66 |
+
), 'Content Url')
|
67 |
+
->setComment('Bulk Messages');
|
68 |
+
|
69 |
+
$this->getConnection()->createTable($table);
|
70 |
+
}
|
71 |
+
|
72 |
+
/** optit_bulk_phones */
|
73 |
+
if (!$connection->isTableExists($installer->getTable('optit/bulk_message_phones'))) {
|
74 |
+
$table = $this->getConnection()
|
75 |
+
->newTable($this->getTable('optit/bulk_message_phones'))
|
76 |
+
->addColumn(
|
77 |
+
'message_id',
|
78 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
79 |
+
null,
|
80 |
+
array(
|
81 |
+
'unsigned' => true,
|
82 |
+
'nullable' => false,
|
83 |
+
), 'ID')
|
84 |
+
->addColumn(
|
85 |
+
'phone_number',
|
86 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
87 |
+
25,
|
88 |
+
array(
|
89 |
+
'nullable' => false,
|
90 |
+
), 'Phone Number')
|
91 |
+
->addIndex(
|
92 |
+
$installer->getIdxName('optit/bulk_message_phones', array('message_id', 'phone_number'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
|
93 |
+
array('message_id', 'phone_number'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
|
94 |
+
->addForeignKey(
|
95 |
+
$this->getFkName('optit/bulk_message_phones', 'message_id', 'optit/bulk_keyword_messages', 'message_id'),
|
96 |
+
'message_id',
|
97 |
+
$this->getTable('optit/bulk_keyword_messages'), 'message_id',
|
98 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
99 |
+
->setComment('Bulk Message Phones');
|
100 |
+
|
101 |
+
$this->getConnection()->createTable($table);
|
102 |
+
}
|
103 |
+
|
104 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/optit.xml
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2 |
+
<layout>
|
3 |
+
<adminhtml_optit_keyword_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="optit/adminhtml_keyword" name="optit_keyword"/>
|
6 |
+
</reference>
|
7 |
+
<reference name="adminhtml_keyword.grid">
|
8 |
+
<action method="setTemplate">
|
9 |
+
<template>optit/grid.phtml</template>
|
10 |
+
</action>
|
11 |
+
</reference>
|
12 |
+
</adminhtml_optit_keyword_index>
|
13 |
+
|
14 |
+
<adminhtml_optit_keyword_grid>
|
15 |
+
<block type="core/text_list" name="root" output="toHtml">
|
16 |
+
<block type="optit/adminhtml_keyword_grid" name="optit_keyword_grid"/>
|
17 |
+
</block>
|
18 |
+
</adminhtml_optit_keyword_grid>
|
19 |
+
|
20 |
+
<adminhtml_optit_subscription_index>
|
21 |
+
<reference name="content">
|
22 |
+
<block type="optit/adminhtml_subscription" name="optit_subscription"/>
|
23 |
+
</reference>
|
24 |
+
<reference name="adminhtml_subscription.grid">
|
25 |
+
<action method="setTemplate">
|
26 |
+
<template>optit/grid.phtml</template>
|
27 |
+
</action>
|
28 |
+
</reference>
|
29 |
+
</adminhtml_optit_subscription_index>
|
30 |
+
|
31 |
+
<adminhtml_optit_subscription_grid>
|
32 |
+
<block type="core/text_list" name="root" output="toHtml">
|
33 |
+
<block type="optit/adminhtml_subscription_grid" name="optit_subscription_grid"/>
|
34 |
+
</block>
|
35 |
+
</adminhtml_optit_subscription_grid>
|
36 |
+
|
37 |
+
<adminhtml_optit_subscription_interest>
|
38 |
+
<reference name="content">
|
39 |
+
<block type="optit/adminhtml_subscription" name="optit_subscription"/>
|
40 |
+
</reference>
|
41 |
+
<reference name="adminhtml_subscription.grid">
|
42 |
+
<action method="setTemplate">
|
43 |
+
<template>optit/grid.phtml</template>
|
44 |
+
</action>
|
45 |
+
</reference>
|
46 |
+
</adminhtml_optit_subscription_interest>
|
47 |
+
|
48 |
+
<adminhtml_optit_interest_index>
|
49 |
+
<reference name="content">
|
50 |
+
<block type="optit/adminhtml_interest" name="optit_interest"/>
|
51 |
+
</reference>
|
52 |
+
<reference name="adminhtml_interest.grid">
|
53 |
+
<action method="setTemplate">
|
54 |
+
<template>optit/grid.phtml</template>
|
55 |
+
</action>
|
56 |
+
</reference>
|
57 |
+
</adminhtml_optit_interest_index>
|
58 |
+
|
59 |
+
<adminhtml_optit_interest_grid>
|
60 |
+
<block type="core/text_list" name="root" output="toHtml">
|
61 |
+
<block type="optit/adminhtml_interest_grid" name="optit_interest_grid"/>
|
62 |
+
</block>
|
63 |
+
</adminhtml_optit_interest_grid>
|
64 |
+
|
65 |
+
<adminhtml_optit_member_index>
|
66 |
+
<reference name="content">
|
67 |
+
<block type="optit/adminhtml_member" name="optit_member"/>
|
68 |
+
</reference>
|
69 |
+
<reference name="adminhtml_member.grid">
|
70 |
+
<action method="setTemplate">
|
71 |
+
<template>optit/grid.phtml</template>
|
72 |
+
</action>
|
73 |
+
</reference>
|
74 |
+
</adminhtml_optit_member_index>
|
75 |
+
|
76 |
+
<adminhtml_optit_message_sms>
|
77 |
+
<reference name="content">
|
78 |
+
<block type="optit/adminhtml_message_sms_edit" name="optit_send_sms" />
|
79 |
+
</reference>
|
80 |
+
</adminhtml_optit_message_sms>
|
81 |
+
|
82 |
+
<adminhtml_optit_message_mms>
|
83 |
+
<reference name="content">
|
84 |
+
<block type="optit/adminhtml_message_mms_edit" name="optit_send_mms" />
|
85 |
+
</reference>
|
86 |
+
</adminhtml_optit_message_mms>
|
87 |
+
|
88 |
+
<adminhtml_optit_bulk_sms>
|
89 |
+
<reference name="content">
|
90 |
+
<block type="optit/adminhtml_message_sms" name="optit_bulk_sms" />
|
91 |
+
</reference>
|
92 |
+
</adminhtml_optit_bulk_sms>
|
93 |
+
|
94 |
+
<adminhtml_optit_bulk_smsgrid>
|
95 |
+
<block type="core/text_list" name="root" output="toHtml">
|
96 |
+
<block type="optit/adminhtml_message_sms_grid" name="optit_message_sms_grid"/>
|
97 |
+
</block>
|
98 |
+
</adminhtml_optit_bulk_smsgrid>
|
99 |
+
|
100 |
+
<adminhtml_optit_bulk_mms>
|
101 |
+
<reference name="content">
|
102 |
+
<block type="optit/adminhtml_message_mms" name="optit_bulk_mms" />
|
103 |
+
</reference>
|
104 |
+
</adminhtml_optit_bulk_mms>
|
105 |
+
|
106 |
+
<adminhtml_optit_bulk_mmsgrid>
|
107 |
+
<block type="core/text_list" name="root" output="toHtml">
|
108 |
+
<block type="optit/adminhtml_message_mms_grid" name="optit_message_mms_grid"/>
|
109 |
+
</block>
|
110 |
+
</adminhtml_optit_bulk_mmsgrid>
|
111 |
+
</layout>
|
app/design/adminhtml/default/default/template/optit/grid.phtml
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
/**
|
29 |
+
* Template for Mage_Adminhtml_Block_Widget_Grid
|
30 |
+
*
|
31 |
+
* getId()
|
32 |
+
* getCollection()
|
33 |
+
* getColumns()
|
34 |
+
* getPagerVisibility()
|
35 |
+
* getVarNamePage()
|
36 |
+
*/
|
37 |
+
$numColumns = sizeof($this->getColumns());
|
38 |
+
?>
|
39 |
+
<?php if($this->getCollection()): ?>
|
40 |
+
<?php if($this->canDisplayContainer()): ?>
|
41 |
+
<?php if($this->getGridHeader()): ?>
|
42 |
+
<div class="content-header">
|
43 |
+
<table cellspacing="0">
|
44 |
+
<tr>
|
45 |
+
<td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
|
46 |
+
</tr>
|
47 |
+
</table>
|
48 |
+
</div>
|
49 |
+
<?php endif ?>
|
50 |
+
|
51 |
+
<div id="<?php echo $this->getId() ?>">
|
52 |
+
<?php else: ?>
|
53 |
+
<?php echo $this->getMessagesBlock()->toHtml() ?>
|
54 |
+
<?php endif; ?>
|
55 |
+
<?php if($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
|
56 |
+
<table cellspacing="0" class="actions">
|
57 |
+
<tr>
|
58 |
+
<?php if($this->getPagerVisibility()): ?>
|
59 |
+
<td class="pager">
|
60 |
+
<?php echo $this->__('Page') ?>
|
61 |
+
|
62 |
+
<?php $_curPage = $this->getCollection()->getCurPage() ?>
|
63 |
+
<?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
|
64 |
+
<?php if($_curPage>1): ?>
|
65 |
+
<a href="#" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Previous page')) ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage-1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Go to Previous page')) ?>" class="arrow"/></a>
|
66 |
+
<?php else: ?>
|
67 |
+
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Go to Previous page')) ?>" class="arrow"/>
|
68 |
+
<?php endif; ?>
|
69 |
+
|
70 |
+
<input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
|
71 |
+
|
72 |
+
<?php if($_curPage < $_lastPage): ?>
|
73 |
+
<a href="#" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Next page')) ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage+1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Go to Next page')) ?>" class="arrow"/></a>
|
74 |
+
<?php else: ?>
|
75 |
+
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Go to Next page')) ?>" class="arrow"/>
|
76 |
+
<?php endif; ?>
|
77 |
+
|
78 |
+
<?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
|
79 |
+
<?php if($this->getRssLists()): ?>
|
80 |
+
<?php foreach ($this->getRssLists() as $_rss): ?>
|
81 |
+
<span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
|
82 |
+
<?php endforeach ?>
|
83 |
+
<?php endif; ?>
|
84 |
+
</td>
|
85 |
+
<?php endif ?>
|
86 |
+
<?php if($this->getExportTypes()): ?>
|
87 |
+
<td class="export a-right">
|
88 |
+
<img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/> <?php echo $this->__('Export to:') ?>
|
89 |
+
<select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
|
90 |
+
<?php foreach ($this->getExportTypes() as $_type): ?>
|
91 |
+
<option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
|
92 |
+
<?php endforeach; ?>
|
93 |
+
</select>
|
94 |
+
<?php echo $this->getExportButtonHtml() ?>
|
95 |
+
</td>
|
96 |
+
<?php endif; ?>
|
97 |
+
<td class="filter-actions a-right">
|
98 |
+
<?php echo $this->getMainButtonsHtml() ?>
|
99 |
+
</td>
|
100 |
+
</tr>
|
101 |
+
</table>
|
102 |
+
<?php endif; ?>
|
103 |
+
<?php if($this->getMassactionBlock()->isAvailable()): ?>
|
104 |
+
<?php echo $this->getMassactionBlockHtml() ?>
|
105 |
+
<?php endif ?>
|
106 |
+
<div class="grid">
|
107 |
+
<div class="hor-scroll">
|
108 |
+
<table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
|
109 |
+
<?php foreach ($this->getColumns() as $_column): ?>
|
110 |
+
<col <?php echo $_column->getHtmlProperty() ?> />
|
111 |
+
<?php endforeach; ?>
|
112 |
+
<?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
|
113 |
+
<thead>
|
114 |
+
<?php if ($this->getHeadersVisibility()): ?>
|
115 |
+
<tr class="headings">
|
116 |
+
<?php foreach ($this->getColumns() as $_column): ?>
|
117 |
+
<th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
|
118 |
+
<?php endforeach; ?>
|
119 |
+
</tr>
|
120 |
+
<?php endif; ?>
|
121 |
+
<?php if ($this->getFilterVisibility()): ?>
|
122 |
+
<tr class="filter">
|
123 |
+
<?php $i=0;foreach ($this->getColumns() as $_column): ?>
|
124 |
+
<th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
|
125 |
+
<?php endforeach; ?>
|
126 |
+
</tr>
|
127 |
+
<?php endif ?>
|
128 |
+
</thead>
|
129 |
+
<?php endif; ?>
|
130 |
+
<?php if ($this->getCountTotals()): ?>
|
131 |
+
<tfoot>
|
132 |
+
<tr class="totals">
|
133 |
+
<?php foreach ($this->getColumns() as $_column): ?>
|
134 |
+
<th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?> </th>
|
135 |
+
<?php endforeach; ?>
|
136 |
+
</tr>
|
137 |
+
</tfoot>
|
138 |
+
<?php endif; ?>
|
139 |
+
|
140 |
+
<tbody>
|
141 |
+
<?php if (($this->getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?>
|
142 |
+
<?php foreach ($this->getCollection() as $_index=>$_item): ?>
|
143 |
+
<tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)):?> class="<?php echo $_class; ?>"<?php endif;?> >
|
144 |
+
<?php $i=0;foreach ($this->getColumns() as $_column): ?>
|
145 |
+
|
146 |
+
<?php if ($this->shouldRenderCell($_item, $_column)):?>
|
147 |
+
<?php $_rowspan = $this->getRowspan($_item, $_column);?>
|
148 |
+
<td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns?'last':'' ?>">
|
149 |
+
<?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : ' ') ?>
|
150 |
+
</td>
|
151 |
+
<?php if ($this->shouldRenderEmptyCell($_item, $_column)):?>
|
152 |
+
<td colspan="<?php echo $this->getEmptyCellColspan($_item)?>" class="last"><?php echo $this->getEmptyCellLabel()?></td>
|
153 |
+
<?php endif;?>
|
154 |
+
<?php endif;?>
|
155 |
+
|
156 |
+
<?php endforeach; ?>
|
157 |
+
</tr>
|
158 |
+
<?php if ($_multipleRows = $this->getMultipleRows($_item)):?>
|
159 |
+
<?php foreach ($_multipleRows as $_i):?>
|
160 |
+
<tr>
|
161 |
+
<?php $i=0;foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
|
162 |
+
<td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns-1?'last':'' ?>">
|
163 |
+
<?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : ' ') ?>
|
164 |
+
</td>
|
165 |
+
<?php endforeach; ?>
|
166 |
+
</tr>
|
167 |
+
<?php endforeach;?>
|
168 |
+
<?php endif;?>
|
169 |
+
|
170 |
+
<?php if ($this->shouldRenderSubTotal($_item)): ?>
|
171 |
+
<tr class="subtotals">
|
172 |
+
<?php $i = 0; foreach ($this->getSubTotalColumns() as $_column): ?>
|
173 |
+
<td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i == $numColumns ? 'last' : '' ?>">
|
174 |
+
<?php echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
|
175 |
+
$_column->getRowField($this->getSubTotalItem($_item))
|
176 |
+
);
|
177 |
+
?>
|
178 |
+
</td>
|
179 |
+
<?php endforeach; ?>
|
180 |
+
</tr>
|
181 |
+
<?php endif; ?>
|
182 |
+
<?php endforeach; ?>
|
183 |
+
<?php elseif ($this->getEmptyText()): ?>
|
184 |
+
<tr>
|
185 |
+
<td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns ?>"><?php echo $this->getEmptyText() ?></td>
|
186 |
+
</tr>
|
187 |
+
<?php endif; ?>
|
188 |
+
</tbody>
|
189 |
+
|
190 |
+
</table>
|
191 |
+
</div>
|
192 |
+
</div>
|
193 |
+
<?php if($this->canDisplayContainer()): ?>
|
194 |
+
</div>
|
195 |
+
<script type="text/javascript">
|
196 |
+
//<![CDATA[
|
197 |
+
<?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
|
198 |
+
<?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
|
199 |
+
<?php if($this->getRowClickCallback()): ?>
|
200 |
+
<?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
|
201 |
+
<?php endif; ?>
|
202 |
+
<?php if($this->getCheckboxCheckCallback()): ?>
|
203 |
+
<?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
|
204 |
+
<?php endif; ?>
|
205 |
+
<?php if($this->getRowInitCallback()): ?>
|
206 |
+
<?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
|
207 |
+
<?php echo $this->getJsObjectName() ?>.initGridRows();
|
208 |
+
<?php endif; ?>
|
209 |
+
<?php if($this->getMassactionBlock()->isAvailable()): ?>
|
210 |
+
<?php echo $this->getMassactionBlock()->getJavaScript() ?>
|
211 |
+
<?php endif ?>
|
212 |
+
<?php echo $this->getAdditionalJavaScript(); ?>
|
213 |
+
//]]>
|
214 |
+
</script>
|
215 |
+
<?php endif; ?>
|
216 |
+
<?php endif ?>
|
app/etc/modules/Inchoo_Optit.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Inchoo_Optit>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Inchoo_Optit>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Optit</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GNU General Public License (GPL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Integration with Opt It SMS and MMS</summary>
|
10 |
+
<description>Opt It Mobile is an industry leading text message marketing application to engage, build brand awareness and create a direct dialogue with your customers. Thousands are growing their businesses by utilizing the power of permission based text message marketing.
|
11 |
+

|
12 |
+
This Magento extension integrates with Opt It's Mobile API and provides membership management and messaging UI as well as a PHP API.</description>
|
13 |
+
<notes>Install extension and configure at Promotions > Opt It.</notes>
|
14 |
+
<authors><author><name>Technivant</name><user>technivant</user><email>info@technivant.com</email></author></authors>
|
15 |
+
<date>2016-08-25</date>
|
16 |
+
<time>17:11:08</time>
|
17 |
+
<contents><target name="magelocal"><dir name="Inchoo"><dir name="Optit"><dir name="Block"><dir name="Adminhtml"><dir name="Interest"><dir name="Edit"><file name="Form.php" hash="df10a009994e5374d7746c0c92ce9c12"/></dir><file name="Edit.php" hash="0172c0c244fb114af0f13dd73831556b"/><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="8cba7872f28f6b1a4164975985f84ed4"/></dir></dir><file name="Grid.php" hash="e6f6c0c2130bbc3cef013c2b5d59a3ec"/></dir><file name="Interest.php" hash="be10603096527cbed2fde68be36a35d3"/><dir name="Keyword"><dir name="Edit"><file name="Form.php" hash="6aeb0706dbf04db126d1e307fd829c23"/></dir><file name="Edit.php" hash="656069a0f85727fd9a835df80ee72cf0"/><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="1714ce05480ccbaa1e3e28887083cddd"/></dir></dir><file name="Grid.php" hash="86a74f09ec914eb487cf1fbcf5809b76"/></dir><file name="Keyword.php" hash="181fc425efea649c9e49b876d301ad1b"/><dir name="Member"><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="2082516783f3f3902868b75354590e9e"/></dir></dir><file name="Grid.php" hash="4e1fb6f3d704b8fcb610388862b65c27"/></dir><file name="Member.php" hash="7ff3b27bbc7c821f25eb3d57ff985630"/><dir name="Message"><dir name="Mms"><dir name="Edit"><file name="Form.php" hash="b37be684c503c129a9d6e9a68765d918"/></dir><file name="Edit.php" hash="9aa6e2df90bc31a32f5fbcfb8ade6d31"/><file name="Grid.php" hash="ff151a11c534166fd9dc91bdd9559f41"/></dir><file name="Mms.php" hash="8ea4720ddbe38f354df62ee55f52d58b"/><dir name="Sms"><dir name="Edit"><file name="Form.php" hash="0dfa643029d505dd1d010b2439b541bc"/></dir><file name="Edit.php" hash="b21feaab8e0b222e1e3933eff92812cb"/><file name="Grid.php" hash="ad8c7a89747fe7a9bfbbfefd087bc22b"/></dir><file name="Sms.php" hash="96a9548b60439eb714b5237a191b3428"/></dir><dir name="Subscription"><dir name="Edit"><file name="Form.php" hash="4523f8c9198a01104af6d7715b6c420e"/></dir><file name="Edit.php" hash="abafedbb184ab992c2bf86c911a35602"/><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="17778376644da1bf0ee6f392bffdb45a"/></dir></dir><file name="Grid.php" hash="7a354b9d7169c791ae5c65b1cb699d2c"/><dir name="Subscribe"><dir name="Edit"><file name="Form.php" hash="ada190d4e10ee7e47b98f8e8ac47eeeb"/></dir><file name="Edit.php" hash="62df7dbb26c291df4aa84138b4e2c983"/></dir></dir><file name="Subscription.php" hash="3310bddbff194e31277ae13330ddbe2a"/><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Action.php" hash="7c5fecdb611324e125939fe198c2dd64"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="1af5128668db4db4cef4280e4c27618a"/></dir><dir name="Model"><file name="Abstract.php" hash="d9fc6dddce55b4926c6cacd262071bb8"/><file name="Client.php" hash="c57fbf485e9fc96ce623e19807dcf741"/><file name="Collecition.php" hash="c41691c5bc4eac2a32cdc7afc8d1d4fd"/><file name="Interest.php" hash="5e516647ed41ecc4d7c765826ef0d19e"/><file name="Keyword.php" hash="efe1c134ef8faa229354486ebdd1dbf1"/><file name="Member.php" hash="8f34d20363d7b3c5b820a809b8f0327d"/><file name="Message.php" hash="d495d7712d4c78dd01ec8a03371413bc"/><dir name="Resource"><dir name="Message"><file name="Collection.php" hash="29911120fcad734ffa39b760acb1db53"/></dir><file name="Message.php" hash="a16ce9e6b10216b75e3a0edd31a71c20"/><file name="Phone.php" hash="27c2954051dda30d18b9cb23256c52ca"/></dir><file name="Subscription.php" hash="c0e581a9c53418723f08a6c5b8860f1a"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Billing"><file name="Type.php" hash="800d8f9979007385a40c1166e4c9e92e"/></dir><dir name="Customer"><file name="Gender.php" hash="b8625afdc238b9cfe5d249ec4b3acdc4"/></dir><dir name="Message"><file name="Keyword.php" hash="edfaa1a4107912a71e47be6877b44570"/></dir><dir name="Subscribed"><dir name="Message"><file name="Type.php" hash="d351cc84a860f9c61c1d3ced4e3dd69e"/></dir></dir><dir name="Subscription"><file name="Interest.php" hash="2ea5d71c2edae769970d3ba0e5853746"/><file name="Phone.php" hash="5b16446404b73f24ac6d2009f1599807"/></dir><dir name="Web"><dir name="Form"><dir name="Message"><file name="Type.php" hash="6984f36be07d3460d939e5a845353c8f"/></dir></dir></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Optit"><file name="BulkController.php" hash="84ed21ffbd335d6c4fb3e0948a37d717"/><file name="InterestController.php" hash="cfb2d653329129d650db6df8362f2415"/><file name="KeywordController.php" hash="e094cc91ca9e5b31719ca51d0a9025e1"/><file name="MemberController.php" hash="71f063ab9c61f17f79c6403aee9f85af"/><file name="MessageController.php" hash="b67a2d85eebfa3daa5f807fb767740cd"/><file name="SubscriptionController.php" hash="ded72ce832ae52b30115f307cd2ebafb"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2ba9415e5d9a8ac7355ccf253f5984f2"/><file name="config.xml" hash="45f640fa7006ad389fab1b8e48d42aff"/><file name="system.xml" hash="624659a31880ab41d4232635847ecaeb"/></dir><dir name="sql"><dir name="optit_setup"><file name="install-0.1.0.php" hash="9eef425b56118d478f4cf59f87d328f9"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="optit.xml" hash="44554e5e8a8108d5733c3ccbc9f7c425"/></dir><dir name="template"><dir name="optit"><file name="grid.phtml" hash="701a433d0dc3a701921321b757d0a669"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Inchoo_Optit.xml" hash="3965904c7abe0c9c01b71c193a2828e5"/></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
+
</package>
|