Ejemplo n.º 1
0
 function _config_set_value($configdata, $key, $default = null)
 {
     if (isset($configdata->{$key})) {
         $value = $configdata->{$key};
     } else {
         $value = $default;
     }
     if ($value !== null) {
         pm_set_config($key, $value);
     }
 }
Ejemplo n.º 2
0
/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    local_elisprogram
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @copyright  (C) 2008-2013 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
function xmldb_local_elisprogram_install()
{
    global $CFG, $DB;
    $elisadminblockinstalled = file_exists($CFG->dirroot . '/local/elisprogram/lib/setup.php') && $DB->record_exists('block', array('name' => 'elisadmin'));
    if ($elisadminblockinstalled) {
        require_once $CFG->dirroot . '/blocks/elisadmin/lib.php';
    }
    require_once $CFG->dirroot . '/local/elisprogram/lib/lib.php';
    // Install custom context levels.
    \local_eliscore\context\helper::set_custom_levels(\local_elisprogram\context\contextinfo::get_contextinfo());
    \local_eliscore\context\helper::install_custom_levels();
    // Initialize custom context levels.
    context_helper::reset_levels();
    \local_eliscore\context\helper::reset_levels();
    \local_eliscore\context\helper::init_levels();
    // Migrate component.
    $migrator = new \local_elisprogram\install\migration\elis26();
    if ($migrator->old_component_installed() === true) {
        $migrator->migrate();
    }
    //make sure the site has exactly one curr admin block instance
    //that is viewable everywhere
    if ($elisadminblockinstalled) {
        block_elisadmin_create_instance();
    }
    // make sure that the manager role can be assigned to all PM context levels
    update_capabilities('local_elisprogram');
    // load context levels
    pm_ensure_role_assignable('manager');
    pm_ensure_role_assignable('curriculumadmin');
    // Migrate dataroot files
    pm_migrate_certificate_files();
    // These notifications are default-on.
    pm_set_config('notify_addedtowaitlist_user', 1);
    pm_set_config('notify_enroledfromwaitlist_user', 1);
    pm_set_config('notify_incompletecourse_user', 1);
    // Ensure ELIS scheduled tasks is initialized.
    require_once $CFG->dirroot . '/local/eliscore/lib/tasklib.php';
    elis_tasks_update_definition('local_elisprogram');
    // Remove some lingering subplugins that were renamed
    unset_all_config_for_plugin('usersetenrol_manual');
    unset_all_config_for_plugin('usersetenrol_moodle_profile');
}
 /**
  * Validate that the enrolment count excludes inactive users when the site is not configured to show inactive users
  */
 public function test_usercountexcludesinactivewhenexcludinginactive()
 {
     require_once elispm::lib('lib.php');
     // Set up all the data needed for the listing.
     $this->load_csv_data();
     // Disable showing of inactive users.
     pm_set_config('legacy_show_inactive_users', 0);
     elis::$config = new elis_config();
     // Obtain the listing.
     $listing = track_assignment_get_listing(1);
     // Validate the number of rows.
     $count = 0;
     foreach ($listing as $entity) {
         $count++;
         // Validate the aggregated count in the first row.
         $this->assertEquals(1, $entity->enrolments);
     }
     unset($listing);
     $this->assertEquals(1, $count);
 }
 /**
  * Validate that the listing respects paging
  */
 public function test_availableusersrespectspaging()
 {
     $this->load_csv_data();
     $this->assign_track_enrol_permissions();
     set_config('siteguest', '');
     set_config('siteadmins', '');
     pm_set_config('legacy_show_inactive_users', 0);
     elis::$config = new elis_config();
     $usersrecset = usertrack::get_available_users(1, 'lastname', 'ASC', '', '', 0, 1);
     $users = array();
     foreach ($usersrecset as $key => $user) {
         $users[$key] = $user;
     }
     unset($usersrecset);
     // Validate that only one record is picked up when paging with page size 1.
     $this->assertEquals(1, count($users));
 }
Ejemplo n.º 5
0
 /**
  * Validate that My Moodle redirection works when it's supposed to
  */
 public function test_myoodleredirectreturnstruewhensettingenabled()
 {
     global $CFG, $USER, $DB;
     require_once $CFG->dirroot . '/user/lib.php';
     // Set up our test user.
     $user = new stdClass();
     $user->username = "******";
     $userid = user_create_user($user);
     $USER = $DB->get_record('user', array('id' => $userid));
     // Enable functionality.
     pm_set_config('mymoodle_redirect', 1);
     elis::$config = new elis_config();
     // Validation.
     $result = pm_mymoodle_redirect();
     $this->assertTrue($result);
 }
Ejemplo n.º 6
0
/**
 * Upgrade old ELIS tables.
 *
 * @param int $oldversion The old ELIS version.
 * @return bool Success/Failure.
 */
function local_elisprogram_upgrade_old_tables($oldversion)
{
    global $DB, $CFG;
    $dbman = $DB->get_manager();
    $result = true;
    if ($result && $oldversion < 2013031400) {
        // ELIS-8066: remove blank/empty menu options from custom field menu/checkbox and defaults using them.
        $customfields = $DB->get_recordset('local_eliscore_field', null, '', 'id');
        foreach ($customfields as $id => $unused) {
            $field = new field($id);
            $field->load();
            if (isset($field->owners['manual'])) {
                $manual = new field_owner($field->owners['manual']);
                $control = $manual->param_control;
                $options = $manual->param_options;
                if (!empty($options) && empty($manual->param_options_source) && ($control == 'menu' || $control == 'checkbox')) {
                    $options = str_replace("\r", '', $options);
                    // Strip CRs.
                    $options = preg_replace("/\n+/", "\n", $options);
                    $manual->param_options = rtrim($options, "\n");
                    $manual->save();
                    // Remove any empty defaults.
                    $DB->delete_records_select($field->data_table(), "contextid IS NULL AND fieldid = ? AND data = ''", array($id));
                }
            }
        }
        upgrade_plugin_savepoint($result, 2013031400, 'elis', 'program');
    }
    // ELIS-7780: remove deprecated capabilites.
    if ($result && $oldversion < 2013041900) {
        $capstodelete = array('elis/program:viewgroupreports', 'elis/program:viewreports');
        list($inorequal, $params) = $DB->get_in_or_equal($capstodelete);
        $where = "capability {$inorequal}";
        $DB->delete_records_select('role_capabilities', $where, $params);
        $where = "name {$inorequal}";
        $DB->delete_records_select('capabilities', $where, $params);
        upgrade_plugin_savepoint($result, 2013041900, 'elis', 'program');
    }
    // Remove any duplicate user track records before attempting to apply an index.
    pm_fix_duplicate_usertrack_records('crlm_user_track');
    if ($result && $oldversion < 2013042900) {
        // Add indexes to {crlm_user_track} table.
        $table = new xmldb_table('crlm_user_track');
        if ($dbman->table_exists($table)) {
            // Array of indexes to drop.
            $dropindexes = array(new xmldb_index('any_userid_ix', XMLDB_INDEX_UNIQUE, array('userid')), new xmldb_index('any_trackid_ix', XMLDB_INDEX_UNIQUE, array('trackid')), new xmldb_index('any_userid_trackid_ix', XMLDB_INDEX_NOTUNIQUE, array('userid', 'trackid')));
            foreach ($dropindexes as $index) {
                // Drop unwanted indexes if they exist.
                if ($dbman->index_exists($table, $index)) {
                    $dbman->drop_index($table, $index);
                }
            }
            // Array of indexes to create.
            $createindexes = array(new xmldb_index('userid_ix', XMLDB_INDEX_NOTUNIQUE, array('userid')), new xmldb_index('trackid_ix', XMLDB_INDEX_NOTUNIQUE, array('trackid')), new xmldb_index('userid_trackid_ix', XMLDB_INDEX_UNIQUE, array('userid', 'trackid')));
            foreach ($createindexes as $index) {
                // Create desired indexes as required.
                if (!$dbman->index_exists($table, $index)) {
                    $dbman->add_index($table, $index);
                }
            }
        }
        upgrade_plugin_savepoint($result, 2013042900, 'elis', 'program');
    }
    if ($result && $oldversion < 2013051500) {
        // Change results engine action min/max fields from integer to float.
        $table = new xmldb_table('crlm_results_action');
        if ($dbman->table_exists($table)) {
            $field = new xmldb_field('minimum', XMLDB_TYPE_NUMBER, '10,5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'actiontype');
            $dbman->change_field_type($table, $field);
            $field = new xmldb_field('maximum', XMLDB_TYPE_NUMBER, '10,5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'minimum');
            $dbman->change_field_type($table, $field);
        }
        upgrade_plugin_savepoint($result, 2013051500, 'elis', 'program');
    }
    if ($result && $oldversion < 2013051502) {
        // Define table crlm_certificate_settings to be created
        // Conditionally launch create table for crlm_certificate_settings.
        $table = new xmldb_table('crlm_certificate_settings');
        if (!$dbman->table_exists($table)) {
            // Adding fields to table crlm_certificate_settings.
            $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
            $table->add_field('entity_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
            $table->add_field('entity_type', XMLDB_TYPE_CHAR, '9', null, XMLDB_NOTNULL, null, null);
            $table->add_field('cert_border', XMLDB_TYPE_CHAR, '200', null, XMLDB_NOTNULL, null, null);
            $table->add_field('cert_seal', XMLDB_TYPE_CHAR, '200', null, XMLDB_NOTNULL, null, null);
            $table->add_field('cert_template', XMLDB_TYPE_CHAR, '200', null, XMLDB_NOTNULL, null, null);
            $table->add_field('disable', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1');
            $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
            $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
            // Adding keys to table crlm_certificate_settings.
            $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
            // Adding indexes to table crlm_certificate_settings.
            $table->add_index('ent_id_type_ix', XMLDB_INDEX_UNIQUE, array('entity_id', 'entity_type'));
            $dbman->create_table($table);
        }
        // Define table crlm_certificate_issued to be created.
        $table = new xmldb_table('crlm_certificate_issued');
        // Conditionally launch create table for crlm_certificate_issued.
        if (!$dbman->table_exists($table)) {
            // Adding fields to table crlm_certificate_issued.
            $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
            $table->add_field('cm_userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
            $table->add_field('cert_setting_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
            $table->add_field('cert_code', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null);
            $table->add_field('timeissued', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
            $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
            // Adding keys to table crlm_certificate_issued.
            $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
            // Adding indexes to table crlm_certificate_issued.
            $table->add_index('cert_code_ix', XMLDB_INDEX_UNIQUE, array('cert_code'));
            $table->add_index('cm_userid_ix', XMLDB_INDEX_NOTUNIQUE, array('cm_userid'));
            $dbman->create_table($table);
        }
        // ELIS savepoint reached.
        upgrade_plugin_savepoint($result, 2013051502, 'elis', 'program');
    }
    // ELIS-8528: remove orphaned LOs.
    if ($result && $oldversion < 2013051503) {
        $where = 'NOT EXISTS (SELECT \'x\' FROM {crlm_course} cc WHERE cc.id = {crlm_course_completion}.courseid)';
        $DB->delete_records_select('crlm_course_completion', $where);
        upgrade_plugin_savepoint($result, 2013051503, 'elis', 'program');
    }
    if ($result && $oldversion < 2013082100) {
        // Change password field length to 255.
        $table = new xmldb_table('crlm_user');
        $field = new xmldb_field('password', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'username');
        $dbman->change_field_precision($table, $field);
        upgrade_plugin_savepoint($result, 2013082100, 'elis', 'program');
    }
    if ($result && $oldversion < 2013082101) {
        require_once elis::file('eliscore/fields/manual/custom_fields.php');
        require_once elis::file('eliscore/fields/moodleprofile/custom_fields.php');
        $fieldcat = field_category::ensure_exists_for_contextlevel(get_string('moodlefields', 'local_elisprogram'), CONTEXT_ELIS_USER);
        $sql = 'SELECT m.id
                  FROM {user_info_field} m
                 WHERE NOT EXISTS(
                           SELECT *
                             FROM {local_eliscore_field} e
                            WHERE e.shortname = m.shortname
                       )';
        $fieldstosync = $DB->get_records_sql($sql);
        foreach ($fieldstosync as $mfield) {
            // Create field.
            $efield = field::make_from_moodle_field($mfield->id, $fieldcat, pm_moodle_profile::sync_from_moodle);
            // Sync profile field information from Moodle into ELIS.
            sync_profile_field_from_moodle($efield);
        }
        upgrade_plugin_savepoint($result, 2013082101, 'elis', 'program');
    }
    if ($result && $oldversion < 2013082103) {
        // ELIS-8441 & ELIS-8569: Fix Program timetocomplete & frequency defaults of '0y'.
        $table = new xmldb_table('crlm_curriculum');
        if ($dbman->table_exists($table)) {
            $field = new xmldb_field('timetocomplete', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null, 'timemodified');
            $dbman->change_field_default($table, $field);
            $field = new xmldb_field('frequency', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null, 'timetocomplete');
            $dbman->change_field_default($table, $field);
            $sql = 'UPDATE {crlm_curriculum} SET timetocomplete = "" WHERE timetocomplete = "0y"';
            $DB->execute($sql);
            $sql = 'UPDATE {crlm_curriculum} SET frequency = "" WHERE frequency = "0y"';
            $DB->execute($sql);
        }
        upgrade_plugin_savepoint($result, 2013082103, 'elis', 'program');
    }
    if ($result && $oldversion < 2013082104) {
        require_once dirname(__FILE__) . '/../../../lib/lib.php';
        pm_set_config('notify_addedtowaitlist_user', 1);
        pm_set_config('notify_enroledfromwaitlist_user', 1);
        pm_set_config('notify_incompletecourse_user', 1);
        upgrade_plugin_savepoint($result, 2013082104, 'elis', 'program');
    }
    return $result;
}
Ejemplo n.º 7
0
 /**
  * handler for the default display action.  Prints the edit form.
  */
 function display_default()
 {
     $target = $this->get_new_page(array('action' => 'default'));
     $configform = new $this->form_class($target->url);
     $configform->set_data(elis::$config->local_elisprogram);
     if ($configdata = $configform->get_data()) {
         /// Notifications section:
         configpage::config_set_value($configdata, 'notify_classenrol_user', 0);
         configpage::config_set_value($configdata, 'notify_classenrol_role', 0);
         configpage::config_set_value($configdata, 'notify_classenrol_supervisor', 0);
         if (empty($configdata->notify_classenrol_message)) {
             $configdata->notify_classenrol_message = get_string('notifyclassenrolmessagedef', 'local_elisprogram');
         }
         pm_set_config('notify_classenrol_message', $configdata->notify_classenrol_message);
         configpage::config_set_value($configdata, 'notify_classcompleted_user', 0);
         configpage::config_set_value($configdata, 'notify_classcompleted_role', 0);
         configpage::config_set_value($configdata, 'notify_classcompleted_supervisor', 0);
         if (empty($configdata->notify_classcompleted_message)) {
             $configdata->notify_classcompleted_message = get_string('notifyclasscompletedmessagedef', 'local_elisprogram');
         }
         pm_set_config('notify_classcompleted_message', $configdata->notify_classcompleted_message);
         configpage::config_set_value($configdata, 'notify_classnotstarted_user', 0);
         configpage::config_set_value($configdata, 'notify_classnotstarted_role', 0);
         configpage::config_set_value($configdata, 'notify_classnotstarted_supervisor', 0);
         if (empty($configdata->notify_classnotstarted_message)) {
             $configdata->notify_classnotstarted_message = get_string('notifyclassnotstartedmessagedef', 'local_elisprogram');
         }
         pm_set_config('notify_classnotstarted_message', $configdata->notify_classnotstarted_message);
         configpage::config_set_value($configdata, 'notify_classnotstarted_days', 0);
         configpage::config_set_value($configdata, 'notify_classnotcompleted_user', 0);
         configpage::config_set_value($configdata, 'notify_classnotcompleted_role', 0);
         configpage::config_set_value($configdata, 'notify_classnotcompleted_supervisor', 0);
         if (empty($configdata->notify_classnotcompleted_message)) {
             $configdata->notify_classnotcompleted_message = get_string('notifyclassnotcompletedmessagedef', 'local_elisprogram');
         }
         pm_set_config('notify_classnotcompleted_message', $configdata->notify_classnotcompleted_message);
         configpage::config_set_value($configdata, 'notify_classnotcompleted_days', 0);
         configpage::config_set_value($configdata, 'notify_curriculumcompleted_user', 0);
         configpage::config_set_value($configdata, 'notify_curriculumcompleted_role', 0);
         configpage::config_set_value($configdata, 'notify_curriculumcompleted_supervisor', 0);
         if (empty($configdata->notify_curriculumcompleted_message)) {
             $configdata->notify_curriculumcompleted_message = get_string('notifycurriculumcompletedmessagedef', 'local_elisprogram');
         }
         pm_set_config('notify_curriculumcompleted_message', $configdata->notify_curriculumcompleted_message);
         configpage::config_set_value($configdata, 'notify_curriculumnotcompleted_user', 0);
         configpage::config_set_value($configdata, 'notify_curriculumnotcompleted_role', 0);
         configpage::config_set_value($configdata, 'notify_curriculumnotcompleted_supervisor', 0);
         if (empty($configdata->notify_curriculumnotcompleted_message)) {
             $configdata->notify_curriculumnotcompleted_message = get_string('notifycurriculumnotcompletedmessagedef', 'local_elisprogram');
         }
         pm_set_config('notify_curriculumnotcompleted_message', $configdata->notify_curriculumnotcompleted_message);
         configpage::config_set_value($configdata, 'notify_curriculumnotcompleted_days', 0);
         configpage::config_set_value($configdata, 'notify_trackenrol_user', 0);
         configpage::config_set_value($configdata, 'notify_trackenrol_role', 0);
         configpage::config_set_value($configdata, 'notify_trackenrol_supervisor', 0);
         if (empty($configdata->notify_trackenrol_message)) {
             $configdata->notify_trackenrol_message = get_string('notifytrackenrolmessagedef', 'local_elisprogram');
         }
         pm_set_config('notify_trackenrol_message', $configdata->notify_trackenrol_message);
         configpage::config_set_value($configdata, 'notify_courserecurrence_user', 0);
         configpage::config_set_value($configdata, 'notify_courserecurrence_role', 0);
         configpage::config_set_value($configdata, 'notify_courserecurrence_supervisor', 0);
         if (empty($configdata->notify_courserecurrence_message)) {
             $configdata->notify_courserecurrence_message = get_string('notifycourserecurrencemessagedef', 'local_elisprogram');
         }
         pm_set_config('notify_courserecurrence_message', $configdata->notify_courserecurrence_message);
         configpage::config_set_value($configdata, 'notify_courserecurrence_days', 0);
         configpage::config_set_value($configdata, 'notify_curriculumrecurrence_user', 0);
         configpage::config_set_value($configdata, 'notify_curriculumrecurrence_role', 0);
         configpage::config_set_value($configdata, 'notify_curriculumrecurrence_supervisor', 0);
         if (empty($configdata->notify_curriculumrecurrence_message)) {
             $configdata->notify_curriculumrecurrence_message = get_string('notifycurriculumrecurrencemessagedef', 'local_elisprogram');
         }
         pm_set_config('notify_curriculumrecurrence_message', $configdata->notify_curriculumrecurrence_message);
         configpage::config_set_value($configdata, 'notify_curriculumrecurrence_days', 0);
         configpage::config_set_value($configdata, 'notify_addedtowaitlist_user', 1);
         configpage::config_set_value($configdata, 'notify_enroledfromwaitlist_user', 1);
         configpage::config_set_value($configdata, 'notify_incompletecourse_user', 1);
     }
     $configform->display();
 }
Ejemplo n.º 8
0
 function do_default()
 {
     global $CFG, $DB;
     //get saved defaults
     $defaults = get_config('local_elisprogram', 'results_engine_defaults');
     $defaults = !empty($defaults) ? unserialize($defaults) : array();
     $saved_row_count = !empty($defaults) ? sizeof($defaults) : 1;
     $this->customdata = array('nrc' => optional_param('rowcount', $saved_row_count, PARAM_INT), 'defaults' => $defaults);
     $form = $this->get_form();
     $data = (array) $form->get_data();
     if (!empty($data) && isset($data['finalize'])) {
         //form being saved
         $data = $this->normalize_submitted_data($data);
         //validate submitted info
         $data2 = array();
         foreach ($data as $i => $range) {
             if (is_numeric($i)) {
                 //remove entirely empty rows
                 if (empty($range['min']) && empty($range['max']) && empty($range['name'])) {
                     continue;
                 }
                 //check for empty values
                 if (empty($range['min'])) {
                     $errs[$i][] = get_string('results_engine_defaults_err_no_min', 'local_elisprogram');
                 }
                 if (empty($range['max'])) {
                     $errs[$i][] = get_string('results_engine_defaults_err_no_max', 'local_elisprogram');
                 }
                 if (!isset($range['name'])) {
                     $range['name'] = '';
                 }
                 //check for overlapping values
                 if (empty($errs[$i]) && !empty($data2) && is_array($data2)) {
                     foreach ($data2 as $j => $ex_rng) {
                         if (!isset($ex_rng['min'], $ex_rng['max'])) {
                             continue;
                         }
                         if ($range['min'] >= $ex_rng['min'] && $range['min'] <= $ex_rng['max']) {
                             $errs[$i][] = get_string('results_engine_defaults_err_min_conflict', 'local_elisprogram');
                             break;
                         }
                         if ($range['max'] >= $ex_rng['min'] && $range['max'] <= $ex_rng['max']) {
                             $errs[$i][] = get_string('results_engine_defaults_err_max_conflict', 'local_elisprogram');
                             break;
                         }
                         if ($ex_rng['min'] >= $range['min'] && $ex_rng['max'] <= $range['max']) {
                             $errs[$i][] = get_string('results_engine_defaults_err_enveloped_range', 'local_elisprogram');
                             break;
                         }
                     }
                 }
                 if (empty($errs[$i])) {
                     $data2[$i] = $range;
                 }
             }
         }
         $data = array();
         //index saved info by rowid to make getting extra saved data easy
         $saved_data_rowid_indexed = array();
         $extradata = array();
         foreach ($defaults as $i => $defaultsdata) {
             if (is_numeric($i) && isset($defaultsdata['rowid']) && is_numeric($defaultsdata['rowid'])) {
                 $saved_data_rowid_indexed[$defaultsdata['rowid']] = $defaultsdata;
             } else {
                 $extradata[$i] = $defaultsdata;
             }
         }
         //add back in any extra values
         foreach ($data2 as $i => $row) {
             if (is_numeric($i) && isset($row['rowid']) && is_numeric($row['rowid']) && !empty($saved_data_rowid_indexed[$row['rowid']])) {
                 $data2[$i] = array_merge($saved_data_rowid_indexed[$row['rowid']], $row);
             }
         }
         $data2 = array_merge($extradata, $data2);
         $data2 = serialize($data2);
         pm_set_config('results_engine_defaults', $data2);
         //$target = $this->get_new_page(array('s'=>'resultsconfig','action' => 'default'), false);
         //redirect($target->url);
         $results = '';
         if (!empty($errs) && is_array($errs)) {
             $results .= get_string('results_engine_defaults_errs_encountered', 'local_elisprogram');
             foreach ($errs as $i => $rowerrs) {
                 if (!empty($rowerrs) && is_array($rowerrs)) {
                     $results .= '<ul>';
                     $results .= '<li>' . get_string('results_engine_defaults_err_row', 'local_elisprogram', $i + 1) . '</li>';
                     $results .= '<ul>';
                     foreach ($rowerrs as $err) {
                         $results .= '<li>' . $err . '</li>';
                     }
                     $results .= '</ul></ul>';
                 }
             }
             $results .= get_string('results_engine_defaults_saved_with_errors', 'local_elisprogram');
         } else {
             $results .= get_string('results_engine_defaults_settings_saved', 'local_elisprogram');
         }
         $results .= '<br /><br />';
     }
     $this->customdata['results'] = !empty($results) ? $results : '';
     $this->display('default');
 }