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 Contact Form
|
||||
* @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
|
||||
* @since 12 Nov 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -23,7 +23,21 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _contact extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
if ( !static::canUseContactUs() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_permission', '2S333/1', 403, '' );
|
||||
}
|
||||
|
||||
/* Execute */
|
||||
return parent::execute();
|
||||
}
|
||||
/**
|
||||
* Method
|
||||
*
|
||||
@@ -31,6 +45,10 @@ class _contact extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Get extensions */
|
||||
$extensions = \IPS\Application::allExtensions( 'core', 'ContactUs', FALSE, 'core', 'InternalEmail', TRUE );
|
||||
|
||||
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
|
||||
@@ -41,39 +59,87 @@ class _contact extends \IPS\Dispatcher\Controller
|
||||
'app' => 'core',
|
||||
'key' => 'Contact',
|
||||
'autoSaveKey' => 'contact-' . \IPS\Member::loggedIn()->member_id,
|
||||
//'minimize' => 'x',
|
||||
) ) );
|
||||
|
||||
if ( !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'contact_name', NULL, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'email_address', NULL, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Captcha );
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'email_address', NULL, TRUE, array( 'bypassProfanity' => TRUE ) ) );
|
||||
if ( \IPS\Settings::i()->bot_antispam_type !== 'none' and \IPS\Settings::i()->guest_captcha )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Captcha );
|
||||
}
|
||||
}
|
||||
foreach ( $extensions as $k => $class )
|
||||
{
|
||||
$class->runBeforeFormOutput( $form );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Send the message */
|
||||
$fromName = ( \IPS\Member::loggedIn()->member_id ) ? \IPS\Member::loggedIn()->name : $values['contact_name'];
|
||||
$mail = \IPS\Email::buildFromTemplate( 'core', 'contact_form', array( \IPS\Member::loggedIn(), $fromName, $values['contact_text'] ) );
|
||||
foreach ( $extensions as $k => $class )
|
||||
{
|
||||
if ( $handled = $class->handleForm( $values ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set contact email as Reply-To instead of From, so that it will pass Spam/SPF checks */
|
||||
$mail->headers['Reply-To'] = '=?UTF-8?B?' . base64_encode( $fromName ) . "?= <" . ( \IPS\Member::loggedIn()->member_id ? \IPS\Member::loggedIn()->email : $values['email_address'] ) . '>';
|
||||
$mail->send( \IPS\Settings::i()->email_in );
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( 'OK' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('message_sent');
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'message_sent' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->contactDone();
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('contact');
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'contact' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->contact( $form );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the current user allowed to use the contact us form
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function canUseContactUs()
|
||||
{
|
||||
try
|
||||
{
|
||||
$module = \IPS\Application\Module::get( 'core', 'contact' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !\IPS\Member::loggedIn()->canAccessModule( $module ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If all groups have access, we can */
|
||||
if( \IPS\Settings::i()->contact_access != '*' )
|
||||
{
|
||||
/* Check member */
|
||||
$member = \IPS\Member::loggedIn();
|
||||
$memberGroups = array_merge( array( $member->member_group_id ), array_filter( explode( ',', $member->mgroup_others ) ) );
|
||||
$accessGroups = explode( ',', \IPS\Settings::i()->contact_access );
|
||||
|
||||
/* Are we in an allowed group? */
|
||||
if( count( array_intersect( $accessGroups, $memberGroups ) ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user