1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Notification
35: extends Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
36: implements Mage_Adminhtml_Block_Widget_Tab_Interface
37: {
38: 39: 40: 41:
42: public function __construct()
43: {
44: parent::__construct();
45: $this->setShowGlobalIcon(true);
46: }
47:
48: 49: 50: 51: 52: 53:
54: protected function _prepareForm()
55: {
56: $form = new Varien_Data_Form();
57:
58: $this->setForm($form);
59:
60: $data = Mage::helper('xmlconnect')->getApplication()->getFormData();
61:
62: $yesNoValues = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();
63:
64: $fieldset = $form->addFieldset('notifications', array(
65: 'legend' => $this->__('Urban Airship Push Notification'),
66: ));
67:
68: if (isset($data['conf[native][notifications][isActive]'])) {
69: $notificationStatus = $data['conf[native][notifications][isActive]'];
70: } else {
71: $notificationStatus = '0';
72: }
73:
74: $notificationEnabled = $fieldset->addField('conf/native/notifisations/isActive', 'select', array(
75: 'label' => $this->__('Enable AirMail Message Push notification'),
76: 'name' => 'conf[native][notifications][isActive]',
77: 'values' => $yesNoValues,
78: 'value' => $notificationStatus,
79: ));
80:
81: if (isset($data['conf[native][notifications][applicationKey]'])) {
82: $keyValue = $data['conf[native][notifications][applicationKey]'];
83: } else {
84: $keyValue = '';
85: }
86:
87: $applicationKey = $fieldset->addField('conf/native/notifications/applicationKey', 'text', array(
88: 'label' => $this->__('Application Key'),
89: 'name' => 'conf[native][notifications][applicationKey]',
90: 'value' => $keyValue,
91: 'required' => true
92: ));
93:
94: if (isset($data['conf[native][notifications][applicationSecret]'])) {
95: $secretValue = $data['conf[native][notifications][applicationSecret]'];
96: } else {
97: $secretValue = '';
98: }
99:
100: $applicationSecret = $fieldset->addField('conf/native/notifications/applicationSecret', 'text', array(
101: 'label' => $this->__('Application Secret'),
102: 'name' => 'conf[native][notifications][applicationSecret]',
103: 'value' => $secretValue,
104: 'required' => true
105: ));
106:
107: if (isset($data['conf[native][notifications][applicationMasterSecret]'])) {
108: $mSecretValue = $data['conf[native][notifications][applicationMasterSecret]'];
109: } else {
110: $mSecretValue = '';
111: }
112:
113: $mSecretConfPath = 'conf/native/notifications/applicationMasterSecret';
114: $applicationMasterSecret = $fieldset->addField($mSecretConfPath, 'text', array(
115: 'label' => $this->__('Application Master Secret'),
116: 'name' => 'conf[native][notifications][applicationMasterSecret]',
117: 'value' => $mSecretValue,
118: 'required' => true
119: ));
120:
121: if (isset($data['conf[native][notifications][mailboxTitle]'])) {
122: $titleValue = $data['conf[native][notifications][mailboxTitle]'];
123: } else {
124: $titleValue = '';
125: }
126:
127: $mailboxTitle = $fieldset->addField('conf/native/notifications/mailboxTitle', 'text', array(
128: 'label' => $this->__('Mailbox title'),
129: 'name' => 'conf[native][notifications][mailboxTitle]',
130: 'value' => $titleValue,
131: 'required' => true,
132: 'note' => $this->__('The Mailbox title will be shown in the More Info tab. To understand more about the title, please <a target="_blank" href="http://www.magentocommerce.com/img/product/mobile/helpers/mail_box_title.png">click here</a>')
133: ));
134:
135:
136: $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
137: ->addFieldMap($applicationKey->getHtmlId(), $applicationKey->getName())
138: ->addFieldMap($applicationSecret->getHtmlId(), $applicationSecret->getName())
139: ->addFieldMap($applicationMasterSecret->getHtmlId(), $applicationMasterSecret->getName())
140: ->addFieldMap($mailboxTitle->getHtmlId(), $mailboxTitle->getName())
141: ->addFieldMap($notificationEnabled->getHtmlId(), $notificationEnabled->getName())
142: ->addFieldDependence(
143: $applicationKey->getName(),
144: $notificationEnabled->getName(),
145: 1)
146: ->addFieldDependence(
147: $applicationSecret->getName(),
148: $notificationEnabled->getName(),
149: 1)
150: ->addFieldDependence(
151: $applicationMasterSecret->getName(),
152: $notificationEnabled->getName(),
153: 1)
154: ->addFieldDependence(
155: $mailboxTitle->getName(),
156: $notificationEnabled->getName(),
157: 1)
158: );
159: return parent::_prepareForm();
160: }
161:
162: 163: 164: 165: 166:
167: public function getTabLabel()
168: {
169: return $this->__('Push Notification');
170: }
171:
172: 173: 174: 175: 176:
177: public function getTabTitle()
178: {
179: return $this->__('Push Notification');
180: }
181:
182: 183: 184: 185: 186:
187: public function canShowTab()
188: {
189: return (bool) !Mage::getSingleton('adminhtml/session')->getNewApplication()
190: && Mage::helper('xmlconnect')->isNotificationsAllowed();
191: }
192:
193: 194: 195: 196: 197:
198: public function isHidden()
199: {
200: if (!$this->getData('conf/special/notifications_submitted')) {
201: return false;
202: } else {
203: return true;
204: }
205: }
206:
207: 208: 209: 210: 211:
212: protected function _toHtml()
213: {
214: return $this->getChildHtml('app_notification_helper') . parent::_toHtml();
215: }
216: }
217: