Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+162 -71
View File
@@ -12,7 +12,7 @@
namespace 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;
@@ -92,6 +92,11 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
* @brief Node Class
*/
public static $containerNodeClass = 'IPS\nexus\Support\Department';
/**
* @brief Check posts per day limits? Useful for things that use the content system, but aren't necessarily content themselves.
*/
public static $checkPostsPerDay = FALSE;
/* !Generic */
@@ -123,7 +128,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$members = array();
/* Get the members who are admins for being in an admin group */
if ( count( $administrators['g'] ) )
if ( \count( $administrators['g'] ) )
{
foreach ( \IPS\Db::i()->select( array( 'member_id', 'name' ), 'core_members', '( ' . \IPS\Db::i()->in( 'member_group_id', array_keys( $administrators['g'] ) ) . ' ) OR ( ' . \IPS\Db::i()->findInSet( 'mgroup_others', array_keys( $administrators['g'] ) ) . ' )' ) as $row )
{
@@ -164,9 +169,9 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
{
$num = mt_rand( 48, 122 );
}
while ( in_array( $num, array( 58, 59, 60, 61, 62, 63, 64, 91, 92, 93, 94, 95, 96 ) ) );
while ( \in_array( $num, array( 58, 59, 60, 61, 62, 63, 64, 91, 92, 93, 94, 95, 96 ) ) );
$emailKey .= chr( $num );
$emailKey .= \chr( $num );
}
$this->email_key = $emailKey;
@@ -189,7 +194,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Set department
*
* @param \IPS\nexus\Support\Department
* @param \IPS\nexus\Support\Department $department Department for request
* @return void
*/
public function set_department( Department $department )
@@ -217,7 +222,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Set purchase
*
* @param \IPS\nexus\Purchase
* @param \IPS\nexus\Purchase $purchase Purchase to associate
* @return void
*/
public function set_purchase( \IPS\nexus\Purchase $purchase = NULL )
@@ -238,7 +243,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Set purchase
*
* @param \IPS\nexus\Support\Status
* @param \IPS\nexus\Support\Status $status Status to set
* @return void
*/
public function set_status( Status $status )
@@ -259,7 +264,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Set severity
*
* @param \IPS\nexus\Support\Severity
* @param \IPS\nexus\Support\Severity $severity Severity to set
* @return void
*/
public function set_severity( Severity $severity )
@@ -270,7 +275,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Set last reply by
*
* @param int $lastReplyBy
* @param int $lastReplyBy Last reply author
* @return void
*/
public function set_last_reply_by( $lastReplyBy )
@@ -371,7 +376,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Set PPI invoice
*
* @param \IPS\nexus\Invoice|NULL
* @param \IPS\nexus\Invoice|NULL $invoice Invoice to set for PPI
* @return void
*/
public function set_ppi_invoice( \IPS\nexus\Invoice $invoice = NULL )
@@ -423,7 +428,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$purchaseWhere[] = "ps_id={$id}";
}
}
if ( count( $purchaseWhere ) )
if ( \count( $purchaseWhere ) )
{
$purchaseWhere = array( array( "( ps_member={$account->member_id} OR ( " . implode( ' OR ', $purchaseWhere ) . ' ) )' ) );
}
@@ -444,7 +449,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$doNotShowPurchasesForDepartments = array();
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', 'package' ) ), array( \IPS\Db::i()->in( 'ps_item_id', explode( ',', $department->packages ) ) ) ) ) ) )
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', 'package' ) ), array( \IPS\Db::i()->in( 'ps_item_id', explode( ',', $department->packages ) ) ) ) ) ) )
{
if ( $department->require_package )
{
@@ -463,7 +468,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
{
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 ( !\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 )
{
@@ -479,7 +484,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
}
}
if ( !count( $availableDepartments ) )
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' );
}
@@ -487,21 +492,36 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/* What custom fields need to be triggered by departments? */
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, "sf_departments='*' OR " . \IPS\Db::i()->findInSet( 'sf_departments', array_keys( $availableDepartments ) ) );
/* Closure to reduce duplication */
$assignToggle = function( $departmentId, $fieldId ) use ( &$departmentToggles )
{
if ( !isset( $departmentToggles[ $departmentId ] ) )
{
$departmentToggles[ $departmentId ] = array();
}
$departmentToggles[ $departmentId ][] = "nexus_cfield_{$fieldId}";
};
/* Cycle custom fields and add relevant toggles */
foreach ( $customFields as $field )
{
if ( $field->departments and $field->departments !== '*' )
{
foreach ( explode( ',', $field->departments ) as $departmentId )
{
if ( !isset( $departmentToggles[ $departmentId ] ) )
{
$departmentToggles[ $departmentId ] = array();
}
$departmentToggles[ $departmentId ][] = "nexus_cfield_{$field->id}";
$assignToggle( $departmentId, $field->id );
}
}
elseif( $field->departments === '*' )
{
foreach ( $availableDepartments as $department )
{
$assignToggle( $department->id, $field->id );
}
}
}
/* What purchase fields need to be triggered by departments? */
$departments = array();
$purchaseFields = array();
@@ -524,11 +544,48 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$content->error = NULL;
}
$ppiDepartments[] = $department->id;
foreach ( $customFields as $field )
{
/* PPI Departments - Remove any custom fields from PPI departments */
if ( ( $fieldId = array_search( "nexus_cfield_{$field->id}", $departmentToggles[ $department->id ] ) ) !== FALSE )
{
/* If this field belongs only to this one paid department, we can just remove it from the custom fields array to prevent that it's going to be shown in all departments */
$fieldDepartments = explode( ',', $field->departments );
if ( \count( $fieldDepartments ) == 1 )
{
unset( $customFields[$field->id]);
}
else if ( \count( $fieldDepartments ) > 1 )
{
$hasFree = FALSE;
foreach ( $fieldDepartments as $fieldDepartment )
{
try
{
if ( !\IPS\nexus\Support\Department::load( $fieldDepartment )->ppiCost() )
{
$hasFree = TRUE;
}
}
catch( \OutOfRangeException $e ) {}
if ( !$hasFree )
{
unset( $customFields[$field->id]);
}
}
}
unset( $departmentToggles[ $department->id ][ $fieldId ] );
}
}
}
else
{
$departmentToggles[ $department->id ][] = static::$formLangPrefix . 'content_editor';
if ( $department->packages and !in_array( $department->id, $doNotShowPurchasesForDepartments ) )
if ( $department->packages and !\in_array( $department->id, $doNotShowPurchasesForDepartments ) )
{
$allowedPackageIds = explode( ',', $department->packages );
$allowedSubscriptionIds = explode( ',', $department->subscriptions );
@@ -538,7 +595,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
{
$field = new \IPS\Helpers\Form\Node(
'support_purchase_' . $allowedPackages,
isset( \IPS\Request::i()->purchase ) ? intval( \IPS\Request::i()->purchase ) : NULL,
isset( \IPS\Request::i()->purchase ) ? \intval( \IPS\Request::i()->purchase ) : NULL,
TRUE,
array(
'class' => 'IPS\nexus\Purchase',
@@ -546,8 +603,8 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
'permissionCheck' => function( $node ) use ( $allowedPackageIds, $allowedSubscriptionIds )
{
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 ) ) )
( $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,
@@ -555,7 +612,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
),
$department->require_package ? function( $val ) use ( $allowedPackages, $departmentToggles )
{
if ( !$val and isset( $departmentToggles[ \IPS\Request::i()->support_department ] ) and in_array( 'support_purchase_' . $allowedPackages, $departmentToggles[ \IPS\Request::i()->support_department ] ) )
if ( !$val and isset( $departmentToggles[ \IPS\Request::i()->support_department ] ) and \in_array( 'support_purchase_' . $allowedPackages, $departmentToggles[ \IPS\Request::i()->support_department ] ) )
{
throw new \DomainException('support_purchase_required');
}
@@ -578,7 +635,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$defaultSeverityId = Severity::load( TRUE, 'sev_default' )->id;
foreach ( $availableDepartments as $department )
{
if ( count( $department->availableSeverities() ) > 1 )
if ( \count( $department->availableSeverities() ) > 1 )
{
$serialized = "severity_{$department->serializedSeverityIds()}";
@@ -590,7 +647,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$options[ $severity->id ] = "nexus_severity_{$severity->id}";
}
$field = new \IPS\Helpers\Form\Radio( 'support_' . $serialized, in_array( $defaultSeverityId, array_keys( $options ) ) ? $defaultSeverityId : NULL, FALSE, array( 'options' => $options ), NULL, NULL, NULL, 'support_' . $serialized );
$field = new \IPS\Helpers\Form\Radio( 'support_' . $serialized, \in_array( $defaultSeverityId, array_keys( $options ) ) ? $defaultSeverityId : NULL, FALSE, array( 'options' => $options ), NULL, NULL, NULL, 'support_' . $serialized );
$field->label = \IPS\Member::loggedIn()->language()->addToStack('support_severity');
$severityFields[ $serialized ] = $field;
}
@@ -603,9 +660,10 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
}
}
}
/* Add department */
if ( !empty( $ppiDepartments ) and count( $departments ) == count( $ppiDepartments ) )
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 ) );
}
@@ -613,7 +671,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
{
$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 );
$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") )
@@ -627,7 +685,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/* Purchase */
$return = array_merge( $return, $purchaseFields );
/* Custom Fields */
foreach ( $customFields as $field )
{
@@ -635,14 +693,24 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
if ( $field->required )
{
$validation = function( $val ) use ( $field, $departmentToggles ) {
if ( $val === '' and ( !isset( \IPS\Request::i()->support_department ) or in_array( "nexus_cfield_{$field->id}", $departmentToggles[ \IPS\Request::i()->support_department ] ) ) )
if ( !$val and ( !isset( \IPS\Request::i()->support_department ) or \in_array( "nexus_cfield_{$field->id}", $departmentToggles[ \IPS\Request::i()->support_department ] ) ) )
{
throw new \DomainException('form_required');
}
};
}
$helper = $field->buildHelper( NULL, $validation );
if ( $field->type === 'Editor' )
{
$attachIds = array( NULL, NULL, NULL );
if ( $item )
{
$attachIds = array( $item->id, $field->id, 'fields' );
}
$field::$editorOptions = array_merge( $field::$editorOptions, array( 'attachIds' => $attachIds ) );
}
$return[] = $field->buildHelper( NULL, $validation );
$return[] = $helper;
}
/* Return */
@@ -729,7 +797,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
else
{
$availableSeverities = $department->availableSeverities();
if ( count( $availableSeverities ) === 1 )
if ( \count( $availableSeverities ) === 1 )
{
$this->severity = array_pop( $availableSeverities );
}
@@ -780,6 +848,16 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
{
$cfields[ $k ] = $class::stringValue( $v );
}
if ( $customFieldObjects[ $k ]->type === 'Editor' )
{
$idColumn = static::$databaseColumnId;
if ( !$this->$idColumn )
{
$this->save();
}
$customFieldObjects[ $k ]->claimAttachments( $this->$idColumn, 'fields' );
}
}
}
$this->cfields = $cfields;
@@ -802,7 +880,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Log that the request was created
*
* @param \IPS\nexus\Support\Reply The first message
* @param \IPS\nexus\Support\Reply $reply The first message
* @return void
*/
public function afterCreateLog( $reply )
@@ -869,12 +947,12 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$order = isset( \IPS\Request::i()->order ) ? \IPS\Request::i()->order : ( isset( \IPS\Request::i()->cookie['support_replies_order'] ) ? \IPS\Request::i()->cookie['support_replies_order'] : 'desc' );
if ( $order === 'asc' )
{
$lastPageUrl = $lastPageUrl->setQueryString( 'page', $this->commentPageCount() );
$lastPageUrl = $lastPageUrl->setPage( 'page', $this->commentPageCount() );
}
if ( $pending )
{
$lastPageUrl = $lastPageUrl->setQueryString( 'pending', 1 );
if ( is_array( $pending ) )
if ( \is_array( $pending ) )
{
$lastPageUrl = $lastPageUrl->setQueryString( $pending );
}
@@ -952,7 +1030,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$this->_staffFormRedirect( FALSE, TRUE );
}
}
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'support', 'nexus' ) ), 'noteForm' ), $this );
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'support', 'nexus' ), 'noteForm' ), $this );
}
/**
@@ -986,13 +1064,14 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
{
$defaultContent = \IPS\Db::i()->select( 'content', 'nexus_support_staff_preferences', array( 'staff_id=?', \IPS\Member::loggedIn()->member_id ) )->first();
$defaultContent = str_replace(
array( '{customer_first_name}', '{customer_last_name}', '{customer_full_name}', '{department_name}', '{department_email}' ),
array( '{customer_first_name}', '{customer_last_name}', '{customer_full_name}', '{department_name}', '{department_email}', '{default_content}' ),
array(
( $this->supportAuthor() instanceof \IPS\nexus\Support\Author\Member ) ? \IPS\nexus\Customer::load( $this->author()->member_id )->cm_first_name : '',
( $this->supportAuthor() instanceof \IPS\nexus\Support\Author\Member ) ? \IPS\nexus\Customer::load( $this->author()->member_id )->cm_last_name : '',
$this->supportAuthor()->name(),
$this->department->_title,
$this->department->email
$this->department->email,
'<br>'
),
$defaultContent
);
@@ -1003,7 +1082,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
}
/* Attributes */
if ( count( \IPS\nexus\Support\StockAction::roots() ) )
if ( \count( \IPS\nexus\Support\StockAction::roots() ) )
{
$form->add( new \IPS\Helpers\Form\Select( 'stock_action', NULL, FALSE, array( 'options' => $stockActions ), NULL, NULL, NULL, 'stock_action' ) );
}
@@ -1114,7 +1193,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
}
/* Display */
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'support', 'nexus' ) ), 'staffReplyForm' ), $this );
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'support', 'nexus' ), 'staffReplyForm' ), $this );
}
/**
@@ -1185,7 +1264,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$alternativeContactWhere[] = '( r_member=' . $contact->main_id->member_id . ' AND ' . \IPS\Db::i()->in( 'r_purchase', $contact->purchaseIds() ) . ' )';
}
}
if ( count( $alternativeContactWhere ) )
if ( \count( $alternativeContactWhere ) )
{
$extraClause[0] = '( ' . $extraClause[0] . ' OR ( ' . implode( ' OR ', $alternativeContactWhere ) . ' ) )';
}
@@ -1264,19 +1343,30 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
}
/* Staff */
elseif ( ( !\IPS\Dispatcher::hasInstance() or \IPS\Dispatcher::i()->controllerLocation === 'admin' ) and $member->isAdmin() and ( $this->department->staff === '*' or count( array_intersect( explode( ',', $this->department->staff ), Department::staffDepartmentPerms( $member ) ) ) ) )
elseif ( ( !\IPS\Dispatcher::hasInstance() or \IPS\Dispatcher::i()->controllerLocation === 'admin' ) and $member->isAdmin() and ( $this->department->staff === '*' or \count( array_intersect( explode( ',', $this->department->staff ), Department::staffDepartmentPerms( $member ) ) ) ) )
{
return TRUE;
}
/* Altcontact */
elseif ( in_array( $this->author()->member_id, array_keys( iterator_to_array( $member->parentContacts( $this->purchase ? array( '( support=1 OR ' . \IPS\Db::i()->findInSet( 'purchases', array( $this->purchase->id ) ) . ' )' ) : array( 'support=1' ) ) ) ) ) )
elseif ( \in_array( $this->author()->member_id, array_keys( iterator_to_array( $member->parentContacts( $this->purchase ? array( '( support=1 OR ' . \IPS\Db::i()->findInSet( 'purchases', array( $this->purchase->id ) ) . ' )' ) : array( 'support=1' ) ) ) ) ) )
{
return TRUE;
}
return FALSE;
}
/**
* Can Merge?
*
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
* @return bool
*/
public function canMerge( $member=NULL )
{
return FALSE;
}
/**
* Can view hidden comments on this item?
@@ -1294,7 +1384,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$return = parent::canViewHiddenComments( $member );
/* Is the member a staff member with access to this department? They may not be a moderator on the front-end, so the parent method will return false */
if ( $return === FALSE and ( !\IPS\Dispatcher::hasInstance() or \IPS\Dispatcher::i()->controllerLocation === 'admin' ) and $member->isAdmin() and ( $this->department->staff === '*' or count( array_intersect( explode( ',', $this->department->staff ), Department::staffDepartmentPerms( $member ) ) ) ) )
if ( $return === FALSE and ( !\IPS\Dispatcher::hasInstance() or \IPS\Dispatcher::i()->controllerLocation === 'admin' ) and $member->isAdmin() and ( $this->department->staff === '*' or \count( array_intersect( explode( ',', $this->department->staff ), Department::staffDepartmentPerms( $member ) ) ) ) )
{
$return = TRUE;
}
@@ -1306,12 +1396,13 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Can comment?
*
* @param \IPS\Member\NULL $member The member (NULL for currently logged in member)
* @param \IPS\Member\NULL $member The member (NULL for currently logged in member)
* @param bool $considerPostBeforeRegistering If TRUE, and $member is a guest, will return TRUE if "Post Before Registering" feature is enabled
* @return bool
*/
public function canComment( $member=NULL )
public function canComment( $member=NULL, $considerPostBeforeRegistering = TRUE )
{
return parent::canComment( $member ) and !$this->status->is_locked;
return parent::canComment( $member, $considerPostBeforeRegistering ) and !$this->status->is_locked;
}
/**
@@ -1361,10 +1452,11 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Should new comments be moderated?
*
* @param \IPS\Member $member The member posting
* @param \IPS\Member $member The member posting
* @param bool $considerPostBeforeRegistering If TRUE, and $member is a guest, will check if a newly registered member would be moderated
* @return bool
*/
public function moderateNewComments( \IPS\Member $member )
public function moderateNewComments( \IPS\Member $member, $considerPostBeforeRegistering = FALSE )
{
return FALSE; // Even if the member is on mod queue, that doesn't apply to support requests
}
@@ -1418,11 +1510,11 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
foreach ( \IPS\Db::i()->select( 'staff_id', 'nexus_support_notify', array( array( 'type=?', 'n' ), array( "(departments='*' OR " . \IPS\Db::i()->findInSet( 'departments', array( $this->department->id ) ) . ')' ) ) ) as $staffId )
{
if ( in_array( $staffId, $staffIds ) )
if ( \in_array( $staffId, $staffIds ) )
{
$member = \IPS\Member::load( $staffId );
if ( $this->department->staff === '*' or count( array_intersect( \IPS\nexus\Support\Department::staffDepartmentPerms( $member ), explode( ',', $this->department->staff ) ) ) )
if ( $this->department->staff === '*' or \count( array_intersect( \IPS\nexus\Support\Department::staffDepartmentPerms( $member ), explode( ',', $this->department->staff ) ) ) )
{
$fromEmail = ( $this->department->email ) ? $this->department->email : \IPS\Settings::i()->email_out;
switch ( \IPS\Settings::i()->nexus_sout_from )
@@ -1448,6 +1540,8 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
\IPS\Db::i()->delete( 'nexus_support_notify', array( 'staff_id=?', $staffId ) );
}
}
\IPS\core\AdminNotification::send( 'nexus', 'Support', NULL, TRUE, NULL, TRUE );
}
/* !Other */
@@ -1610,7 +1704,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
*/
public function nextPrevious( $type=0, $excludeAssignedToOther=FALSE )
{
if ( !array_key_exists( intval( $type ), $this->nextPrevious ) )
if ( !array_key_exists( \intval( $type ), $this->nextPrevious ) )
{
/* Get out stream */
$stream = \IPS\nexus\Support\Stream::myStream();
@@ -1621,8 +1715,8 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
}
/* And figure out our order */
$sortBy = ( isset( \IPS\Request::i()->cookie['support_sort'] ) and in_array( \IPS\Request::i()->cookie['support_sort'], array( 'r_started', 'r_last_new_reply', 'r_last_reply', 'r_last_staff_reply' ) ) ) ? \IPS\Request::i()->cookie['support_sort'] : 'r_last_new_reply';
$sortDir = ( isset( \IPS\Request::i()->cookie['support_order'] ) and in_array( \IPS\Request::i()->cookie['support_order'], array( 'ASC', 'DESC' ) ) ) ? \IPS\Request::i()->cookie['support_order'] : 'ASC';
$sortBy = ( isset( \IPS\Request::i()->cookie['support_sort'] ) and \in_array( \IPS\Request::i()->cookie['support_sort'], array( 'r_started', 'r_last_new_reply', 'r_last_reply', 'r_last_staff_reply' ) ) ) ? \IPS\Request::i()->cookie['support_sort'] : 'r_last_new_reply';
$sortDir = ( isset( \IPS\Request::i()->cookie['support_order'] ) and \in_array( \IPS\Request::i()->cookie['support_order'], array( 'ASC', 'DESC' ) ) ) ? \IPS\Request::i()->cookie['support_order'] : 'ASC';
if ( $type == 1 )
{
$sortDir = ( $sortDir === 'ASC' ) ? 'DESC' : 'ASC';
@@ -1679,16 +1773,16 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$result = $query->first();
}
$this->nextPrevious[ intval( $type ) ] = \IPS\nexus\Support\Request::constructFromData( $result );
return $this->nextPrevious[ intval( $type ) ];
$this->nextPrevious[ \intval( $type ) ] = \IPS\nexus\Support\Request::constructFromData( $result );
return $this->nextPrevious[ \intval( $type ) ];
}
catch ( \UnderflowException $e ) { }
/* If we're still here and we were after the first in the list, we can go no further */
if ( $type == 2 )
{
$this->nextPrevious[ intval( $type ) ] = NULL;
return $this->nextPrevious[ intval( $type ) ];
$this->nextPrevious[ \intval( $type ) ] = NULL;
return $this->nextPrevious[ \intval( $type ) ];
}
/* Still here? Try with the next/previous severity */
@@ -1702,8 +1796,8 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
try
{
$result = \IPS\Db::i()->select( '*', 'nexus_support_requests', $whereClause, "{$sortBy} {$sortDir}" )->first();
$this->nextPrevious[ intval( $type ) ] = \IPS\nexus\Support\Request::constructFromData( $result );
return $this->nextPrevious[ intval( $type ) ];
$this->nextPrevious[ \intval( $type ) ] = \IPS\nexus\Support\Request::constructFromData( $result );
return $this->nextPrevious[ \intval( $type ) ];
}
catch ( \UnderflowException $e ) { }
}
@@ -1727,18 +1821,18 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
{
$result = \IPS\Db::i()->select( '*', 'nexus_support_requests', $whereClause, "sev_position " . ( $type == 1 ? 'DESC' : 'ASC' ) . ", {$sortBy} {$sortDir}" )
->join( 'nexus_support_severities', 'sev_id=r_severity' )->first();
$this->nextPrevious[ intval( $type ) ] = \IPS\nexus\Support\Request::constructFromData( $result );
return $this->nextPrevious[ intval( $type ) ];
$this->nextPrevious[ \intval( $type ) ] = \IPS\nexus\Support\Request::constructFromData( $result );
return $this->nextPrevious[ \intval( $type ) ];
}
catch ( \UnderflowException $e ) { }
}
}
/* Still here? We got nothing */
$this->nextPrevious[ intval( $type ) ] = NULL;
return $this->nextPrevious[ intval( $type ) ];
$this->nextPrevious[ \intval( $type ) ] = NULL;
return $this->nextPrevious[ \intval( $type ) ];
}
return $this->nextPrevious[ intval( $type ) ];
return $this->nextPrevious[ \intval( $type ) ];
}
/**
@@ -1747,10 +1841,7 @@ class _Request extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
* @param string $action What changed
* @param mixed $old Old value
* @param mixed $new New value
* @param \IPS\Member|NULL|FALSE The member
* FALSE if there is no member
* NULL to use currently logged in member
*
* @param \IPS\Member|NULL|FALSE $member The member (FALSE if there is no member, NULL to use currently logged in member )
* @return void
*/
public function log( $action, $old, $new, $member = NULL )