Skip to content

Commit e50adea

Browse files
author
Jason Smale
committed
Merge pull request #52 from max-mi/master
Empty SSO Token Validate & Try to create log file if it does not exist
2 parents a5d1818 + 54844e2 commit e50adea

File tree

8 files changed

+81
-2
lines changed

8 files changed

+81
-2
lines changed

src/app/code/community/Zendesk/Zendesk/controllers/Adminhtml/ZendeskController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,14 @@ public function autocompleteAction()
364364
public function logAction()
365365
{
366366
$path = Mage::helper('zendesk/log')->getLogPath();
367-
367+
368368
if(!file_exists($path)) {
369-
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('zendesk')->__('The Zendesk log file has not been created. Check to see if logging has been enabled.'));
369+
if (is_writable($path)) {
370+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('zendesk')->__('Creating a Zendesk log file.'));
371+
file_put_contents(" ",$path);
372+
} else {
373+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('zendesk')->__('Magento logging has been disabled or Magento log folder has incorrect permissions.'));
374+
}
370375
}
371376

372377
if(Mage::helper('zendesk/log')->isLogTooLarge()) {

src/app/code/community/Zendesk/Zendesk/etc/config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@
115115
<zendesk>
116116
<file>zendesk.xml</file>
117117
</zendesk>
118+
<jstranslate>
119+
<file>jstranslate.xml</file>
120+
</jstranslate>
118121
</updates>
119122
</layout>
120123
<translate>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright 2015 Zendesk
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
-->
19+
<jstranslator>
20+
<validate-zendesk-sso-token translate="message" module="zendesk">
21+
<message>Token cannot be empty</message>
22+
</validate-zendesk-sso-token>
23+
<validate-zendesk-sso-frontend-token translate="message" module="zendesk">
24+
<message>Token cannot be empty</message>
25+
</validate-zendesk-sso-frontend-token>
26+
</jstranslator>

src/app/code/community/Zendesk/Zendesk/etc/system.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
<label>Remote Authentication Token</label>
136136
<frontend_type>text</frontend_type>
137137
<sort_order>2</sort_order>
138+
<validate>validate-zendesk-sso-token</validate>
138139
<show_in_default>1</show_in_default>
139140
<show_in_website>1</show_in_website>
140141
<show_in_store>1</show_in_store>
@@ -164,6 +165,7 @@
164165
<label>Remote Authentication Token</label>
165166
<frontend_type>text</frontend_type>
166167
<sort_order>2</sort_order>
168+
<validate>validate-zendesk-sso-frontend-token</validate>
167169
<show_in_default>1</show_in_default>
168170
<show_in_website>1</show_in_website>
169171
<show_in_store>1</show_in_store>

src/app/design/adminhtml/default/default/layout/zendesk.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
<action method="addCss">
2323
<stylesheet>zendesk/zendesk.css</stylesheet>
2424
</action>
25+
<action method="addJs">
26+
<script>zendesk/validation.js</script>
27+
</action>
28+
</reference>
29+
<reference name="content">
30+
<block type="core/template" template="zendesk/translations.phtml"></block>
2531
</reference>
2632
</adminhtml_system_config_edit>
2733

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Copyright 2015 Zendesk
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
?>
18+
<script>
19+
Translator.add('Token cannot be empty', '<?php echo $this->__('Token cannot be empty'); ?>');
20+
</script>

src/app/locale/en_US/Zendesk_Zendesk.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,4 @@
109109
"Decide which features you would like turned on in your admin panel.","Decide which features you would like turned on in your admin panel."
110110
"Show "All" tab on dashboard","Show "All" tab on dashboard"
111111
"Generate New Token","Generate New Token"
112+
"Token cannot be empty","Token cannot be empty"

src/js/zendesk/validation.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Validation.addAllThese([
2+
['validate-zendesk-sso-token', 'Token cannot be empty', function (v) {
3+
if ($('zendesk_sso_enabled').getValue() === '1') {
4+
return !Validation.get('IsEmpty').test(v);
5+
} else {
6+
return true;
7+
}
8+
}],
9+
['validate-zendesk-sso-frontend-token', 'Token cannot be empty', function (v) {
10+
if ($('zendesk_sso_frontend_enabled').getValue() === '1') {
11+
return !Validation.get('IsEmpty').test(v);
12+
} else {
13+
return true;
14+
}
15+
}]
16+
]);

0 commit comments

Comments
 (0)