/** * Saves the supplied OmniLog Entry to the database. * * @access public * @param Omnilog_entry $entry The entry to save. * @return Omnilog_entry */ public function save_entry_to_log(Omnilog_entry $entry) { if (!$entry->is_populated()) { throw new Exception($this->_ee->lang->line('exception__save_entry__missing_data')); } $insert_data = array_merge($entry->to_array(), array('notify_admin' => $entry->get_notify_admin() === TRUE ? 'y' : 'n', 'site_id' => $this->get_site_id())); $this->_ee->db->insert('omnilog_entries', $insert_data); if (!($insert_id = $this->_ee->db->insert_id())) { throw new Exception($this->_ee->lang->line('exception__save_entry__not_saved')); } $entry->set_log_entry_id($insert_id); return $entry; }
/** * Saves the supplied OmniLog Entry to the database. * * @access public * @param Omnilog_entry $entry The entry to save. * @return Omnilog_entry */ public function save_entry_to_log(Omnilog_entry $entry) { /** * This method could conceivably be called when the module is * not installed, but the Omnilogger class is present. */ if (!$this->EE->db->table_exists('omnilog_entries')) { throw new Exception($this->EE->lang->line('exception__save_entry__not_installed')); } if (!$entry->is_populated()) { throw new Exception($this->EE->lang->line('exception__save_entry__missing_data')); } $insert_data = array_merge($entry->to_array(), array('notify_admin' => $entry->get_notify_admin() === TRUE ? 'y' : 'n', 'site_id' => $this->get_site_id())); $insert_data['admin_emails'] = implode($insert_data['admin_emails'], '|'); $this->EE->db->insert('omnilog_entries', $insert_data); if (!($insert_id = $this->EE->db->insert_id())) { throw new Exception($this->EE->lang->line('exception__save_entry__not_saved')); } $entry->set_log_entry_id($insert_id); return $entry; }