Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -13,7 +13,7 @@ namespace IPS\nexus\modules\admin\support;
|
||||
use \IPS\nexus\Support;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -24,6 +24,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _request extends \IPS\nexus\modules\front\support\view
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
@@ -92,7 +97,35 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
|
||||
if ( $action->message )
|
||||
{
|
||||
$data['message'] = $action->message;
|
||||
/* Do we have default content? */
|
||||
try
|
||||
{
|
||||
$defaultContent = \IPS\Db::i()->select( 'content', 'nexus_support_staff_preferences', array( 'staff_id=?', \IPS\Member::loggedIn()->member_id ) )->first();
|
||||
|
||||
/* If we aren't using the {default_content} tag then we just want the stock reply returned */
|
||||
if( mb_strpos( $defaultContent, '{default_content}' ) === FALSE )
|
||||
{
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
$data['message'] = str_replace(
|
||||
array( '{customer_first_name}', '{customer_last_name}', '{customer_full_name}', '{department_name}', '{department_email}', '{default_content}' ),
|
||||
array(
|
||||
( $this->request->supportAuthor() instanceof \IPS\nexus\Support\Author\Member ) ? \IPS\nexus\Customer::load( $this->request->author()->member_id )->cm_first_name : '',
|
||||
( $this->request->supportAuthor() instanceof \IPS\nexus\Support\Author\Member ) ? \IPS\nexus\Customer::load( $this->request->author()->member_id )->cm_last_name : '',
|
||||
$this->request->supportAuthor()->name(),
|
||||
$action->department ? $action->department->_title : $this->request->department->_title,
|
||||
$action->department ? $action->department->email : $this->request->department->email,
|
||||
/* We want to strip the wrapping <p></p> because where we insert it into our default content will already be wrapped, so we will have double line breaks otherwise */
|
||||
preg_replace( "/^<p>(.+?)<\/p>$/is", "$1", trim( $action->message ) )
|
||||
),
|
||||
$defaultContent
|
||||
);
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
$data['message'] = $action->message;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->json( $data );
|
||||
@@ -122,7 +155,9 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
/* Setting Order? */
|
||||
if ( isset( \IPS\Request::i()->order ) )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Request::i()->setCookie( 'support_replies_order', \IPS\Request::i()->order, \IPS\DateTime::create()->add( new \DateInterval('P1Y') ) );
|
||||
\IPS\Output::i()->redirect( $this->request->acpUrl() );
|
||||
}
|
||||
|
||||
/* Views */
|
||||
@@ -144,7 +179,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
'icon' => 'tag',
|
||||
'title' => $this->request->status->_title,
|
||||
'menu' => array(),
|
||||
'menuClass' => 'ipsMenu_selectable ipsMenu_narrow',
|
||||
'menuClass' => 'ipsMenu_selectable ipsMenu_narrow',
|
||||
'data' => array( 'role' => 'statusMenu', 'controller' => 'nexus.admin.support.metamenu' ),
|
||||
'tooltip' => \IPS\Member::loggedIn()->language()->addToStack('keyboard_shortcut_status')
|
||||
),
|
||||
@@ -152,7 +187,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
'icon' => 'exclamation',
|
||||
'title' => $this->request->severity->_title,
|
||||
'menu' => array(),
|
||||
'menuClass' => 'ipsMenu_selectable',
|
||||
'menuClass' => 'ipsMenu_selectable',
|
||||
'data' => array( 'role' => 'severityMenu', 'controller' => 'nexus.admin.support.metamenu' ),
|
||||
'tooltip' => \IPS\Member::loggedIn()->language()->addToStack('keyboard_shortcut_severity')
|
||||
),
|
||||
@@ -160,7 +195,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
'icon' => 'folder',
|
||||
'title' => $this->request->department->_title,
|
||||
'menu' => array(),
|
||||
'menuClass' => 'ipsMenu_selectable ipsMenu_narrow',
|
||||
'menuClass' => 'ipsMenu_selectable ipsMenu_narrow',
|
||||
'data' => array( 'role' => 'departmentMenu', 'controller' => 'nexus.admin.support.metamenu' ),
|
||||
'tooltip' => \IPS\Member::loggedIn()->language()->addToStack('keyboard_shortcut_department')
|
||||
),
|
||||
@@ -171,17 +206,17 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
array(
|
||||
'class' => $trackLang === 'not_tracking' ? 'ipsMenu_itemChecked' : '',
|
||||
'title' => 'not_tracking',
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'track', 'track' => 0 ) )
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'track', 'track' => 0 ) )->csrf()
|
||||
),
|
||||
array(
|
||||
'class' => $trackLang === 'tracking_no_notify' ? 'ipsMenu_itemChecked' : '',
|
||||
'title' => 'tracking_no_notify',
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'track', 'track' => 1, 'notify' => 0 ) )
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'track', 'track' => 1, 'notify' => 0 ) )->csrf()
|
||||
),
|
||||
array(
|
||||
'class' => $trackLang === 'tracking_notify' ? 'ipsMenu_itemChecked' : '',
|
||||
'title' => 'tracking_notify',
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'track', 'track' => 1, 'notify' => 1 ) )
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'track', 'track' => 1, 'notify' => 1 ) )->csrf()
|
||||
)
|
||||
),
|
||||
'menuClass' => 'ipsMenu_selectable',
|
||||
@@ -204,12 +239,12 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$requestActions['status']['menu'][] = array(
|
||||
'class' => $status->id === $this->request->status->id ? 'ipsMenu_itemChecked' : '',
|
||||
'title' => $status->_title,
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'status', 'status' => $status->id ) )
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'status', 'status' => $status->id ) )->csrf()
|
||||
);
|
||||
}
|
||||
|
||||
/* Populate severities */
|
||||
if ( count( Support\Severity::roots() ) < 2 )
|
||||
if ( \count( Support\Severity::roots() ) < 2 )
|
||||
{
|
||||
unset( \IPS\Output::i()->sidebar['actions']['severity'] );
|
||||
}
|
||||
@@ -220,7 +255,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$requestActions['severity']['menu'][] = array(
|
||||
'class' => $severity->id === $this->request->severity->id ? 'ipsMenu_itemChecked' : '',
|
||||
'title' => $severity->_title,
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'severity', 'severity' => $severity->id ) ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'severity', 'severity' => $severity->id ) )->csrf(),
|
||||
'data' => array( 'group' => 'severities' ),
|
||||
);
|
||||
}
|
||||
@@ -231,13 +266,13 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$requestActions['severity']['menu'][] = array(
|
||||
'class' => !$this->request->author()->cm_no_sev ? 'ipsMenu_itemChecked' : '',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'cm_no_sev_off', FALSE, array( 'sprintf' => array( $this->request->supportAuthor()->name() ) ) ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'noSev', 'no_sev' => 0 ) ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'noSev', 'no_sev' => 0 ) )->csrf(),
|
||||
'data' => array( 'group' => 'no_sev', 'noSet' => 'true' ),
|
||||
);
|
||||
$requestActions['severity']['menu'][] = array(
|
||||
'class' => $this->request->author()->cm_no_sev ? 'ipsMenu_itemChecked' : '',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'cm_no_sev_on', FALSE, array( 'sprintf' => array( $this->request->supportAuthor()->name() ) ) ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'noSev', 'no_sev' => 1 ) ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'noSev', 'no_sev' => 1 ) )->csrf(),
|
||||
'data' => array( 'group' => 'no_sev', 'noSet' => 'true' ),
|
||||
);
|
||||
}
|
||||
@@ -249,7 +284,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$requestActions['department']['menu'][] = array(
|
||||
'class' => $department->id === $this->request->department->id ? 'ipsMenu_itemChecked' : '',
|
||||
'title' => $department->_title,
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'department', 'department' => $department->id ) )
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'department', 'department' => $department->id ) )->csrf()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -259,27 +294,27 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$requestActions['staff']['menu'][] = array(
|
||||
'class' => ( $this->request->staff and $id === $this->request->staff->member_id ) ? 'ipsMenu_itemChecked' : '',
|
||||
'title' => $name,
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'staff', 'staff' => $id ) ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'staff', 'staff' => $id ) )->csrf(),
|
||||
'data' => array( 'group' => 'staff', 'id' => $id ),
|
||||
);
|
||||
}
|
||||
$requestActions['staff']['menu'][] = array(
|
||||
'class' => !$this->request->staff ? 'ipsMenu_itemChecked' : '',
|
||||
'title' => 'unassigned',
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'staff', 'staff' => 0 ) ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'staff', 'staff' => 0 ) )->csrf(),
|
||||
'data' => array( 'group' => 'staff', 'id' => 0 ),
|
||||
);
|
||||
$requestActions['staff']['menu'][] = array( 'hr' => TRUE );
|
||||
$requestActions['staff']['menu'][] = array(
|
||||
'class' => $this->request->staff_lock ? 'ipsMenu_itemChecked' : '',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'request_staff_lock_on' ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'staffLock', 'lock' => 1 ) ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'staffLock', 'lock' => 1 ) )->csrf(),
|
||||
'data' => array( 'group' => 'staff_lock', 'noSet' => 'true' ),
|
||||
);
|
||||
$requestActions['staff']['menu'][] = array(
|
||||
'class' => !$this->request->staff_lock ? 'ipsMenu_itemChecked' : '',
|
||||
'title' =>\IPS\Member::loggedIn()->language()->addToStack( 'request_staff_lock_off' ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'staffLock', 'lock' => 0 ) ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( array( 'do' => 'staffLock', 'lock' => 0 ) )->csrf(),
|
||||
'data' => array( 'group' => 'staff_lock', 'noSet' => 'true' ),
|
||||
);
|
||||
|
||||
@@ -289,18 +324,21 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
\IPS\Output::i()->sidebar['actions']['delete'] = array(
|
||||
'icon' => 'times-circle',
|
||||
'title' => 'delete',
|
||||
'link' => $this->request->acpUrl()->setQueryString( 'do', 'delete' ),
|
||||
'link' => $this->request->acpUrl()->setQueryString( 'do', 'delete' )->csrf(),
|
||||
'data' => array( 'confirm' => '' )
|
||||
);
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sidebar['actions']['purchase'] = array(
|
||||
'icon' => 'cube',
|
||||
'title' => 'associate_purchase',
|
||||
'link' => $this->request->acpUrl()->setQueryString( 'do', 'associate' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('associate'), 'ipsDialog-size' => 'narrow', 'role' => 'associatePurchaseMenu' ),
|
||||
'tooltip' => \IPS\Member::loggedIn()->language()->addToStack('keyboard_shortcut_purchase')
|
||||
);
|
||||
if( \IPS\Member::loggedIn()->hasAcpRestriction( \IPS\Application::load('nexus'), \IPS\Application\Module::get( 'nexus', 'customers' ), 'purchases_view' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['purchase'] = array(
|
||||
'icon' => 'cube',
|
||||
'title' => 'associate_purchase',
|
||||
'link' => $this->request->acpUrl()->setQueryString( 'do', 'associate' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('associate'), 'ipsDialog-size' => 'narrow', 'role' => 'associatePurchaseMenu' ),
|
||||
'tooltip' => \IPS\Member::loggedIn()->language()->addToStack('keyboard_shortcut_purchase')
|
||||
);
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'support' )->request( $this->request, $requestActions );
|
||||
|
||||
@@ -408,7 +446,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$page = ceil( $commentPosition / \IPS\nexus\Support\Request::getCommentsPerPage() );
|
||||
if ( $page != 1 )
|
||||
{
|
||||
$url = $url->setQueryString( 'page', $page );
|
||||
$url = $url->setPage( 'page', $page );
|
||||
}
|
||||
$url = $url->setFragment( "reply-{$unreadComment->id}" );
|
||||
|
||||
@@ -429,7 +467,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$lastPage = $request->commentPageCount();
|
||||
if ( $lastPage != 1 )
|
||||
{
|
||||
$url = $url->setQueryString( 'page', $lastPage );
|
||||
$url = $url->setPage( 'page', $lastPage );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,7 +518,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$page = ceil( $commentPosition / \IPS\nexus\Support\Request::getCommentsPerPage() );
|
||||
if ( $page != 1 )
|
||||
{
|
||||
$url = $url->setQueryString( 'page', $page );
|
||||
$url = $url->setPage( 'page', $page );
|
||||
}
|
||||
$url = $url->setFragment( "reply-{$comment->id}" );
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
@@ -492,7 +530,9 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
* @return void
|
||||
*/
|
||||
protected function pending()
|
||||
{
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$message = Support\Reply::loadAndCheckPerms( \IPS\Request::i()->response );
|
||||
@@ -589,7 +629,12 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$form = new \IPS\Helpers\Form;
|
||||
foreach ( $request->department->customFields() as $field )
|
||||
{
|
||||
$form->add( $field->buildHelper( isset( $customFieldValues[ $field->id ] ) ? $customFieldValues[ $field->id ] : NULL ) );
|
||||
if ( $field->type === 'Editor' )
|
||||
{
|
||||
$field::$editorOptions = array_merge( $field::$editorOptions, array( 'attachIds' => array( $request->id, $field->id, 'fields' ) ) );
|
||||
}
|
||||
$helper = $field->buildHelper( isset( $customFieldValues[ $field->id ] ) ? $customFieldValues[ $field->id ] : NULL );
|
||||
$form->add( $helper );
|
||||
}
|
||||
|
||||
if ( $values = $form->values( TRUE ) )
|
||||
@@ -619,6 +664,8 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
*/
|
||||
protected function status()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
/* Init */
|
||||
@@ -680,6 +727,8 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
*/
|
||||
protected function severity()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$request = Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
@@ -709,6 +758,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
protected function noSev()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'requests_block_sev' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -734,6 +784,8 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
*/
|
||||
protected function staffLock()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$request = Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
@@ -758,6 +810,8 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
*/
|
||||
protected function department()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$request = Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
@@ -809,6 +863,8 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
*/
|
||||
protected function staff()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$request = Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
@@ -839,6 +895,8 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
*/
|
||||
protected function track()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$request = Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
@@ -884,7 +942,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$form = new \IPS\Helpers\Form;
|
||||
|
||||
$parentContacts = \IPS\nexus\Customer::load( $request->author()->member_id )->parentContacts();
|
||||
if ( count( $parentContacts ) )
|
||||
if ( \count( $parentContacts ) )
|
||||
{
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$options = array();
|
||||
@@ -932,7 +990,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
\IPS\Output::i()->redirect( $request->acpUrl() );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core', 'front' ) ), 'popupTemplate' ) );
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core', 'front' ), 'popupTemplate' ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
@@ -948,6 +1006,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
protected function merge()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'requests_merge' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1171,4 +1230,4 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
}
|
||||
return $defaultAction;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user