This is exactly what I was looking for!
Need to add an event to the Survey class.
// Permission
$criteriaPerm = self::getPermissionCriteria();
$criteria->mergeWith($criteriaPerm, 'AND');
// the new event
// custom criteria from a plugin
$event = new PluginEvent('beforeSurveySearch');
$event->set('criteria', $criteria);
App()->getPluginManager()->dispatchEvent($event);
$returnedCriteria = $event->get('criteria');
if ($returnedCriteria instanceof LSDbCriteria) {
$criteria = $returnedCriteria;
}
// Rest of the existing method code...
// $criteria->addCondition("t.blabla == 'blub'");
// ...
return $dataProvider;
===
class XXX extends PluginBase
{
protected $storage = 'DbStorage';
static protected $description = 'YYY';
static protected $name = 'XXX';
public function init(): void
{
$this->subscribe('beforeSurveySearch');
// ...
public function beforeSurveySearch(): void
{
$criteria = $this->event->get('criteria');
try {
// whatever you need
$criteria->addInCondition('t.sid', array_map('intval', $localSurveys));
} catch (Exception $e) {
// ...
Thank you very much!
github.com/LimeSurvey/LimeSurvey/pull/4269