isFrontend()) { return; } // Get the name of the access field $table = $model->getTable(); $accessField = $table->getColumnAlias('access'); // Make sure the field actually exists if (!in_array($accessField, $table->getKnownFields())) { return; } $model->applyAccessFiltering(null); } /** * The event runs after FOFModel has called FOFTable and retrieved a single * item from the database. It is used to apply automatic filters. * * @param FOFModel &$model The model which was called * @param FOFTable &$record The record loaded from the database * * @return void */ public function onAfterGetItem(&$model, &$record) { if ($record instanceof FOFTable) { $fieldName = $record->getColumnAlias('access'); // Make sure the field actually exists if (!in_array($fieldName, $record->getKnownFields())) { return; } // Get the user $user = FOFPlatform::getInstance()->getUser(); // Filter by authorised access levels if (!in_array($record->$fieldName, $user->getAuthorisedViewLevels())) { $record = null; } } } }