Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Support Request View
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 09 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -123,7 +123,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
/* Setting Order? */
|
||||
if ( isset( \IPS\Request::i()->order ) )
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'support_order', \IPS\Request::i()->order, \IPS\DateTime::create()->add( new \DateInterval('P1Y') ) );
|
||||
\IPS\Request::i()->setCookie( 'support_replies_order', \IPS\Request::i()->order, \IPS\DateTime::create()->add( new \DateInterval('P1Y') ) );
|
||||
}
|
||||
|
||||
/* Views */
|
||||
@@ -146,21 +146,24 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
'title' => $this->request->status->_title,
|
||||
'menu' => array(),
|
||||
'menuClass' => 'ipsMenu_selectable ipsMenu_narrow',
|
||||
'data' => array( 'controller' => 'nexus.admin.support.metamenu' )
|
||||
'data' => array( 'role' => 'statusMenu', 'controller' => 'nexus.admin.support.metamenu' ),
|
||||
'tooltip' => \IPS\Member::loggedIn()->language()->addToStack('keyboard_shortcut_status')
|
||||
),
|
||||
'severity' => array(
|
||||
'icon' => 'exclamation',
|
||||
'title' => $this->request->severity->_title,
|
||||
'menu' => array(),
|
||||
'menuClass' => 'ipsMenu_selectable',
|
||||
'data' => array( 'controller' => 'nexus.admin.support.metamenu' )
|
||||
'data' => array( 'role' => 'severityMenu', 'controller' => 'nexus.admin.support.metamenu' ),
|
||||
'tooltip' => \IPS\Member::loggedIn()->language()->addToStack('keyboard_shortcut_severity')
|
||||
),
|
||||
'department' => array(
|
||||
'icon' => 'folder',
|
||||
'title' => $this->request->department->_title,
|
||||
'menu' => array(),
|
||||
'menuClass' => 'ipsMenu_selectable ipsMenu_narrow',
|
||||
'data' => array( 'controller' => 'nexus.admin.support.metamenu' )
|
||||
'data' => array( 'role' => 'departmentMenu', 'controller' => 'nexus.admin.support.metamenu' ),
|
||||
'tooltip' => \IPS\Member::loggedIn()->language()->addToStack('keyboard_shortcut_department')
|
||||
),
|
||||
'staff' => array(
|
||||
'icon' => 'user',
|
||||
@@ -168,9 +171,17 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
'menu' => array(),
|
||||
'menuClass' => 'ipsMenu_selectable',
|
||||
'data' => array( 'controller' => 'nexus.admin.support.metamenu', 'role' => 'staffMenu' ),
|
||||
'tooltip' => \IPS\Member::loggedIn()->language()->addToStack('keyboard_shortcut_staff')
|
||||
),
|
||||
'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')
|
||||
),
|
||||
'track' => array(
|
||||
'icon' => 'star',
|
||||
'icon' => 'bookmark',
|
||||
'title' => $trackLang,
|
||||
'menu' => array(
|
||||
array(
|
||||
@@ -190,7 +201,8 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
)
|
||||
),
|
||||
'menuClass' => 'ipsMenu_selectable',
|
||||
'data' => array( 'controller' => 'nexus.admin.support.metamenu' )
|
||||
'data' => array( 'role' => 'trackMenu', 'controller' => 'nexus.admin.support.metamenu' ),
|
||||
'tooltip' => \IPS\Member::loggedIn()->language()->addToStack('keyboard_shortcut_tracking')
|
||||
)
|
||||
);
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'support', 'requests_delete' ) )
|
||||
@@ -289,8 +301,10 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
);
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'request_x', FALSE, array( 'sprintf' => "#{$this->request->id}" ) );
|
||||
\IPS\Output::i()->title = "#{$this->request->id} " . $this->request->mapped('title');
|
||||
\IPS\Output::i()->showTitle = FALSE;
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_support.js', 'nexus', 'admin' ) );
|
||||
\IPS\Output::i()->globalControllers[] = 'nexus.admin.support.request';
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'support.css', 'nexus', 'admin' ) );
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
@@ -298,6 +312,175 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hovercard
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function hovercard()
|
||||
{
|
||||
/* Load request */
|
||||
try
|
||||
{
|
||||
$request = \IPS\nexus\Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X208/K', 404, '' );
|
||||
}
|
||||
|
||||
/* Start with the first message */
|
||||
$overview = array( 'firstMessage' => array( 'support_first_message', $request->comments( 1, 0, 'date', 'asc', NULL, FALSE ) ) );
|
||||
|
||||
/* Add the last customer reply */
|
||||
if ( $request->last_reply != $request->started )
|
||||
{
|
||||
if ( $latestPost = $request->comments( 1, 0, 'date', 'desc', NULL, FALSE, NULL, array( '( reply_type=? OR reply_type=? OR reply_type=? )', \IPS\nexus\Support\Reply::REPLY_MEMBER, \IPS\nexus\Support\Reply::REPLY_ALTCONTACT, \IPS\nexus\Support\Reply::REPLY_EMAIL ) ) )
|
||||
{
|
||||
$overview['lastCustomerReply'] = array( 'support_last_customer_reply', $latestPost );
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the last staff reply */
|
||||
if ( $request->last_staff_reply )
|
||||
{
|
||||
if ( $latestStaffReply = $request->comments( 1, 0, 'date', 'desc', NULL, FALSE, NULL, array( 'reply_type=?', \IPS\nexus\Support\Reply::REPLY_STAFF ) ) )
|
||||
{
|
||||
$overview['lastStaffReply'] = array( 'support_last_staff_reply', $latestStaffReply );
|
||||
}
|
||||
}
|
||||
|
||||
/* And the latest note */
|
||||
if ( $latestNote = $request->comments( 1, 0, 'date', 'desc', NULL, NULL, NULL, array( 'reply_type=?', \IPS\nexus\Support\Reply::REPLY_HIDDEN ) ) )
|
||||
{
|
||||
$overview['lastNote'] = array( 'support_last_note', $latestNote );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'support' )->requestHover( $request, $overview ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Go to first unread
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getNewComment()
|
||||
{
|
||||
/* Load request */
|
||||
try
|
||||
{
|
||||
$request = \IPS\nexus\Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X208/L', 404, '' );
|
||||
}
|
||||
|
||||
/* What order are we viewing? */
|
||||
$order = isset( \IPS\Request::i()->cookie['support_replies_order'] ) ? mb_strtolower( \IPS\Request::i()->cookie['support_replies_order'] ) : 'desc';
|
||||
|
||||
/* Have we read it before? */
|
||||
$timeLastRead = $request->timeLastRead();
|
||||
if ( $timeLastRead instanceof \IPS\DateTime )
|
||||
{
|
||||
if( $unreadComment = $request->comments( 1, NULL, 'date', 'asc', NULL, NULL, $timeLastRead ) )
|
||||
{
|
||||
$where = array( array( 'reply_request=?', $request->id ) );
|
||||
|
||||
if ( $order === 'desc' )
|
||||
{
|
||||
$where[] = array( 'reply_id>?', $unreadComment->id );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( 'reply_id<?', $unreadComment->id );
|
||||
}
|
||||
|
||||
$commentPosition = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_replies', $where )->first();
|
||||
|
||||
$url = $request->acpUrl();
|
||||
$page = ceil( $commentPosition / \IPS\nexus\Support\Request::getCommentsPerPage() );
|
||||
if ( $page != 1 )
|
||||
{
|
||||
$url = $url->setQueryString( 'page', $page );
|
||||
}
|
||||
$url = $url->setFragment( "reply-{$unreadComment->id}" );
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $request->acpUrl() );
|
||||
}
|
||||
}
|
||||
/* Nope? Just go to the first message */
|
||||
else
|
||||
{
|
||||
$url = $request->acpUrl();
|
||||
|
||||
if ( $order === 'desc' )
|
||||
{
|
||||
$lastPage = $request->commentPageCount();
|
||||
if ( $lastPage != 1 )
|
||||
{
|
||||
$url = $url->setQueryString( 'page', $lastPage );
|
||||
}
|
||||
}
|
||||
|
||||
$firstMessage = $request->comments( 1, 0, 'date', 'asc', NULL, FALSE );
|
||||
$url = $url->setFragment( "reply-{$firstMessage->id}" );
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a Comment
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function findComment()
|
||||
{
|
||||
/* Load request and comment */
|
||||
try
|
||||
{
|
||||
$request = \IPS\nexus\Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
$comment = \IPS\nexus\Support\Reply::load( \IPS\Request::i()->comment );
|
||||
if ( $comment->request != $request->id )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X208/M', 404, '' );
|
||||
}
|
||||
|
||||
/* Find its position */
|
||||
$order = isset( \IPS\Request::i()->cookie['support_replies_order'] ) ? mb_strtolower( \IPS\Request::i()->cookie['support_replies_order'] ) : 'desc';
|
||||
$where = array( array( 'reply_request=?', $request->id ) );
|
||||
if ( $order === 'desc' )
|
||||
{
|
||||
$where[] = array( 'reply_id>?', $comment->id );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( 'reply_id<?', $comment->id );
|
||||
}
|
||||
$commentPosition = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_replies', $where )->first();
|
||||
|
||||
/* Redirect */
|
||||
$url = $request->acpUrl();
|
||||
$page = ceil( $commentPosition / \IPS\nexus\Support\Request::getCommentsPerPage() );
|
||||
if ( $page != 1 )
|
||||
{
|
||||
$url = $url->setQueryString( 'page', $page );
|
||||
}
|
||||
$url = $url->setFragment( "reply-{$comment->id}" );
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
|
||||
/**
|
||||
* Pending Response Send/Discard
|
||||
*
|
||||
@@ -318,7 +501,34 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$message->delete();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $message->item()->acpUrl()->setQueryString( array( 'filter' => \IPS\Request::i()->filter, 'sort' => \IPS\Request::i()->sort ) ) );
|
||||
if ( isset( \IPS\Request::i()->department ) and \IPS\Request::i()->department != -1 )
|
||||
{
|
||||
$newDepartment = Support\Department::load( \IPS\Request::i()->department );
|
||||
if ( $message->item()->department != $newDepartment )
|
||||
{
|
||||
$message->item()->log( 'department', $message->item()->department, $newDepartment );
|
||||
$message->item()->department = $newDepartment;
|
||||
}
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->status ) and \IPS\Request::i()->status != -1 )
|
||||
{
|
||||
$message->item()->status = Support\Status::load( \IPS\Request::i()->status );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->staff ) and \IPS\Request::i()->staff != -1 )
|
||||
{
|
||||
$newStaff = \IPS\Request::i()->staff ? \IPS\Member::load( \IPS\Request::i()->staff ) : NULL;
|
||||
if ( $message->item()->staff != $newStaff )
|
||||
{
|
||||
if ( $newStaff )
|
||||
{
|
||||
$message->item()->log( 'staff', $message->item()->staff, $newStaff );
|
||||
}
|
||||
$message->item()->staff = $newStaff;
|
||||
}
|
||||
}
|
||||
$message->item()->save();
|
||||
|
||||
\IPS\Output::i()->redirect( $message->item()->acpUrl() );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
@@ -403,7 +613,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
try
|
||||
{
|
||||
/* Init */
|
||||
$return = array();
|
||||
$return = array( 'note_status' => \IPS\Request::i()->status );
|
||||
$request = Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
$status = Support\Status::load( \IPS\Request::i()->status );
|
||||
$oldStatus = $request->status;
|
||||
@@ -418,12 +628,16 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
}
|
||||
$request->staff = \IPS\Member::loggedIn();
|
||||
$return['staff'] = array( 'id' => \IPS\Member::loggedIn()->member_id, 'name' => \IPS\Member::loggedIn()->name );
|
||||
$return['note_assign_to'] = \IPS\Member::loggedIn()->member_id;
|
||||
$return['staffBadge'] = \IPS\Member::loggedIn()->language()->addToStack( 'assigned_to_x', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack('you') ) ) );
|
||||
}
|
||||
/* Or set the previous status was "Working", release our assigning */
|
||||
elseif ( $oldStatus->assign and $request->staff )
|
||||
{
|
||||
$request->staff = NULL;
|
||||
$return['staff'] = array( 'id' => 0, 'name' => \IPS\Member::loggedIn()->language()->addToStack('unassigned') );
|
||||
$return['note_assign_to'] = 0;
|
||||
$return['staffBadge'] = '';
|
||||
}
|
||||
$request->save();
|
||||
|
||||
@@ -434,6 +648,7 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
}
|
||||
|
||||
/* Return */
|
||||
$return['statusBadge'] = \IPS\Theme::i()->getTemplate('support')->status( $request->status );
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( $return );
|
||||
@@ -465,7 +680,9 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$request->save();
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array() );
|
||||
$return = array();
|
||||
$return['severityBadge'] = $request->severity->color != '000' ? \IPS\Theme::i()->getTemplate('support')->severity( $request->severity ) : '';
|
||||
\IPS\Output::i()->json( $return );
|
||||
}
|
||||
\IPS\Output::i()->redirect( $request->acpUrl() );
|
||||
}
|
||||
@@ -548,7 +765,25 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$stockActions[ $action->id ] = $action->_title;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->json( array( 'department' => \IPS\Request::i()->department, 'stockActions' => $stockActions, 'requiresPurchase' => (bool) $request->department->require_package ) );
|
||||
$purchaseWarning = NULL;
|
||||
if ( $request->department->packages )
|
||||
{
|
||||
if ( !$request->purchase )
|
||||
{
|
||||
$purchaseWarning = 'purchaseWarningNone';
|
||||
}
|
||||
elseif ( !$request->purchase->active )
|
||||
{
|
||||
$purchaseWarning = 'purchaseWarningInactive';
|
||||
}
|
||||
|
||||
if ( $purchaseWarning )
|
||||
{
|
||||
$purchaseWarning .= ( $request->department->require_package ? 'Required' : 'Optional' );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->json( array( 'department' => \IPS\Request::i()->department, 'note_department' => \IPS\Request::i()->department, 'stockActions' => $stockActions, 'purchaseWarning' => $purchaseWarning ) );
|
||||
}
|
||||
\IPS\Output::i()->redirect( $request->acpUrl() );
|
||||
}
|
||||
@@ -574,7 +809,11 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$request->save();
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'assign_to' => ( $request->staff_lock ? ( $request->staff ? $request->staff->member_id : 0 ) : 0 ) ) );
|
||||
\IPS\Output::i()->json( array(
|
||||
'assign_to' => ( $request->staff_lock ? ( $request->staff ? $request->staff->member_id : 0 ) : 0 ),
|
||||
'note_assign_to' => $request->staff ? $request->staff->member_id : 0,
|
||||
'staffBadge' => $request->staff ? \IPS\Member::loggedIn()->language()->addToStack( 'assigned_to_x', FALSE, array( 'sprintf' => array( $request->staff->name ) ) ) : ''
|
||||
) );
|
||||
}
|
||||
\IPS\Output::i()->redirect( $request->acpUrl() );
|
||||
}
|
||||
@@ -634,12 +873,52 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
$request = Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class = 'ipsForm_vertical ipsForm_noLabels';
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'associated_purchase', $request->purchase, TRUE, array( 'class' => 'IPS\nexus\Purchase', 'forceOwner' => $request->author(), 'zeroVal' => 'none' ) ) );
|
||||
|
||||
$parentContacts = \IPS\nexus\Customer::load( $request->author()->member_id )->parentContacts();
|
||||
if ( count( $parentContacts ) )
|
||||
{
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$options = array();
|
||||
$toggles = array();
|
||||
foreach ( $parentContacts as $contact )
|
||||
{
|
||||
$options[ $contact->main_id->member_id ] = $contact->main_id->cm_name;
|
||||
$toggles[ $contact->main_id->member_id ] = array( 'associated_purchase_' . $contact->main_id->member_id );
|
||||
}
|
||||
$options[ $request->author()->member_id ] = $request->author()->name;
|
||||
$toggles[ $request->author()->member_id ] = array( 'associated_purchase_' . $request->author()->member_id );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'support_account', $request->author()->member_id, TRUE, array( 'options' => $options, 'toggles' => $toggles, 'parse' => 'none' ) ) );
|
||||
foreach ( $options as $memberId => $memberName )
|
||||
{
|
||||
$field = new \IPS\Helpers\Form\Node( 'associated_purchase_' . $memberId, $memberId == $request->author()->member_id ? $request->purchase : NULL, TRUE, array( 'class' => 'IPS\nexus\Purchase', 'forceOwner' => \IPS\Member::load( $memberId ), 'zeroVal' => 'none' ), NULL, NULL, NULL, 'associated_purchase_' . $memberId );
|
||||
$field->label = \IPS\Member::loggedIn()->language()->addToStack('associated_purchase');
|
||||
$form->add( $field );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->class = 'ipsForm_vertical ipsForm_noLabels';
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'associated_purchase', $request->purchase, TRUE, array( 'class' => 'IPS\nexus\Purchase', 'forceOwner' => $request->author(), 'zeroVal' => 'none' ) ) );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$request->log( 'purchase', $request->purchase, $values['associated_purchase'] ?: NULL );
|
||||
$request->purchase = $values['associated_purchase'] ?: NULL;
|
||||
if ( isset( $values['support_account'] ) )
|
||||
{
|
||||
if ( $values['support_account'] != $request->member )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_support_replies', array( 'reply_type' => \IPS\nexus\Support\Reply::REPLY_MEMBER ), array( 'reply_request=? AND reply_member=?', $request->id, $values['support_account'] ) );
|
||||
\IPS\Db::i()->update( 'nexus_support_replies', array( 'reply_type' => \IPS\nexus\Support\Reply::REPLY_ALTCONTACT ), array( 'reply_request=? AND reply_member=?', $request->id, $request->member ) );
|
||||
$request->member = $values['support_account'];
|
||||
}
|
||||
$request->log( 'purchase', $request->purchase, $values[ 'associated_purchase_' . $values['support_account'] ] ?: NULL );
|
||||
$request->purchase = $values[ 'associated_purchase_' . $values['support_account'] ] ?: NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$request->log( 'purchase', $request->purchase, $values['associated_purchase'] ?: NULL );
|
||||
$request->purchase = $values['associated_purchase'] ?: NULL;
|
||||
}
|
||||
$request->save();
|
||||
\IPS\Output::i()->redirect( $request->acpUrl() );
|
||||
}
|
||||
@@ -673,6 +952,114 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Multimod
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function multimod()
|
||||
{
|
||||
/* CSRF check */
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Load request */
|
||||
$request = Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
|
||||
/* Are we going to leave any messages in the request? */
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_replies', array( array( 'reply_request=? AND reply_hidden=0', $request->id ), \IPS\Db::i()->in( 'reply_id', array_keys( \IPS\Request::i()->multimod ), TRUE ) ) )->first();
|
||||
if ( !$count )
|
||||
{
|
||||
\IPS\Output::i()->error( 'can_not_multimod_all', '1X208/H', 403, '' );
|
||||
}
|
||||
|
||||
/* Splitting? */
|
||||
if ( \IPS\Request::i()->modaction === 'split' )
|
||||
{
|
||||
/* Permission check */
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'requests_split' );
|
||||
|
||||
/* Check we're not trying to split notes only */
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_replies', array( array( 'reply_hidden=0', $request->id ), \IPS\Db::i()->in( 'reply_id', array_keys( \IPS\Request::i()->multimod ) ) ) )->first();
|
||||
if ( !$count )
|
||||
{
|
||||
\IPS\Output::i()->error( 'can_not_split_notes_only', '1S208/J', 403, '' );
|
||||
}
|
||||
|
||||
/* Create form */
|
||||
$url = $request->acpUrl()->setQueryString( array( 'do' => 'multimod', 'modaction' => 'split', 'multimod' => \IPS\Request::i()->multimod ) )->csrf();
|
||||
$form = new \IPS\Helpers\Form( 'split_form', 'split', $url, array( 'data-controller' => 'nexus.admin.support.splitForm' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'support_title', sprintf( \IPS\Member::loggedIn()->language()->get( 'split_request_title' ), $request->title, $request->id ), TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'support_department', $request->department, TRUE, array( 'class' => 'IPS\nexus\Support\Department', 'url' => $url ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'r_status', $request->status, TRUE, array( 'class' => 'IPS\nexus\Support\Status', 'url' => $url ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'support_severity', $request->severity, TRUE, array( 'class' => 'IPS\nexus\Support\Severity', 'url' => $url ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'r_staff', $request->staff ? $request->staff->member_id : 0, FALSE, array( 'options' => array( 0 => 'unassigned' ) + \IPS\nexus\Support\Request::staff() ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$newRequest = new \IPS\nexus\Support\Request;
|
||||
$newRequest->title = $values['support_title'];
|
||||
$newRequest->member = $request->member;
|
||||
$newRequest->email = $request->email;
|
||||
$newRequest->department = $values['support_department'];
|
||||
if ( $request->purchase )
|
||||
{
|
||||
$newRequest->purchase = $request->purchase;
|
||||
}
|
||||
$newRequest->status = $values['r_status'];
|
||||
$newRequest->severity = $values['support_severity'];
|
||||
if ( $values['r_staff'] )
|
||||
{
|
||||
$newRequest->staff = \IPS\Member::load( $values['r_staff']);
|
||||
}
|
||||
$newRequest->cfields = $request->cfields;
|
||||
$newRequest->notify = $request->notify;
|
||||
$newRequest->save();
|
||||
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_support_replies', array( array( 'reply_request=?', $request->id ), \IPS\Db::i()->in( 'reply_id', array_keys( \IPS\Request::i()->multimod ) ) ) ), 'IPS\nexus\Support\Reply' ) as $comment )
|
||||
{
|
||||
$comment->move( $newRequest );
|
||||
}
|
||||
|
||||
$request->rebuildFirstAndLastCommentData();
|
||||
$newRequest->rebuildFirstAndLastCommentData();
|
||||
|
||||
|
||||
|
||||
$request->log( 'split_away', $request, $newRequest );
|
||||
$newRequest->log( 'split_new', $request, $newRequest );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'oldUrl' => (string) $request->acpUrl(), 'newUrl' => (string) $newRequest->acpUrl() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $newRequest->acpUrl() );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
/* Or deleting? */
|
||||
elseif ( \IPS\Request::i()->modaction === 'delete' )
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'requests_reply_delete' );
|
||||
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_support_replies', array( array( 'reply_request=?', $request->id ), \IPS\Db::i()->in( 'reply_id', array_keys( \IPS\Request::i()->multimod ) ) ) ), 'IPS\nexus\Support\Reply' ) as $comment )
|
||||
{
|
||||
$comment->delete();
|
||||
}
|
||||
|
||||
$request->rebuildFirstAndLastCommentData();
|
||||
|
||||
\IPS\Output::i()->redirect( $request->acpUrl() );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->error( 'generic_error', '3X208/I', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
@@ -682,9 +1069,13 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'requests_delete' );
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
|
||||
try
|
||||
{
|
||||
$request = Support\Request::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
\IPS\Session::i()->log( 'acplogs__deleted_request', array( $request->id => FALSE ) );
|
||||
$request->delete();
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=nexus&module=support&controller=requests" ) );
|
||||
}
|
||||
@@ -703,9 +1094,13 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'requests_reply_delete' );
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
|
||||
try
|
||||
{
|
||||
$reply = Support\Reply::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
\IPS\Session::i()->log( 'acplogs__deleted_reply', array( $reply->id => FALSE ) );
|
||||
$reply->delete();
|
||||
\IPS\Output::i()->redirect( $reply->item()->acpUrl() );
|
||||
}
|
||||
@@ -745,4 +1140,25 @@ class _request extends \IPS\nexus\modules\front\support\view
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'support' )->feedback( $rating );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default action
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function defaultReplyAction()
|
||||
{
|
||||
$defaultAction = NULL;
|
||||
try
|
||||
{
|
||||
$defaultAction = \IPS\Db::i()->select( 'action', 'nexus_support_staff_preferences', array( 'staff_id=?', \IPS\Member::loggedIn()->member_id ) )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e ) {}
|
||||
|
||||
if ( !$defaultAction )
|
||||
{
|
||||
$defaultAction = isset( \IPS\Request::i()->cookie['support_primary_action'] ) ? \IPS\Request::i()->cookie['support_primary_action'] : 'first';
|
||||
}
|
||||
return $defaultAction;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user