Skip to content

Commit a79a9fe

Browse files
maxmimaxmi
authored andcommitted
Reformat
1 parent 7623adc commit a79a9fe

File tree

18 files changed

+117
-211
lines changed

18 files changed

+117
-211
lines changed

src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Dashboard.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@ public function getIsZendeskDashboard() {
2929

3030
public function getAuthHeader() {
3131
return 'Token token="' . Mage::helper('zendesk')->getApiToken(false) . '"';
32-
}
32+
}
3333

3434
public function isConnected() {
3535
$connection = Mage::helper('zendesk')->getConnectionStatus();
3636
return $connection['success'];
3737
}
38-
38+
3939
public function getTotals() {
4040
return Mage::helper("zendesk")->getTicketTotals();
4141
}
42-
4342
}

src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Dashboard/Grids.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@ class Zendesk_Zendesk_Block_Adminhtml_Dashboard_Grids extends Mage_Adminhtml_Blo
2020

2121
public function __construct() {
2222
parent::__construct();
23-
23+
2424
$this->setId('tickets_grid_tab');
2525
$this->setDestElementId('tickets_grid_tab_content');
2626
$this->setTemplate('widget/tabshoriz.phtml');
2727
}
28-
28+
2929
protected function _prepareLayout() {
3030
// Check if we are on the main admin dashboard and, if so, whether we should be showing the grid
3131
// Note: an additional check in the template is needed, but this will prevent unnecessary API calls to Zendesk
32-
if (!$this->getIsZendeskDashboard() && !Mage::getStoreConfig('zendesk/backend_features/show_on_dashboard')) {
32+
if ( !$this->getIsZendeskDashboard() && !Mage::getStoreConfig('zendesk/backend_features/show_on_dashboard') )
33+
{
3334
return parent::_prepareLayout();
3435
}
35-
36+
3637
//check if module is setted up
3738
$configured = (bool) Mage::getStoreConfig('zendesk/general/domain');
3839
$viewsIds = Mage::getStoreConfig('zendesk/backend_features/show_views') ? Mage::helper('zendesk')->getChosenViews() : array();
@@ -45,8 +46,7 @@ protected function _prepareLayout() {
4546
$label = $this->__("All tickets");
4647

4748
$all_count = Mage::registry('zendesk_tickets_all');
48-
if ( !$all_count )
49-
{
49+
if (!$all_count) {
5050
$this->getLayout()->createBlock('zendesk/adminhtml_dashboard_tab_tickets_grid_all')->toHtml();
5151
$all_count = Mage::registry('zendesk_tickets_all');
5252
}
@@ -75,15 +75,14 @@ protected function _prepareLayout() {
7575
return $view['view_id'] === (int) $viewId;
7676
}));
7777

78-
if( $count['value'] ) {
78+
if($count['value']) {
7979
$label = $view['title'] . ' (' . $count['value'] . ')';
8080
$this->addTab($viewId, array(
8181
'label' => $label,
8282
'class' => 'ajax',
8383
'url' => $this->getUrl('zendesk/adminhtml_zendesk/ticketsView', array('viewid' => $viewId)),
8484
));
85-
}
86-
else {
85+
} else {
8786
Mage::unregister('zendesk_tickets_view');
8887
Mage::register('zendesk_tickets_view', $viewId);
8988

@@ -106,5 +105,4 @@ protected function _prepareLayout() {
106105
public function getIsZendeskDashboard() {
107106
return Mage::app()->getFrontController()->getRequest()->getControllerName() === 'zendesk';
108107
}
109-
110108
}

src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Dashboard/Tab/Tickets/Grid/Abstract.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ protected abstract function _getCollection($collection);
3131
protected function _getCollectionModel() {
3232
return Mage::getModel('zendesk/resource_tickets_collection');
3333
}
34-
34+
3535
public function setViewId($id = null) {
3636
$this->_viewId = (is_null($id) ? uniqid() : $id);
3737
}
38-
38+
3939
public function __construct($attributes = array()) {
4040
parent::__construct($attributes);
41-
41+
4242
$this->_defaultSort = Mage::getStoreConfig('zendesk/backend_features/default_sort');
4343
$this->_defaultDir = Mage::getStoreConfig('zendesk/backend_features/default_sort_dir');
4444

@@ -49,7 +49,7 @@ public function __construct($attributes = array()) {
4949

5050
protected function _construct() {
5151
parent::_construct();
52-
52+
5353
$this->setMassactionBlockName('zendesk/adminhtml_dashboard_tab_tickets_grid_massaction');
5454
$this->setId('zendesk_tab_tickets_grid_' . $this->_viewId);
5555
$this->setSaveParametersInSession(true);
@@ -65,11 +65,11 @@ protected function _construct() {
6565

6666
protected function _preparePage() {
6767
parent::_preparePage();
68-
69-
$this->_page = (int) $this->getParam( $this->getVarNamePage(), $this->_defaultPage);
70-
$this->_limit = (int) $this->getParam( $this->getVarNameLimit(), $this->_defaultLimit);
68+
69+
$this->_page = (int) $this->getParam($this->getVarNamePage(), $this->_defaultPage);
70+
$this->_limit = (int) $this->getParam($this->getVarNameLimit(), $this->_defaultLimit);
7171
}
72-
72+
7373
protected function _prepareCollection() {
7474
if( ! $this->getCollection() ) {
7575
$collection = $this->_getCollectionModel();
@@ -89,7 +89,7 @@ protected function _prepareCollection() {
8989

9090
protected function _prepareMassaction() {
9191
parent::_prepareMassaction();
92-
92+
9393
$this->setMassactionIdField('id');
9494
$this->getMassactionBlock()->setFormFieldName('id');
9595

@@ -213,4 +213,4 @@ protected function getGridParams() {
213213
);
214214
}
215215

216-
}
216+
}

src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Dashboard/Tab/Tickets/Grid/All.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
*/
1818

1919
class Zendesk_Zendesk_Block_Adminhtml_Dashboard_Tab_Tickets_Grid_All extends Zendesk_Zendesk_Block_Adminhtml_Dashboard_Tab_Tickets_Grid_Abstract {
20-
20+
2121
public function __construct($attributes = array()) {
2222
$this->setViewId('all');
23-
23+
2424
parent::__construct($attributes);
2525
}
26-
26+
2727
protected function _getCollection($collection) {
2828
return $collection->getCollection($this->getGridParams());
2929
}
30-
30+
3131
public function getGridUrl() {
3232
return $this->getUrl('*/*/ticketsAll', array('_current' => true));
3333
}
34-
34+
3535
protected function _prepareColumns() {
3636
$this->addColumn('id', array(
3737
'header' => Mage::helper('zendesk')->__('Ticket ID'),
@@ -40,23 +40,23 @@ protected function _prepareColumns() {
4040
'width' => '30px',
4141
'index' => 'id',
4242
));
43-
43+
4444
$this->addColumn('subject', array(
4545
'header' => Mage::helper('zendesk')->__('Subject'),
4646
'sortable' => false,
4747
'index' => 'description',
4848
'type' => 'text',
4949
'renderer' => 'zendesk/adminhtml_dashboard_tab_tickets_grid_renderer_action',
5050
));
51-
51+
5252
$this->addColumn('requester_id', array(
5353
'header' => Mage::helper('zendesk')->__('Email'),
5454
'width' => '60',
5555
'renderer' => 'zendesk/adminhtml_dashboard_tab_tickets_grid_renderer_email',
5656
'index' => 'requester_id',
5757
'sortable' => false,
5858
));
59-
59+
6060
$this->addColumn('type', array(
6161
'header' => Mage::helper('zendesk')->__('Type'),
6262
'width' => '100',
@@ -103,4 +103,4 @@ protected function _prepareColumns() {
103103
return parent::_prepareColumns();
104104
}
105105

106-
}
106+
}

src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Dashboard/Tab/Tickets/Grid/View.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public function getGridUrl() {
3333
return $this->getUrl('*/*/ticketsView', array('_current' => true));
3434
}
3535

36-
protected function _prepareGrid()
37-
{
36+
protected function _prepareGrid() {
3837
parent::_prepareGrid();
3938
$this->_prepareDynamicColumns();
4039
$this->_prepareCollection();

src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Settings/Edit/Form.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,14 @@ protected function _prepareForm() {
4242
'value' => Mage::getSingleton('admin/session')->getUser()->getUserId()
4343
));
4444

45-
if( Mage::getSingleton('admin/session')->isAllowed('zendesk/main_api_credentials') ) {
45+
if(Mage::getSingleton('admin/session')->isAllowed('zendesk/main_api_credentials')) {
4646
$fieldset->addField('use_global_settings', 'select', array(
4747
'name' => 'use_global_settings',
4848
'label' => Mage::helper('zendesk')->__('Use Global Settings'),
4949
'options' => Mage::getModel('adminhtml/system_config_source_yesno')->toArray(),
5050
'value' => 1
5151
));
52-
}
53-
else {
52+
} else {
5453
$fieldset->addField('use_global_settings', 'hidden', array(
5554
'name' => 'use_global_settings',
5655
'value' => 0

src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Widget/Form/Renderer/Fieldset.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
class Zendesk_Zendesk_Block_Adminhtml_Widget_Form_Renderer_Fieldset extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset {
44
protected $_message = '';
55

6-
protected function _construct()
7-
{
6+
protected function _construct() {
87
parent::_construct();
98
$this->setTemplate('zendesk/widget/form/renderer/fieldset.phtml');
109
}

src/app/code/community/Zendesk/Zendesk/Helper/Data.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function getTicketUrl($row, $link = false)
274274
$path = Mage::getSingleton('admin/session')->getUser() ? 'adminhtml/zendesk/login' : '*/sso/login';
275275
$url = Mage::helper('adminhtml')->getUrl($path, array("return_url" => Mage::helper('core')->urlEncode(Mage::helper('zendesk')->getUrl('ticket', $row['id']))));
276276

277-
if ( $link )
277+
if ($link)
278278
return $url;
279279

280280
$subject = $row['subject'] ? $row['subject'] : $this->__('No Subject');
@@ -284,14 +284,11 @@ public function getTicketUrl($row, $link = false)
284284

285285
public function getAdminSettings() {
286286
$admin = Mage::getSingleton('admin/session')->getUser();
287-
if( $admin )
288-
{
287+
if($admin) {
289288
$adminId = $admin->getUserId();
290289
$settings = Mage::getModel('zendesk/settings')->loadByAdminId($adminId);
291290
return $settings;
292-
}
293-
else
294-
{
291+
} else {
295292
return false;
296293
}
297294

@@ -327,7 +324,7 @@ public function getTypeMap()
327324
'question' => 'Question',
328325
'task' => 'Task'
329326
);
330-
}
327+
}
331328

332329
public function getChosenViews() {
333330
$list = trim(trim(Mage::getStoreConfig('zendesk/backend_features/show_views')), ',');
@@ -340,7 +337,7 @@ public function getFormatedDataForAPI($dateToFormat) {
340337
}
341338

342339
public function isValidDate($date) {
343-
if( is_string($date) ) {
340+
if(is_string($date)) {
344341
$d = DateTime::createFromFormat('d/m/Y', $date);
345342
return $d && $d->format('d/m/Y') == $date;
346343
}

src/app/code/community/Zendesk/Zendesk/Model/Api/Abstract.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,15 @@ protected function _call($endpoint, $params = null, $method = 'GET', $data = nul
4949

5050
$settings = Mage::helper('zendesk')->getAdminSettings();
5151

52-
if( $settings && isset($settings) && $settings->isConfigured() && !$global)
53-
{
54-
if( $settings->getUseGlobalSettings() === "0")
55-
{
52+
if($settings && isset($settings) && $settings->isConfigured() && !$global) {
53+
if($settings->getUseGlobalSettings() === "0") {
5654
$email = $settings->getUsername();
5755
$password = Mage::helper('core')->decrypt($settings->getPassword());
58-
}
59-
else
60-
{
56+
} else {
6157
$email = Mage::getStoreConfig('zendesk/general/email'). '/token';
6258
$password = Mage::getStoreConfig('zendesk/general/password');
6359
}
64-
}
65-
else
66-
{
60+
} else {
6761
$email = Mage::getStoreConfig('zendesk/general/email'). '/token';
6862
$password = Mage::getStoreConfig('zendesk/general/password');
6963
}
@@ -90,12 +84,9 @@ protected function _call($endpoint, $params = null, $method = 'GET', $data = nul
9084
'zendesk.log'
9185
);
9286

93-
try
94-
{
87+
try {
9588
$response = $client->request();
96-
}
97-
catch ( Exception $ex )
98-
{
89+
} catch ( Exception $ex ) {
9990
return array();
10091
}
10192

src/app/code/community/Zendesk/Zendesk/Model/Api/Tickets.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,28 +144,24 @@ public function forOrder($orderIncrementId)
144144
public function forRequester($customerEmail)
145145
{
146146
$user = Mage::getModel('zendesk/api_users')->find($customerEmail);
147-
if( isset($user['id']) )
148-
{
147+
if(isset($user['id'])) {
149148
$response = $this->_call('users/' . $user['id'] . '/requests.json', null, 'GET', null, false, true);
150149
return $response['requests'];
151-
}
152-
else
153-
{
150+
} else {
154151
return array();
155152
}
156153
}
157154

158155
public function bulkDelete($data)
159156
{
160-
if ( is_array($data) )
161-
{
157+
if (is_array($data)) {
162158
$params['ids'] = implode(",",$data);
163159
return $this->_call('tickets/destroy_many.json', $params, 'DELETE');
164160
}
165161
}
166162

167163
public function updateMany($ids, $data) {
168-
if( is_array($ids) ) {
164+
if(is_array($ids)) {
169165
$params['ids'] = implode(",", $ids);
170166
$ticket['ticket'] = $data;
171167

@@ -182,8 +178,7 @@ public function getJobStatus($url)
182178

183179
public function bulkMarkAsSpam($data)
184180
{
185-
if ( is_array($data) )
186-
{
181+
if (is_array($data)) {
187182
$params['ids'] = implode(",",$data);
188183
return $this->_call('tickets/mark_many_as_spam.json', $params, 'PUT');
189184
}

0 commit comments

Comments
 (0)