<commit_before><?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

include_once "ilios_base_model.php";

/**
 * Data Access Object (DAO) to the audit tables.
 */
class Audit_Event extends Ilios_Base_Model
{
    /**
     * Constructor.
     */
    public function __construct ()
    {
        parent::__construct('audit_event', array('audit_event_id'));
    }

    /**
     * @deprecated
     * Use <code>Ilios_Model_AuditUtils::wrapAuditAtom() instead.
     * @see Ilios_Model_AuditUtils::wrapAuditAtom()
     */
    public function wrapAtom ($tableId, $tableColumn, $tableName, $type)
    {
        return Ilios_Model_AuditUtils::wrapAuditAtom($tableId, $tableColumn, $tableName, $type);
    }

    /**
     * Saves a given list of audit atoms related to actions taken by a given user.
     *
     * @param array $wrappedAtomArray An array of assoc. arrays, each sub-array
     *     as returned by the Ilios_Model_AuditUtils::wrapAuditAtom() method.
     * @param int $userId The user id.
     * @return boolean TRUE on success, FALSE on failure.
     * @see Ilios_Model_AuditUtils::wrapAuditAtom()
     */
    public function saveAuditEvent ($wrappedAtomArray, $userId)
    {
        $newRow = array();
        $newRow['audit_event_id'] = null;

        $dtTimeStamp = new DateTime('now', new DateTimeZone('UTC'));
        $newRow['time_stamp'] = $dtTimeStamp->format('Y-m-d H:i:s');
        $newRow['user_id'] = $userId;

        $this->db->insert($this->databaseTableName, $newRow);

        $newEventId = $this->db->insert_id();
        if ((! $newEventId) || ($newEventId == 0)) {
            return false;
        }

        foreach ($wrappedAtomArray as $wrappedAtom) {
            $newRow = array();
            $newRow['audit_atom_id'] = null;

            $newRow['table_row_id'] = $wrappedAtom['table_row_id'];
            $newRow['table_column'] = $wrappedAtom['table_column'];
            $newRow['table_name'] = $wrappedAtom['table_name'];
            $newRow['event_type'] = $wrappedAtom['event_type'];
            $newRow['root_atom'] = $wrappedAtom['root_atom'];
            $newRow['audit_event_id'] = $newEventId;
<commit_msg>adjusted the db insertion of audit atoms in saveAuditEvent() according to related schema changes.<commit_after><?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

include_once "ilios_base_model.php";

/**
 * Data Access Object (DAO) to the audit tables.
 */
class Audit_Event extends Ilios_Base_Model
{
    /**
     * Constructor.
     */
    public function __construct ()
    {
        parent::__construct('audit_event', array('audit_event_id'));
    }

    /**
     * @deprecated
     * Use <code>Ilios_Model_AuditUtils::wrapAuditAtom() instead.
     * @see Ilios_Model_AuditUtils::wrapAuditAtom()
     */
    public function wrapAtom ($tableId, $tableColumn, $tableName, $type)
    {
        return Ilios_Model_AuditUtils::wrapAuditAtom($tableId, $tableColumn, $tableName, $type);
    }

    /**
     * Saves a given list of audit atoms related to actions taken by a given user.
     *
     * @param array $wrappedAtomArray An array of assoc. arrays, each sub-array
     *     as returned by the Ilios_Model_AuditUtils::wrapAuditAtom() method.
     * @param int $userId The user id.
     * @return boolean TRUE on success, FALSE on failure.
     * @see Ilios_Model_AuditUtils::wrapAuditAtom()
     */
    public function saveAuditEvent ($wrappedAtomArray, $userId)
    {
        $dtTimeStamp = new DateTime('now', new DateTimeZone('UTC'));
        $createdAt = $dtTimeStamp->format('Y-m-d H:i:s');

        foreach ($wrappedAtomArray as $wrappedAtom) {
            $newRow = array();
            $newRow['audit_atom_id'] = null;
            $newRow['table_row_id'] = $wrappedAtom['table_row_id'];
            $newRow['table_column'] = $wrappedAtom['table_column'];
            $newRow['table_name'] = $wrappedAtom['table_name'];
            $newRow['event_type'] = $wrappedAtom['event_type'];
            $newRow['created_at'] = $createdAt;
            $newRow['created_by'] = $userId;

{'fraction_non_alphanumeric': 0.1370198189380964, 'fraction_numerical': 0.00024467824810374357, 'mean_word_length': 3.027586206896552, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7472430', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1324, 'n_words': 281}