Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+66 -49
View File
@@ -2,9 +2,9 @@
/**
* @brief Support Reply Model
* @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 9 Apr 2014
* @version SVN_VERSION_NUMBER
@@ -125,9 +125,11 @@ class _Reply extends \IPS\Content\Comment implements \IPS\Content\Hideable
* @param bool|NULL $incrementPostCount Increment post count? If NULL, will use static::incrementPostCount()
* @param \IPS\Member|NULL $member The author of this comment. If NULL, uses currently logged in member.
* @param \IPS\DateTime|NULL $time The time
* @return \IPS\Content\Comment
* @param string|NULL $ipAddress The IP address or NULL to detect automatically
* @param int|NULL $hiddenStatus NULL to set automatically or override: 0 = unhidden; 1 = hidden, pending moderator approval; -1 = hidden (as if hidden by a moderator)
* @return static
*/
public static function create( $item, $comment, $first=FALSE, $guestName=NULL, $incrementPostCount=NULL, $member=NULL, \IPS\DateTime $time=NULL )
public static function create( $item, $comment, $first=FALSE, $guestName=NULL, $incrementPostCount=NULL, $member=NULL, \IPS\DateTime $time=NULL, $ipAddress=NULL, $hiddenStatus=NULL )
{
$obj = call_user_func_array( 'parent::create', func_get_args() );
@@ -287,31 +289,47 @@ class _Reply extends \IPS\Content\Comment implements \IPS\Content\Hideable
$type[] = $assignedTo->member_id;
}
$sentTo = array( $this->member );
foreach ( \IPS\Db::i()->select( 'staff_id', 'nexus_support_notify', array( $type, array( "departments='*' OR " . \IPS\Db::i()->findInSet( 'departments', array( $this->item()->department->id ) ) ) ) ) as $staffId )
$staffToSendTo = array();
foreach ( \IPS\Db::i()->select( 'staff_id', 'nexus_support_notify', array( $type, array( "( departments='*' OR " . \IPS\Db::i()->findInSet( 'departments', array( $this->item()->department->id ) ) . ' )' ) ) ) as $staffId )
{
$staffToSendTo[ $staffId ] = $staffId;
}
foreach ( \IPS\Db::i()->select( 'member_id', 'nexus_support_tracker', array( 'request_id=? AND notify=1', $this->item()->id ) ) as $staffId )
{
$staffToSendTo[ $staffId ] = $staffId;
}
foreach ( $staffToSendTo as $staffId )
{
if ( in_array( $staffId, $staffIds ) )
{
if ( !in_array( $staffId, $sentTo ) and ( $this->item()->department->staff === '*' or in_array( $staffId, explode( ',', $this->item()->department->staff ) ) ) )
/* The department may only be available to specific members OR groups - we need to load an \IPS\Member object here so that we can check both and send the notification as appropriate. */
$staff = \IPS\Member::load( $staffId );
$departmentStaff = $this->item()->department->staff;
if ( !in_array( $staffId, $sentTo ) and ( $this->item()->department->staff === '*' or count( array_intersect( explode( ',', $departmentStaff ), Department::staffDepartmentPerms( $staff ) ) ) ) )
{
$email = \IPS\Email::buildFromTemplate( 'nexus', $this->type === static::REPLY_HIDDEN ? 'staffNotifyNote' : 'staffNotifyReply', array( $this ) );
$email->from = ( $this->item()->department->email ) ? $this->item()->department->email : \IPS\Settings::i()->email_out;
$fromEmail = ( $this->item()->department->email ) ? $this->item()->department->email : \IPS\Settings::i()->email_out;
switch ( \IPS\Settings::i()->nexus_sout_from )
{
case 'staff':
if ( $this->member )
{
$email->fromName = $this->author()->name;
}
$fromName = $this->member ? $this->author()->name : $fromEmail;
break;
case 'dpt':
$email->fromName = $email->language->get( 'nexus_department_' . $this->item()->department->_id );
$member = is_int( $this->member ) ? \IPS\Member::load( $this->member ) : $this->member;
$fromName = $this->member
? $member->language()->get( 'nexus_department_' . $this->item()->department->_id )
: \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( 'nexus_department_' . $this->item()->department->_id );
break;
default:
$email->fromName = \IPS\Settings::i()->nexus_sout_from;
$fromName = \IPS\Settings::i()->nexus_sout_from;
break;
}
$email->unsubscribe = array( 'text' => 'manage_notification_settings', 'link' => \IPS\Http\Url::internal( 'app=nexus&module=support&controller=requests&do=notifications', 'admin' ) );
$email->send( \IPS\Member::load( $staffId ) );
\IPS\Email::buildFromTemplate( 'nexus', $this->type === static::REPLY_HIDDEN ? 'staffNotifyNote' : 'staffNotifyReply', array( $this ), \IPS\Email::TYPE_LIST )
->setUnsubscribe( 'nexus', 'unsubscribeStaffNotify' )
->send( $staff, array(), array(), $fromEmail, $fromName );
$sentTo[] = $staffId;
}
@@ -323,6 +341,17 @@ class _Reply extends \IPS\Content\Comment implements \IPS\Content\Hideable
}
}
/**
* Send Unapproved Notification
*
* @return void
*/
public function sendUnapprovedNotification()
{
// If a hidden note is added, we don't want to send the normal "User has posted something which
// requires approval" email - so this method is overloaded and intentionally left blank.
}
/**
* Send Customer Notifications
*
@@ -335,27 +364,40 @@ class _Reply extends \IPS\Content\Comment implements \IPS\Content\Hideable
{
if ( \IPS\Settings::i()->nexus_sout_chrome )
{
$email = \IPS\Email::buildFromTemplate( 'nexus', 'staffReply', array( $this ) );
$email = \IPS\Email::buildFromTemplate( 'nexus', 'staffReply', array( $this ), \IPS\Email::TYPE_TRANSACTIONAL );
}
else
{
$email = \IPS\Email::buildFromTemplate( 'nexus', 'staffReplyNoChrome', array( $this ) );
$email->useWrapper = FALSE;
$email = \IPS\Email::buildFromTemplate( 'nexus', 'staffReplyNoChrome', array( $this ), \IPS\Email::TYPE_TRANSACTIONAL, FALSE );
}
$email->from = $this->item()->department->email ?: \IPS\Settings::i()->email_out;
/* We need to figure out which language we will use */
try
{
$member = \IPS\Member::load( $to, 'email' );
}
catch( \OutOfRangeException $e )
{
$member = NULL;
}
$language = $member ? $member->language() : \IPS\Lang::load( \IPS\Lang::defaultLanguage() );
$fromEmail = $this->item()->department->email ?: \IPS\Settings::i()->email_out;
switch ( \IPS\Settings::i()->nexus_sout_from )
{
case 'staff':
$email->fromName = $this->author()->name;
$fromName = $this->author()->name;
break;
case 'dpt':
$email->fromName = $email->language->get( 'nexus_department_' . $this->item()->department->_id );
$fromName = $language->get( 'nexus_department_' . $this->item()->department->_id );
break;
default:
$email->fromName = \IPS\Settings::i()->nexus_sout_from;
$fromName = \IPS\Settings::i()->nexus_sout_from;
break;
}
$email->send( $to, $cc, $bcc );
$email->send( $to, $cc, $bcc, $fromEmail, $fromName );
}
/**
@@ -374,29 +416,4 @@ class _Reply extends \IPS\Content\Comment implements \IPS\Content\Hideable
return parent::postCreate();
}
/**
* Get ACP URL
*
* @param string|NULL $action Action
* @return \IPS\Http\Url
*/
public function acpUrl( $action=NULL )
{
$url = \IPS\Http\Url::internal( "app=nexus&module=support&controller=request&id={$this->id}", 'admin' );
if( $action )
{
return $url->setQueryString( 'do', $action . 'Comment' )->setQueryString( 'comment', $this->id );
}
else
{
$commentPosition = \IPS\Db::i()->select( 'COUNT(*) AS position', static::$databaseTable, array( static::$databasePrefix . static::$databaseColumnMap['item'] . '=? AND ' . static::$databasePrefix . static::$databaseColumnId . '<=?', $this->request, $this->id ), static::$databasePrefix . static::$databaseColumnMap['date'] . ' asc' )->first();
$page = ceil( $commentPosition / \IPS\nexus\Support\Request::getCommentsPerPage() );
if ( $page != 1 )
{
$url = $url->setQueryString( 'page', $page );
}
return $url->setFragment( 'comment-' . $this->id );
}
}
}