@@ -22,9 +22,10 @@ public function getUrl($object = '', $id = null, $format = 'old')
2222 {
2323 $ protocol = 'https:// ' ;
2424 $ domain = Mage::getStoreConfig ('zendesk/general/domain ' );
25- $ root = ($ format === 'old ' ) ? '' : '/agent/# ' ;
25+ $ root = ($ format === 'old ' ) ? '' : '/agent ' ;
2626
2727 $ base = $ protocol . $ domain . $ root ;
28+ $ hc = $ protocol . $ domain . '/hc ' ;
2829
2930 switch ($ object ) {
3031 case '' :
@@ -42,6 +43,10 @@ public function getUrl($object = '', $id = null, $format = 'old')
4243 case 'raw ' :
4344 return $ protocol . $ domain . '/ ' . $ id ;
4445 break ;
46+
47+ case 'request ' :
48+ return $ hc . '/requests/ ' . $ id ;
49+ break ;
4550 }
4651 }
4752
@@ -280,9 +285,17 @@ public function isExternalIdEnabled()
280285 }
281286
282287 public function getTicketUrl ($ row , $ link = false )
283- {
288+ {
289+ if ($ this ->isAdmin ()) {
290+ $ path = 'adminhtml/zendesk/login ' ;
291+ $ object = 'ticket ' ;
292+ } else {
293+ $ path = '*/sso/login ' ;
294+ $ object = 'request ' ;
295+ }
284296 $ path = Mage::getSingleton ('admin/session ' )->getUser () ? 'adminhtml/zendesk/login ' : '*/sso/login ' ;
285- $ url = Mage::helper ('adminhtml ' )->getUrl ($ path , array ("return_url " => Mage::helper ('core ' )->urlEncode (Mage::helper ('zendesk ' )->getUrl ('ticket ' , $ row ['id ' ]))));
297+
298+ $ url = Mage::helper ('adminhtml ' )->getUrl ($ path , array ("return_url " => Mage::helper ('core ' )->urlEncode (Mage::helper ('zendesk ' )->getUrl ($ object , $ row ['id ' ]))));
286299
287300 if ($ link )
288301 return $ url ;
@@ -291,7 +304,7 @@ public function getTicketUrl($row, $link = false)
291304
292305 return '<a href=" ' . $ url . '" target="_blank"> ' . Mage::helper ('core ' )->escapeHtml ($ subject ) . '</a> ' ;
293306 }
294-
307+
295308 public function getStatusMap ()
296309 {
297310 return array (
@@ -303,6 +316,7 @@ public function getStatusMap()
303316 'hold ' => 'Hold '
304317 );
305318 }
319+
306320
307321 public function getPriorityMap ()
308322 {
@@ -401,4 +415,17 @@ public function storeDependenciesInCachedRegistry() {
401415 Mage::register ('zendesk_groups ' , $ groups );
402416 }
403417 }
418+
419+ /**
420+ * Checks whether the user is in an admin page.
421+ *
422+ * @return boolean
423+ */
424+ public function isAdmin ()
425+ {
426+ return (
427+ Mage::getSingleton ('admin/session ' )->getUser () &&
428+ (Mage::app ()->getStore ()->isAdmin () || Mage::getDesign ()->getArea () == 'adminhtml ' )
429+ );
430+ }
404431}
0 commit comments