/**
  * The constructor for this logstore.
  *
  * @param string $subplugintype the subplugin type.
  * @param string $subpluginname the subplugin name.
  * @param restore_structure_step $step.
  */
 public function __construct($subplugintype, $subpluginname, $step)
 {
     // Check that the logstore is enabled before setting variables.
     $enabledlogstores = explode(',', get_config('tool_log', 'enabled_stores'));
     if (in_array('logstore_database', $enabledlogstores)) {
         $manager = new \tool_log\log\manager();
         $store = new \logstore_database\log\store($manager);
         self::$extdb = $store->get_extdb();
         self::$extdbtablename = $store->get_config_value('dbtable');
     }
     parent::__construct($subplugintype, $subpluginname, $step);
 }
 /**
  * Returns the subplugin structure to attach to the 'logstore' XML element.
  *
  * @return backup_subplugin_element the subplugin structure to be attached.
  */
 protected function define_logstore_subplugin_structure()
 {
     $subplugin = $this->get_subplugin_element();
     $subpluginwrapper = new backup_nested_element($this->get_recommended_name());
     // Create the custom (base64 encoded, xml safe) 'other' final element.
     $otherelement = new base64_encode_final_element('other');
     $subpluginlog = new backup_logstore_database_nested_element('logstore_database_log', array('id'), array('eventname', 'component', 'action', 'target', 'objecttable', 'objectid', 'crud', 'edulevel', 'contextid', 'userid', 'relateduserid', 'anonymous', $otherelement, 'timecreated', 'ip', 'realuserid'));
     $subplugin->add_child($subpluginwrapper);
     $subpluginwrapper->add_child($subpluginlog);
     // Get the details for the external database.
     $manager = new \tool_log\log\manager();
     $store = new \logstore_database\log\store($manager);
     $extdb = $store->get_extdb();
     if (!$extdb) {
         return false;
     }
     $subpluginlog->set_source_db($extdb);
     $subpluginlog->set_source_table($store->get_config_value('dbtable'), array('contextid' => backup::VAR_CONTEXTID));
     return $subplugin;
 }