Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -188,6 +188,20 @@ class _Department extends \IPS\Node\Model
|
||||
{
|
||||
return !( $node instanceof \IPS\nexus\Package\Group );
|
||||
} ) ) );
|
||||
|
||||
if ( \IPS\Settings::i()->nexus_subs_enabled )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'dpt_subscriptions', $this->subscriptions ? array_filter( array_map( function ( $val ) {
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Subscription\Package::load( $val );
|
||||
} catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}, explode( ',', $this->subscriptions ) ) ) : 0, FALSE, array('zeroVal' => 'do_not_associate_sub_requests', 'multiple' => TRUE, 'class' => 'IPS\nexus\Subscription\Package', 'zeroValTogglesOff' => array('dpt_require_package') ) ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'dpt_require_package', $this->require_package, FALSE, array(), NULL, NULL, NULL, 'dpt_require_package' ) );
|
||||
|
||||
$form->addHeader( 'department_staff' );
|
||||
@@ -203,7 +217,7 @@ class _Department extends \IPS\Node\Model
|
||||
$admins[ 'dpt_staff_member' ][ 'm' . $row['row_id'] ] = \IPS\Member::load( $row['row_id'] )->name;
|
||||
}
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'dpt_staff', ( $this->id and $this->staff !== '*' ) ? explode( ',', $this->staff ) : '*', TRUE, array( 'options' => $admins, 'multiple' => TRUE, 'unlimited' => '*' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'dpt_staff', ( $this->id and $this->staff !== '*' ) ? explode( ',', $this->staff ) : '*', TRUE, array( 'options' => $admins, 'multiple' => TRUE, 'unlimited' => '*', 'parse' => 'normal' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,6 +269,15 @@ class _Department extends \IPS\Node\Model
|
||||
}, array_keys( $values['dpt_packages'] ) ) ) : 0;
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'dpt_subscriptions', $values ) )
|
||||
{
|
||||
$values['dpt_subscriptions'] = is_array( $values['dpt_subscriptions'] ) ? implode( ',', array_keys( $values['dpt_subscriptions'] ) ) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$values['dpt_subscriptions'] = 0;
|
||||
}
|
||||
|
||||
if ( ( array_key_exists( 'dpt_require_package', $values ) AND is_null( $values['dpt_require_package'] ) ) or $values['dpt_packages'] == 0 )
|
||||
{
|
||||
$values['dpt_require_package'] = 0;
|
||||
@@ -393,11 +416,12 @@ class _Department extends \IPS\Node\Model
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string name Name
|
||||
*/
|
||||
public function apiOutput()
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
return array(
|
||||
'id' => $this->_id,
|
||||
|
||||
@@ -253,6 +253,69 @@ class _Reply extends \IPS\Content\Comment implements \IPS\Content\Hideable
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comments based on some arbitrary parameters
|
||||
*
|
||||
* @param array $where Where clause
|
||||
* @param string $order MySQL ORDER BY clause (NULL to order by date)
|
||||
* @param int|array $limit Limit clause
|
||||
* @param string|NULL $permissionKey A key which has a value in the permission map (either of the container or of this class) matching a column ID in core_permission_index, or NULL to ignore permissions
|
||||
* @param mixed $includeHiddenComments Include hidden comments? NULL to detect if currently logged in member has permission, -1 to return public content only, TRUE to return unapproved content and FALSE to only return unapproved content the viewing member submitted
|
||||
* @param int $queryFlags Select bitwise flags
|
||||
* @param \IPS\Member $member The member (NULL to use currently logged in member)
|
||||
* @param bool $joinContainer If true, will join container data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $joinComments If true, will join comment data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $joinReviews If true, will join review data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $countOnly If true will return the count
|
||||
* @param array|null $joins Additional arbitrary joins for the query
|
||||
* @return array|NULL|\IPS\Content\Comment If $limit is 1, will return \IPS\Content\Comment or NULL for no results. For any other number, will return an array.
|
||||
*/
|
||||
public static function getItemsWithPermission( $where=array(), $order=NULL, $limit=10, $permissionKey='read', $includeHiddenComments=\IPS\Content\Hideable::FILTER_AUTOMATIC, $queryFlags=0, \IPS\Member $member=NULL, $joinContainer=FALSE, $joinComments=FALSE, $joinReviews=FALSE, $countOnly=FALSE, $joins=NULL )
|
||||
{
|
||||
/* Get customer object */
|
||||
if ( !$member )
|
||||
{
|
||||
$member = \IPS\nexus\Customer::loggedIn();
|
||||
}
|
||||
elseif ( !( $member instanceof \IPS\nexus\Customer ) )
|
||||
{
|
||||
$member = \IPS\nexus\Customer::load( $member->member_id );
|
||||
}
|
||||
$extraClause = array( 'r_member=?', $member->member_id );
|
||||
|
||||
/* Work out the clause for parent alternative contacts */
|
||||
$alternativeContactWhere = array();
|
||||
foreach ( $member->parentContacts() as $contact )
|
||||
{
|
||||
if ( $contact->support )
|
||||
{
|
||||
$alternativeContactWhere[] = '( r_member=' . $contact->main_id->member_id . ' )';
|
||||
}
|
||||
else
|
||||
{
|
||||
$alternativeContactWhere[] = '( r_member=' . $contact->main_id->member_id . ' AND ' . \IPS\Db::i()->in( 'r_purchase', $contact->purchaseIds() ) . ' )';
|
||||
}
|
||||
}
|
||||
if ( count( $alternativeContactWhere ) )
|
||||
{
|
||||
$extraClause[0] = '( ' . $extraClause[0] . ' OR ( ' . implode( ' OR ', $alternativeContactWhere ) . ' ) )';
|
||||
}
|
||||
|
||||
/* Work out the clause for admins */
|
||||
if ( ( !\IPS\Dispatcher::hasInstance() or \IPS\Dispatcher::i()->controllerLocation === 'admin' ) and $member->isAdmin() )
|
||||
{
|
||||
$extraClause[0] = '( ' . $extraClause[0] . " OR dpt_staff='*' OR " . \IPS\Db::i()->findInSet( 'dpt_staff', Department::staffDepartmentPerms( $member ) ) . ' )';
|
||||
$joins[] = array(
|
||||
'from' => 'nexus_support_departments',
|
||||
'where' => 'dpt_id=r_department'
|
||||
);
|
||||
}
|
||||
|
||||
/* Do it */
|
||||
$where[] = $extraClause;
|
||||
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenComments, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins );
|
||||
}
|
||||
|
||||
/**
|
||||
* Send if it's pending
|
||||
*
|
||||
@@ -263,6 +326,7 @@ class _Reply extends \IPS\Content\Comment implements \IPS\Content\Hideable
|
||||
if ( $this->type === static::REPLY_PENDING )
|
||||
{
|
||||
$this->type = static::REPLY_STAFF;
|
||||
$this->hidden = 0;
|
||||
$this->save();
|
||||
|
||||
$defaultRecipients = $this->item()->getDefaultRecipients();
|
||||
|
||||
@@ -425,14 +425,14 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
}
|
||||
if ( count( $purchaseWhere ) )
|
||||
{
|
||||
$purchaseWhere = array( array( "ps_member={$account->member_id} OR ( " . implode( ' OR ', $purchaseWhere ) . ' )' ) );
|
||||
$purchaseWhere = array( array( "( ps_member={$account->member_id} OR ( " . implode( ' OR ', $purchaseWhere ) . ' ) )' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$purchaseWhere = array( array( 'ps_member=?', $account->member_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Basic elements */
|
||||
$return = parent::formElements( $item, $container );
|
||||
$content = $return['content'];
|
||||
@@ -458,6 +458,27 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
|
||||
$availableDepartments[ $department->id ] = $department;
|
||||
}
|
||||
|
||||
if ( \IPS\Settings::i()->nexus_subs_enabled )
|
||||
{
|
||||
foreach ( Department::roots( NULL, NULL, 'dpt_open=1' ) as $department )
|
||||
{
|
||||
if ( !\IPS\nexus\Customer::loggedIn()->member_id or !count( \IPS\Db::i()->select( '*', 'nexus_purchases', array_merge( $purchaseWhere, array(array('ps_app=? AND ps_type=?', 'nexus', 'subscription')), array(\IPS\Db::i()->in( 'ps_item_id', explode( ',', $department->subscriptions ) ) ) ) ) ) )
|
||||
{
|
||||
if ( $department->require_package )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$doNotShowPurchasesForDepartments[] = $department->id;
|
||||
}
|
||||
}
|
||||
|
||||
$availableDepartments[$department->id] = $department;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !count( $availableDepartments ) )
|
||||
{
|
||||
\IPS\Output::i()->error( \IPS\nexus\Customer::loggedIn()->member_id ? 'no_module_permission' : 'no_module_permission_guest', '1X248/1', 403, 'no_support_departments' );
|
||||
@@ -510,6 +531,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
if ( $department->packages and !in_array( $department->id, $doNotShowPurchasesForDepartments ) )
|
||||
{
|
||||
$allowedPackageIds = explode( ',', $department->packages );
|
||||
$allowedSubscriptionIds = explode( ',', $department->subscriptions );
|
||||
$allowedPackages = $department->serializedPackageIds();
|
||||
$departmentToggles[ $department->id ][] = 'support_purchase_' . $allowedPackages;
|
||||
if ( !isset( $purchaseFields[ $allowedPackages ] ) )
|
||||
@@ -521,9 +543,12 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
array(
|
||||
'class' => 'IPS\nexus\Purchase',
|
||||
'where' => $purchaseWhere,
|
||||
'permissionCheck' => function( $node ) use ( $allowedPackageIds )
|
||||
'permissionCheck' => function( $node ) use ( $allowedPackageIds, $allowedSubscriptionIds )
|
||||
{
|
||||
return $node->active and $node->app === 'nexus' and $node->type === 'package' and in_array( $node->item_id, $allowedPackageIds );
|
||||
return (
|
||||
( $node->active and $node->app === 'nexus' and ( $node->type === 'package' and in_array( $node->item_id, $allowedPackageIds ) ) )
|
||||
or ( $node->active and $node->app === 'nexus' and ( $node->type === 'subscription' and in_array( $node->item_id, $allowedSubscriptionIds ) ) )
|
||||
);
|
||||
},
|
||||
'forceOwner' => FALSE,
|
||||
'zeroVal' => $department->require_package ? NULL : 'support_purchase_none',
|
||||
@@ -580,7 +605,15 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
}
|
||||
|
||||
/* Add department */
|
||||
$return['department'] = new \IPS\Helpers\Form\Select( 'support_department', isset( \IPS\Request::i()->department ) ? intval( \IPS\Request::i()->department ) : NULL, TRUE, array( 'options' => $departments, 'toggles' => $departmentToggles ) );
|
||||
if ( !empty( $ppiDepartments ) and count( $departments ) == count( $ppiDepartments ) )
|
||||
{
|
||||
$departmentFieldOptions = array( 'options' => array_merge( array( 0 => 'support_department' ), $departments ), 'toggles' => array_merge( array( 0 => array( static::$formLangPrefix . 'content_editor' ) ), $departmentToggles ), 'disabled' => array( 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$departmentFieldOptions = array( 'options' => $departments, 'toggles' => $departmentToggles );
|
||||
}
|
||||
$return['department'] = new \IPS\Helpers\Form\Select( 'support_department', isset( \IPS\Request::i()->department ) ? intval( \IPS\Request::i()->department ) : NULL, TRUE, $departmentFieldOptions );
|
||||
foreach ( $availableDepartments as $department )
|
||||
{
|
||||
if ( \IPS\Member::loggedIn()->language()->checkKeyExists("nexus_department_{$department->id}_desc") )
|
||||
@@ -633,7 +666,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
{
|
||||
try
|
||||
{
|
||||
$purchase = \IPS\nexus\Purchase::constructFromData( \IPS\Db::i()->select( '*', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'ppi', $department->id ) )->first() );
|
||||
$purchase = \IPS\nexus\Purchase::constructFromData( \IPS\Db::i()->select( '*', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_item_id=? AND ps_member=?', 'nexus', 'ppi', $department->id, \IPS\Member::loggedIn()->member_id ) )->first() );
|
||||
$this->ppi_invoice = $purchase->original_invoice;
|
||||
$purchase->delete();
|
||||
}
|
||||
@@ -739,7 +772,14 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
{
|
||||
$k = mb_substr( $k, 13 );
|
||||
$class = $customFieldObjects[ $k ]->buildHelper();
|
||||
$cfields[ $k ] = $class::stringValue( $v );
|
||||
if ( $class instanceof \IPS\Helpers\Form\Upload )
|
||||
{
|
||||
$cfields[ $k ] = (string) $v;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cfields[ $k ] = $class::stringValue( $v );
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->cfields = $cfields;
|
||||
@@ -855,7 +895,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'note', NULL, TRUE, array( 'app' => 'nexus', 'key' => 'Support', 'minimize' => 'keyboard_shortcut_note', 'autoSaveKey' => "req{$this->id}-note" ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'department', $this->department->id, FALSE, array( 'options' => \IPS\nexus\Support\Department::rootsAsArray() ), NULL, NULL, NULL, 'staffNoteDepartment' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'status', $this->status->id, FALSE, array( 'options' => \IPS\nexus\Support\Status::rootsAsArray() ), NULL, NULL, NULL, 'staffNoteStatus' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'assign_to', $this->staff ? $this->staff->member_id : 0, FALSE, array( 'options' => array( 0 => 'unassigned' ) + static::staff() ), NULL, NULL, NULL, 'staffNoteAssign' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'assign_to', $this->staff ? $this->staff->member_id : 0, FALSE, array( 'parse' => 'normal', 'options' => array( 0 => \IPS\Member::loggedIn()->language()->addToStack('unassigned') ) + static::staff() ), NULL, NULL, NULL, 'staffNoteAssign' ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
@@ -873,11 +913,18 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
\IPS\File::claimAttachments( "req{$this->id}-note", $this->id, $message->id );
|
||||
|
||||
/* Update the request */
|
||||
$goToList = FALSE;
|
||||
$newDepartment = Department::load( $values['department'] );
|
||||
if ( $this->department != $newDepartment )
|
||||
{
|
||||
$this->log( 'department', $this->department, $newDepartment );
|
||||
$this->department = $newDepartment;
|
||||
|
||||
/* If we're adding a note and sending the request to a department we do not have access to, we should redirect to the support request list with a flash message explaining what happened */
|
||||
if ( !array_key_exists( $values['department'], iterator_to_array( \IPS\nexus\Support\Department::departmentsWithPermission() ) ) )
|
||||
{
|
||||
$goToList = TRUE;
|
||||
}
|
||||
}
|
||||
$newStatus = Status::load( $values['status'] );
|
||||
if ( $this->status != $newStatus )
|
||||
@@ -896,7 +943,14 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
$message->sendNotifications();
|
||||
|
||||
/* Redirect */
|
||||
$this->_staffFormRedirect( FALSE, TRUE );
|
||||
if ( $goToList )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal("app=nexus&module=support&controller=requests"), \IPS\Member::loggedIn()->language()->addToStack( 'note_added_sent_to', NULL, array( 'sprintf' => $newDepartment->_title ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_staffFormRedirect( FALSE, TRUE );
|
||||
}
|
||||
}
|
||||
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'support', 'nexus' ) ), 'noteForm' ), $this );
|
||||
}
|
||||
@@ -924,8 +978,8 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
/* To/Cc/Bcc */
|
||||
$defaultRecipients = $this->getDefaultRecipients();
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'to', $defaultRecipients['to'], FALSE, array( 'disabled' => TRUE ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'cc', $defaultRecipients['cc'], FALSE, array( 'autocomplete' => array( 'unique' => TRUE, 'forceLower' => TRUE ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'bcc', $defaultRecipients['bcc'], FALSE, array( 'autocomplete' => array( 'unique' => TRUE, 'forceLower' => TRUE ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'cc', $defaultRecipients['cc'], FALSE, array( 'autocomplete' => array( 'minimized' => FALSE, 'unique' => TRUE, 'forceLower' => TRUE ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'bcc', $defaultRecipients['bcc'], FALSE, array( 'autocomplete' => array( 'minimized' => FALSE, 'unique' => TRUE, 'forceLower' => TRUE ) ) ) );
|
||||
|
||||
/* Do we have default content? */
|
||||
try
|
||||
@@ -956,7 +1010,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'message', $defaultContent, TRUE, array( 'app' => 'nexus', 'key' => 'Support', 'minimize' => 'keyboard_shortcut_reply', 'autoSaveKey' => "req{$this->id}-reply", 'defaultIfNoAutoSave' => TRUE, 'minimizeWithContent' => TRUE ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'department', $this->department->id, FALSE, array( 'options' => \IPS\nexus\Support\Department::rootsAsArray() ), NULL, NULL, NULL, 'staffReplyDepartment' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'status', \IPS\nexus\Support\Status::load( TRUE, 'status_default_staff' )->id, FALSE, array( 'options' => \IPS\nexus\Support\Status::rootsAsArray() ), NULL, NULL, NULL, 'staffReplyStatus' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'assign_to', $this->staff_lock ? ( $this->staff ? $this->staff->member_id : 0 ) : 0, FALSE, array( 'options' => array( 0 => 'unassigned' ) + static::staff() ), NULL, NULL, NULL, 'staffReplyAssign' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'assign_to', $this->staff_lock ? ( $this->staff ? $this->staff->member_id : 0 ) : 0, FALSE, array( 'parse' => 'normal', 'options' => array( 0 => \IPS\Member::loggedIn()->language()->addToStack('unassigned') ) + static::staff() ), NULL, NULL, NULL, 'staffReplyAssign' ) );
|
||||
|
||||
/* Handle Submissions */
|
||||
if ( $values = $form->values() )
|
||||
@@ -1269,11 +1323,12 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
/**
|
||||
* Get comment page count in ACP (which includes hidden notes)
|
||||
*
|
||||
* @param bool $recache TRUE to recache the value
|
||||
* @return int
|
||||
*/
|
||||
public function commentPageCountIncludingNotes()
|
||||
public function commentPageCountIncludingNotes( $recache=FALSE )
|
||||
{
|
||||
if ( $this->commentPageCountIncludingNotes === NULL )
|
||||
if ( $this->commentPageCountIncludingNotes === NULL OR $recache === TRUE )
|
||||
{
|
||||
$this->commentPageCountIncludingNotes = ceil( \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_replies', array( 'reply_request=?', $this->id ) )->first() / $this->getCommentsPerPage() );
|
||||
|
||||
@@ -1285,6 +1340,24 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
return $this->commentPageCountIncludingNotes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment page count
|
||||
*
|
||||
* @param bool $recache TRUE to recache the value
|
||||
* @return int
|
||||
*/
|
||||
public function commentPageCount( $recache=FALSE )
|
||||
{
|
||||
if ( \IPS\Dispatcher::hasInstance() AND \IPS\Dispatcher::i()->controllerLocation === 'admin' AND static::canViewHiddenComments() )
|
||||
{
|
||||
return $this->commentPageCountIncludingNotes( $recache );
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::commentPageCount( $recache );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should new comments be moderated?
|
||||
*
|
||||
@@ -1702,36 +1775,37 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string title Title
|
||||
* @apiresponse \IPS\Member member If the support request was created by a member, the member object
|
||||
* @apiresponse string email If the support request was created by an email which does not belong to a member, that email address
|
||||
* @apiresponse \IPS\nexus\Support\Status status Status
|
||||
* @apiresponse \IPS\nexus\Support\Department department Department
|
||||
* @apiresponse \IPS\nexus\Support\Severity severity Severity
|
||||
* @apiresponse \IPS\Member staff Assigned staff member
|
||||
* @apiresponse \IPS\nexus\Purchase purchase Associated purchase
|
||||
* @apiresponse \IPS\nexus\Invoice ppiInvoice If this is a pay-per-incident support request, the associated invoice
|
||||
* @apiresponse int replies Number of replies
|
||||
* @apiresponse \IPS\nexus\Support\Reply firstMessage The first message
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string title Title
|
||||
* @apiresponse \IPS\Member member If the support request was created by a member, the member object
|
||||
* @apiresponse string email If the support request was created by an email which does not belong to a member, that email address
|
||||
* @apiresponse \IPS\nexus\Support\Status status Status
|
||||
* @apiresponse \IPS\nexus\Support\Department department Department
|
||||
* @apiresponse \IPS\nexus\Support\Severity severity Severity
|
||||
* @clientapiresponse \IPS\Member staff Assigned staff member
|
||||
* @apiresponse \IPS\nexus\Purchase purchase Associated purchase
|
||||
* @apiresponse \IPS\nexus\Invoice ppiInvoice If this is a pay-per-incident support request, the associated invoice
|
||||
* @apiresponse int replies Number of replies
|
||||
* @apiresponse \IPS\nexus\Support\Reply firstMessage The first message
|
||||
*/
|
||||
public function apiOutput()
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
$firstMessage = $this->comments( 1, 0, 'date', 'asc' );
|
||||
return array(
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'member' => $this->member ? \IPS\Member::load( $this->member )->apiOutput() : null,
|
||||
'member' => $this->member ? \IPS\Member::load( $this->member )->apiOutput( $authorizedMember ) : null,
|
||||
'email' => $this->email ?: null,
|
||||
'status' => $this->status->apiOutput(),
|
||||
'department' => $this->department->apiOutput(),
|
||||
'severity' => $this->severity ? $this->severity->apiOutput() : null,
|
||||
'staff' => $this->staff ? $this->staff->apiOutput() : null,
|
||||
'purchase' => $this->purchase ? $this->purchase->apiOutput() : null,
|
||||
'ppiInvoice' => $this->ppi_invoice ? $this->ppi_invoice->apiOutput() : null,
|
||||
'status' => $this->status->apiOutput( $authorizedMember ),
|
||||
'department' => $this->department->apiOutput( $authorizedMember ),
|
||||
'severity' => $this->severity ? $this->severity->apiOutput( $authorizedMember ) : null,
|
||||
'staff' => $this->staff ? $this->staff->apiOutput( $authorizedMember ) : null,
|
||||
'purchase' => $this->purchase ? $this->purchase->apiOutput( $authorizedMember ) : null,
|
||||
'ppiInvoice' => $this->ppi_invoice ? $this->ppi_invoice->apiOutput( $authorizedMember ) : null,
|
||||
'replies' => $this->replies,
|
||||
'firstMessage' => $firstMessage->apiOutput()
|
||||
'firstMessage' => $firstMessage->apiOutput( $authorizedMember )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -237,11 +237,12 @@ class _Severity extends \IPS\Node\Model
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string name Name
|
||||
*/
|
||||
public function apiOutput()
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
return array(
|
||||
'id' => $this->_id,
|
||||
|
||||
@@ -326,11 +326,12 @@ class _Status extends \IPS\Node\Model
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string name Name
|
||||
*/
|
||||
public function apiOutput()
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
return array(
|
||||
'id' => $this->_id,
|
||||
|
||||
@@ -182,7 +182,7 @@ class _StockAction extends \IPS\Node\Model
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'action_name', NULL, TRUE, array( 'app' => 'nexus', 'key' => ( $this->id ? "nexus_stockaction_{$this->id}" : NULL ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'action_status', $this->status ?: 0, FALSE, array( 'class' => 'IPS\nexus\Support\Status', 'zeroVal' => 'do_not_change' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'action_department', $this->department ?: 0, FALSE, array( 'class' => 'IPS\nexus\Support\Department', 'zeroVal' => 'do_not_move' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'action_staff', $this->staff ? $this->staff->member_id : 0, FALSE, array( 'options' => array_merge( array( 0 => 'do_not_change' ), \IPS\nexus\Support\Request::staff() ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'action_staff', $this->staff ? $this->staff->member_id : 0, FALSE, array( 'parse' => 'normal', 'options' => array_merge( array( 0 => 'do_not_change' ), \IPS\nexus\Support\Request::staff() ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'action_message_on', $this->message, FALSE, array( 'togglesOn' => array( 'action_message_editor' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'action_message', $this->message, FALSE, array( 'app' => 'nexus', 'key' => 'Support', 'autoSaveKey' => md5( 'stockaction-' . ( $this->id ?: 'new' ) ) ), NULL, NULL, NULL, 'action_message_editor' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'action_show_in', ( !$this->show_in or $this->show_in === '*' ) ? 0 : explode( ',', $this->show_in ), FALSE, array( 'class' => 'IPS\nexus\Support\Department', 'zeroVal' => 'all', 'multiple' => TRUE ) ) );
|
||||
|
||||
@@ -160,7 +160,7 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
public static function customer( \IPS\nexus\Customer $customer )
|
||||
{
|
||||
$return = new static;
|
||||
$return->title = \IPS\Member::loggedIn()->language()->addToStack( 'members_support_requests', FALSE, array( 'sprintf' => array( $customer->cm_name ) ) );
|
||||
$return->title = sprintf( \IPS\Member::loggedIn()->language()->get( 'members_support_requests' ), $customer->cm_name );
|
||||
$return->departments = NULL;
|
||||
$return->statuses = NULL;
|
||||
$return->severities = NULL;
|
||||
@@ -406,7 +406,8 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
/* Search term */
|
||||
if ( $this->search_term )
|
||||
{
|
||||
$where[] = array( 'r_id IN(?)', \IPS\Db::i()->select( 'reply_request', 'nexus_support_replies', array( "MATCH(reply_post) AGAINST (? IN BOOLEAN MODE)", $this->search_term ) ) );
|
||||
$subQuery= \IPS\Content\Search\Mysql\Query::matchClause('reply_post', $this->search_term);
|
||||
$where[] = array( 'r_id IN(?)', \IPS\Db::i()->select( 'reply_request', 'nexus_support_replies', $subQuery ) );
|
||||
}
|
||||
|
||||
/* Tracked? */
|
||||
@@ -451,15 +452,8 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
if ( mb_strpos( $order, 'dpt_position' ) !== FALSE )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( 'staff_id', 'nexus_support_staff_dpt_order', array( 'staff_id=?', $member->member_id ), NULL, 1 )->first();
|
||||
$query->join( 'nexus_support_staff_dpt_order', 'nexus_support_staff_dpt_order.department_id=r_department AND nexus_support_staff_dpt_order.staff_id=' . $member->member_id );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
$query->join( 'nexus_support_departments', 'dpt_id=r_department' );
|
||||
}
|
||||
$query->join( 'nexus_support_staff_dpt_order', 'nexus_support_staff_dpt_order.department_id=r_department AND nexus_support_staff_dpt_order.staff_id=' . $member->member_id );
|
||||
$query->join( 'nexus_support_departments', 'dpt_id=r_department' );
|
||||
}
|
||||
if ( mb_strpos( $order, 'sev_position' ) !== FALSE )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user