Esempio n. 1
0
function xmldb_label_install()
{
    global $DB;
    /// Install logging support
    update_log_display_entry('label', 'add', 'label', 'name');
    update_log_display_entry('label', 'update', 'label', 'name');
}
Esempio n. 2
0
function xmldb_quiz_install()
{
    global $DB;
    /// Install logging support
    update_log_display_entry('quiz', 'add', 'quiz', 'name');
    update_log_display_entry('quiz', 'update', 'quiz', 'name');
    update_log_display_entry('quiz', 'view', 'quiz', 'name');
    update_log_display_entry('quiz', 'report', 'quiz', 'name');
    update_log_display_entry('quiz', 'attempt', 'quiz', 'name');
    update_log_display_entry('quiz', 'submit', 'quiz', 'name');
    update_log_display_entry('quiz', 'review', 'quiz', 'name');
    update_log_display_entry('quiz', 'editquestions', 'quiz', 'name');
    update_log_display_entry('quiz', 'preview', 'quiz', 'name');
    update_log_display_entry('quiz', 'start attempt', 'quiz', 'name');
    update_log_display_entry('quiz', 'close attempt', 'quiz', 'name');
    update_log_display_entry('quiz', 'continue attempt', 'quiz', 'name');
    $record = new object();
    $record->name = 'overview';
    $record->displayorder = '10000';
    $DB->insert_record('quiz_report', $record);
    $record = new object();
    $record->name = 'responses';
    $record->displayorder = '9000';
    $DB->insert_record('quiz_report', $record);
    $record = new object();
    $record->name = 'grading';
    $record->displayorder = '6000';
    $DB->insert_record('quiz_report', $record);
}
Esempio n. 3
0
function xmldb_resource_install()
{
    global $DB;
    /// Install logging support
    update_log_display_entry('resource', 'view', 'resource', 'name');
    update_log_display_entry('resource', 'update', 'resource', 'name');
    update_log_display_entry('resource', 'add', 'resource', 'name');
}
Esempio n. 4
0
function xmldb_lesson_install()
{
    global $DB;
    /// Install logging support
    update_log_display_entry('lesson', 'start', 'lesson', 'name');
    update_log_display_entry('lesson', 'end', 'lesson', 'name');
    update_log_display_entry('lesson', 'view', 'lesson_pages', 'title');
}
Esempio n. 5
0
function xmldb_assignment_install()
{
    global $DB;
    /// Install logging support
    update_log_display_entry('assignment', 'view', 'assignment', 'name');
    update_log_display_entry('assignment', 'add', 'assignment', 'name');
    update_log_display_entry('assignment', 'update', 'assignment', 'name');
    update_log_display_entry('assignment', 'view submission', 'assignment', 'name');
    update_log_display_entry('assignment', 'upload', 'assignment', 'name');
}
Esempio n. 6
0
function xmldb_chat_install()
{
    global $DB;
    /// Install logging support
    update_log_display_entry('chat', 'view', 'chat', 'name');
    update_log_display_entry('chat', 'add', 'chat', 'name');
    update_log_display_entry('chat', 'update', 'chat', 'name');
    update_log_display_entry('chat', 'report', 'chat', 'name');
    update_log_display_entry('chat', 'talk', 'chat', 'name');
}
Esempio n. 7
0
/**
 * @package   turnitintool
 * @copyright 2012 Turnitin
 */
function xmldb_turnitintool_install()
{
    global $DB;
    if (!is_callable(array($DB, 'get_record'))) {
        /// Install logging support (pre 2.0 only)
        update_log_display_entry('turnitintool', 'view', 'turnitintool', 'name');
        update_log_display_entry('turnitintool', 'add', 'turnitintool', 'name');
        update_log_display_entry('turnitintool', 'update', 'turnitintool', 'name');
    }
}
Esempio n. 8
0
function xmldb_feedback_install()
{
    global $DB;
    /// Install logging support
    update_log_display_entry('feedback', 'startcomplete', 'feedback', 'name');
    update_log_display_entry('feedback', 'submit', 'feedback', 'name');
    update_log_display_entry('feedback', 'delete', 'feedback', 'name');
    update_log_display_entry('feedback', 'view', 'feedback', 'name');
    update_log_display_entry('feedback', 'view all', 'course', 'shortname');
}
Esempio n. 9
0
/**
 * Post installation and migration code.
 *
 * This file replaces:
 *   - STATEMENTS section in db/install.xml
 *   - lib.php/modulename_install() post installation hook
 *   - partially defaults.php
 *
 * @package   mod-imscp
 * @copyright 2009 Petr Skoda (http://skodak.org)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_imscp_install()
{
    global $CFG;
    // Install logging support
    update_log_display_entry('imscp', 'view', 'imscp', 'name');
    update_log_display_entry('imscp', 'view all', 'imscp', 'name');
    update_log_display_entry('imscp', 'update', 'imscp', 'name');
    update_log_display_entry('imscp', 'add', 'imscp', 'name');
    // Upgrade from old resource module type if needed
    require_once "{$CFG->dirroot}/mod/imscp/db/upgradelib.php";
    imscp_20_migrate();
}
Esempio n. 10
0
function xmldb_data_install()
{
    global $DB;
    /// Install logging support
    update_log_display_entry('data', 'view', 'data', 'name');
    update_log_display_entry('data', 'add', 'data', 'name');
    update_log_display_entry('data', 'update', 'data', 'name');
    update_log_display_entry('data', 'record delete', 'data', 'name');
    update_log_display_entry('data', 'fields add', 'data_fields', 'name');
    update_log_display_entry('data', 'fields update', 'data_fields', 'name');
    update_log_display_entry('data', 'templates saved', 'data', 'name');
    update_log_display_entry('data', 'templates def', 'data', 'name');
}
Esempio n. 11
0
/**
 * Post installation and migration code.
 *
 * This file replaces:
 *   - STATEMENTS section in db/install.xml
 *   - lib.php/modulename_install() post installation hook
 *   - partially defaults.php
 *
 * @package   mod-url
 * @copyright 2009 Petr Skoda (http://skodak.org)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_url_install()
{
    global $CFG;
    // Install logging support
    update_log_display_entry('url', 'view', 'url', 'name');
    update_log_display_entry('url', 'view all', 'url', 'name');
    update_log_display_entry('url', 'update', 'url', 'name');
    update_log_display_entry('url', 'add', 'url', 'name');
    // migrate settings if present
    if (!empty($CFG->resource_secretphrase)) {
        set_config('secretphrase', $CFG->resource_secretphrase, 'url');
    }
    unset_config('resource_secretphrase');
    // Upgrade from old resource module type if needed
    require_once "{$CFG->dirroot}/mod/url/db/upgradelib.php";
    url_20_migrate();
}
Esempio n. 12
0
function xmldb_forum_install()
{
    global $DB;
    /// Install logging support
    update_log_display_entry('forum', 'add', 'forum', 'name');
    update_log_display_entry('forum', 'update', 'forum', 'name');
    update_log_display_entry('forum', 'add discussion', 'forum_discussions', 'name');
    update_log_display_entry('forum', 'add post', 'forum_posts', 'subject');
    update_log_display_entry('forum', 'update post', 'forum_posts', 'subject');
    update_log_display_entry('forum', 'user report', 'user', 'CONCAT(firstname," ",lastname)');
    update_log_display_entry('forum', 'move discussion', 'forum_discussions', 'name');
    update_log_display_entry('forum', 'view subscribers', 'forum', 'name');
    update_log_display_entry('forum', 'view discussion', 'forum_discussions', 'name');
    update_log_display_entry('forum', 'view forum', 'forum', 'name');
    update_log_display_entry('forum', 'subscribe', 'forum', 'name');
    update_log_display_entry('forum', 'unsubscribe', 'forum', 'name');
}
Esempio n. 13
0
function xmldb_glossary_install()
{
    global $DB;
    /// Install logging support
    update_log_display_entry('glossary', 'add', 'glossary', 'name');
    update_log_display_entry('glossary', 'update', 'glossary', 'name');
    update_log_display_entry('glossary', 'view', 'glossary', 'name');
    update_log_display_entry('glossary', 'view all', 'glossary', 'name');
    update_log_display_entry('glossary', 'add entry', 'glossary', 'name');
    update_log_display_entry('glossary', 'update entry', 'glossary', 'name');
    update_log_display_entry('glossary', 'add category', 'glossary', 'name');
    update_log_display_entry('glossary', 'update category', 'glossary', 'name');
    update_log_display_entry('glossary', 'delete category', 'glossary', 'name');
    update_log_display_entry('glossary', 'add comment', 'glossary', 'name');
    update_log_display_entry('glossary', 'update comment', 'glossary', 'name');
    update_log_display_entry('glossary', 'delete comment', 'glossary', 'name');
    update_log_display_entry('glossary', 'approve entry', 'glossary', 'name');
    update_log_display_entry('glossary', 'view entry', 'glossary_entries', 'concept');
}
Esempio n. 14
0
function xmldb_survey_install()
{
    global $DB;
    /// Install logging support
    update_log_display_entry('survey', 'add', 'survey', 'name');
    update_log_display_entry('survey', 'update', 'survey', 'name');
    update_log_display_entry('survey', 'download', 'survey', 'name');
    update_log_display_entry('survey', 'view form', 'survey', 'name');
    update_log_display_entry('survey', 'view graph', 'survey', 'name');
    update_log_display_entry('survey', 'view report', 'survey', 'name');
    update_log_display_entry('survey', 'submit', 'survey', 'name');
    /// insert survey data
    $records = array(array_combine(array('course', 'template', 'days', 'timecreated', 'timemodified', 'name', 'intro', 'questions'), array(0, 0, 0, 985017600, 985017600, 'collesaname', 'collesaintro', '25,26,27,28,29,30,43,44')), array_combine(array('course', 'template', 'days', 'timecreated', 'timemodified', 'name', 'intro', 'questions'), array(0, 0, 0, 985017600, 985017600, 'collespname', 'collespintro', '31,32,33,34,35,36,43,44')), array_combine(array('course', 'template', 'days', 'timecreated', 'timemodified', 'name', 'intro', 'questions'), array(0, 0, 0, 985017600, 985017600, 'collesapname', 'collesapintro', '37,38,39,40,41,42,43,44')), array_combine(array('course', 'template', 'days', 'timecreated', 'timemodified', 'name', 'intro', 'questions'), array(0, 0, 0, 985017600, 985017600, 'attlsname', 'attlsintro', '65,67,68')), array_combine(array('course', 'template', 'days', 'timecreated', 'timemodified', 'name', 'intro', 'questions'), array(0, 0, 0, 985017600, 985017600, 'ciqname', 'ciqintro', '69,70,71,72,73')));
    foreach ($records as $record) {
        $DB->insert_record('survey', $record, false);
    }
    $records = array(array_combine(array('text', 'shorttext', 'type', 'options'), array('colles1', 'colles1short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles2', 'colles2short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles3', 'colles3short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles4', 'colles4short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles5', 'colles5short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles6', 'colles6short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles7', 'colles7short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles8', 'colles8short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles9', 'colles9short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles10', 'colles10short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles11', 'colles11short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles12', 'colles12short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles13', 'colles13short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles14', 'colles14short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles15', 'colles15short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles16', 'colles16short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles17', 'colles17short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles18', 'colles18short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles19', 'colles19short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles20', 'colles20short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles21', 'colles21short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles22', 'colles22short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles23', 'colles23short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('colles24', 'colles24short', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm1', 'collesm1short', '1,2,3,4', 'collesmintro', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm2', 'collesm2short', '5,6,7,8', 'collesmintro', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm3', 'collesm3short', '9,10,11,12', 'collesmintro', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm4', 'collesm4short', '13,14,15,16', 'collesmintro', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm5', 'collesm5short', '17,18,19,20', 'collesmintro', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm6', 'collesm6short', '21,22,23,24', 'collesmintro', 1, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm1', 'collesm1short', '1,2,3,4', 'collesmintro', 2, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm2', 'collesm2short', '5,6,7,8', 'collesmintro', 2, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm3', 'collesm3short', '9,10,11,12', 'collesmintro', 2, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm4', 'collesm4short', '13,14,15,16', 'collesmintro', 2, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm5', 'collesm5short', '17,18,19,20', 'collesmintro', 2, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm6', 'collesm6short', '21,22,23,24', 'collesmintro', 2, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm1', 'collesm1short', '1,2,3,4', 'collesmintro', 3, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm2', 'collesm2short', '5,6,7,8', 'collesmintro', 3, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm3', 'collesm3short', '9,10,11,12', 'collesmintro', 3, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm4', 'collesm4short', '13,14,15,16', 'collesmintro', 3, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm5', 'collesm5short', '17,18,19,20', 'collesmintro', 3, 'scaletimes5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('collesm6', 'collesm6short', '21,22,23,24', 'collesmintro', 3, 'scaletimes5')), array_combine(array('text', 'type', 'options'), array('howlong', 1, 'howlongoptions')), array_combine(array('text', 'type'), array('othercomments', 0)), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls1', 'attls1short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls2', 'attls2short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls3', 'attls3short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls4', 'attls4short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls5', 'attls5short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls6', 'attls6short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls7', 'attls7short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls8', 'attls8short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls9', 'attls9short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls10', 'attls10short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls11', 'attls11short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls12', 'attls12short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls13', 'attls13short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls14', 'attls14short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls15', 'attls15short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls16', 'attls16short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls17', 'attls17short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls18', 'attls18short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls19', 'attls19short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type', 'options'), array('attls20', 'attls20short', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('attlsm1', 'attlsm1', '45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64', 'attlsmintro', 1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('-', '-', '-', '-', 0, '-')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('attlsm2', 'attlsm2', '63,62,59,57,55,49,52,50,48,47', 'attlsmintro', -1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'multi', 'intro', 'type', 'options'), array('attlsm3', 'attlsm3', '46,54,45,51,60,53,56,58,61,64', 'attlsmintro', -1, 'scaleagree5')), array_combine(array('text', 'shorttext', 'type'), array('ciq1', 'ciq1short', 0)), array_combine(array('text', 'shorttext', 'type'), array('ciq2', 'ciq2short', 0)), array_combine(array('text', 'shorttext', 'type'), array('ciq3', 'ciq3short', 0)), array_combine(array('text', 'shorttext', 'type'), array('ciq4', 'ciq4short', 0)), array_combine(array('text', 'shorttext', 'type'), array('ciq5', 'ciq5short', 0)));
    foreach ($records as $record) {
        $DB->insert_record('survey_questions', $record, false);
    }
}
Esempio n. 15
0
function xmldb_main_install()
{
    global $CFG, $DB, $SITE;
    /// make sure system context exists
    $syscontext = get_system_context(false);
    if ($syscontext->id != 1) {
        throw new moodle_exception('generalexceptionmessage', 'error', '', 'Unexpected system context id created!');
    }
    // create site course
    $newsite = new object();
    $newsite->fullname = "";
    $newsite->shortname = "";
    $newsite->summary = NULL;
    $newsite->newsitems = 3;
    $newsite->numsections = 0;
    $newsite->category = 0;
    $newsite->format = 'site';
    // Only for this course
    $newsite->teacher = get_string("defaultcourseteacher");
    $newsite->teachers = get_string("defaultcourseteachers");
    $newsite->student = get_string("defaultcoursestudent");
    $newsite->students = get_string("defaultcoursestudents");
    $newsite->timemodified = time();
    $DB->insert_record('course', $newsite);
    $SITE = get_site();
    if ($SITE->id != 1) {
        throw new moodle_exception('generalexceptionmessage', 'error', '', 'Unexpected site course id created!');
    }
    /// make sure site course context exists
    get_context_instance(CONTEXT_COURSE, $SITE->id);
    /// create default course category
    $cat = get_course_category();
    $defaults = array('rolesactive' => '0', 'auth' => 'email', 'auth_pop3mailbox' => 'INBOX', 'enrol' => 'manual', 'enrol_plugins_enabled' => 'manual', 'style' => 'default', 'template' => 'default', 'theme' => 'standardwhite', 'filter_multilang_converted' => 1, 'siteidentifier' => random_string(32) . get_host_from_url($CFG->wwwroot), 'backup_version' => 2008111700, 'backup_release' => '2.0 dev', 'blocks_version' => 2007081300, 'mnet_dispatcher_mode' => 'off', 'sessiontimeout' => 7200, 'stringfilters' => '', 'filterall' => 0, 'texteditors' => 'tinymce,textarea');
    foreach ($defaults as $key => $value) {
        set_config($key, $value);
    }
    /// bootstrap mnet
    $mnethost = new object();
    $mnethost->wwwroot = $CFG->wwwroot;
    $mnethost->name = '';
    $mnethost->name = '';
    $mnethost->public_key = '';
    if (empty($_SERVER['SERVER_ADDR'])) {
        // SERVER_ADDR is only returned by Apache-like webservers
        preg_match("@^(?:http[s]?://)?([A-Z0-9\\-\\.]+).*@i", $CFG->wwwroot, $matches);
        $my_hostname = $matches[1];
        $my_ip = gethostbyname($my_hostname);
        // Returns unmodified hostname on failure. DOH!
        if ($my_ip == $my_hostname) {
            $mnethost->ip_address = 'UNKNOWN';
        } else {
            $mnethost->ip_address = $my_ip;
        }
    } else {
        $mnethost->ip_address = $_SERVER['SERVER_ADDR'];
    }
    $mnetid = $DB->insert_record('mnet_host', $mnethost);
    set_config('mnet_localhost_id', $mnetid);
    // Initial insert of mnet applications info
    $mnet_app = new object();
    $mnet_app->name = 'moodle';
    $mnet_app->display_name = 'Moodle';
    $mnet_app->xmlrpc_server_url = '/mnet/xmlrpc/server.php';
    $mnet_app->sso_land_url = '/auth/mnet/land.php';
    $mnet_app->sso_jump_url = '/auth/mnet/land.php';
    $DB->insert_record('mnet_application', $mnet_app);
    $mnet_app = new object();
    $mnet_app->name = 'mahara';
    $mnet_app->display_name = 'Mahara';
    $mnet_app->xmlrpc_server_url = '/api/xmlrpc/server.php';
    $mnet_app->sso_land_url = '/auth/xmlrpc/land.php';
    $mnet_app->sso_jump_url = '/auth/xmlrpc/jump.php';
    $DB->insert_record('mnet_application', $mnet_app);
    /// insert log entries - replaces statements section in install.xml
    update_log_display_entry('user', 'view', 'user', 'CONCAT(firstname,\' \',lastname)');
    update_log_display_entry('course', 'user report', 'user', 'CONCAT(firstname,\' \',lastname)');
    update_log_display_entry('course', 'view', 'course', 'fullname');
    update_log_display_entry('course', 'update', 'course', 'fullname');
    update_log_display_entry('course', 'enrol', 'course', 'fullname');
    update_log_display_entry('course', 'unenrol', 'course', 'fullname');
    update_log_display_entry('course', 'report log', 'course', 'fullname');
    update_log_display_entry('course', 'report live', 'course', 'fullname');
    update_log_display_entry('course', 'report outline', 'course', 'fullname');
    update_log_display_entry('course', 'report participation', 'course', 'fullname');
    update_log_display_entry('course', 'report stats', 'course', 'fullname');
    update_log_display_entry('message', 'write', 'user', 'CONCAT(firstname,\' \',lastname)');
    update_log_display_entry('message', 'read', 'user', 'CONCAT(firstname,\' \',lastname)');
    update_log_display_entry('message', 'add contact', 'user', 'CONCAT(firstname,\' \',lastname)');
    update_log_display_entry('message', 'remove contact', 'user', 'CONCAT(firstname,\' \',lastname)');
    update_log_display_entry('message', 'block contact', 'user', 'CONCAT(firstname,\' \',lastname)');
    update_log_display_entry('message', 'unblock contact', 'user', 'CONCAT(firstname,\' \',lastname)');
    update_log_display_entry('group', 'view', 'groups', 'name');
    /// Create guest record
    $guest = new object();
    $guest->auth = 'manual';
    $guest->username = '******';
    $guest->password = hash_internal_user_password('guest');
    $guest->firstname = get_string('guestuser');
    $guest->lastname = ' ';
    $guest->email = 'root@localhost';
    $guest->description = get_string('guestuserinfo');
    $guest->mnethostid = $CFG->mnet_localhost_id;
    $guest->confirmed = 1;
    $guest->lang = $CFG->lang;
    $guest->timemodified = time();
    $guest->id = $DB->insert_record('user', $guest);
    /// Now create admin user
    $admin = new object();
    $admin->auth = 'manual';
    $admin->firstname = get_string('admin');
    $admin->lastname = get_string('user');
    $admin->username = '******';
    $admin->password = '******';
    $admin->email = '';
    $admin->confirmed = 1;
    $admin->mnethostid = $CFG->mnet_localhost_id;
    $admin->lang = $CFG->lang;
    $admin->maildisplay = 1;
    $admin->timemodified = time();
    $admin->lastip = CLI_SCRIPT ? '0.0.0.0' : getremoteaddr();
    // installation hijacking prevention
    $admin->id = $DB->insert_record('user', $admin);
    /// Install the roles system.
    $adminrole = create_role(get_string('administrator'), 'admin', get_string('administratordescription'), 'moodle/legacy:admin');
    $coursecreatorrole = create_role(get_string('coursecreators'), 'coursecreator', get_string('coursecreatorsdescription'), 'moodle/legacy:coursecreator');
    $editteacherrole = create_role(get_string('defaultcourseteacher'), 'editingteacher', get_string('defaultcourseteacherdescription'), 'moodle/legacy:editingteacher');
    $noneditteacherrole = create_role(get_string('noneditingteacher'), 'teacher', get_string('noneditingteacherdescription'), 'moodle/legacy:teacher');
    $studentrole = create_role(get_string('defaultcoursestudent'), 'student', get_string('defaultcoursestudentdescription'), 'moodle/legacy:student');
    $guestrole = create_role(get_string('guest'), 'guest', get_string('guestdescription'), 'moodle/legacy:guest');
    $userrole = create_role(get_string('authenticateduser'), 'user', get_string('authenticateduserdescription'), 'moodle/legacy:user');
    /// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles
    assign_capability('moodle/site:doanything', CAP_ALLOW, $adminrole, $syscontext->id);
    update_capabilities('moodle');
    /// assign default roles
    role_assign($guestrole, $guest->id, 0, $syscontext->id);
    role_assign($adminrole, $admin->id, 0, $syscontext->id);
    /// Default allow assign/override/switch.
    $defaultallows = array($coursecreatorrole => $noneditteacherrole, $coursecreatorrole => $editteacherrole, $coursecreatorrole => $studentrole, $coursecreatorrole => $guestrole, $editteacherrole => $noneditteacherrole, $editteacherrole => $studentrole, $editteacherrole => $guestrole);
    foreach ($defaultallows as $fromroleid => $toroleid) {
        allow_assign($fromroleid, $toroleid);
        allow_override($fromroleid, $toroleid);
        // There is a rant about this in MDL-15841.
        allow_switch($fromroleid, $toroleid);
    }
    allow_switch($noneditteacherrole, $studentrole);
    /// Set up the context levels where you can assign each role.
    set_role_contextlevels($adminrole, get_default_contextlevels('admin'));
    set_role_contextlevels($coursecreatorrole, get_default_contextlevels('coursecreator'));
    set_role_contextlevels($editteacherrole, get_default_contextlevels('editingteacher'));
    set_role_contextlevels($noneditteacherrole, get_default_contextlevels('teacher'));
    set_role_contextlevels($studentrole, get_default_contextlevels('student'));
    set_role_contextlevels($guestrole, get_default_contextlevels('guest'));
    set_role_contextlevels($userrole, get_default_contextlevels('user'));
}
Esempio n. 16
0
/**
 * Resource module upgrade code
 *
 * This file keeps track of upgrades to
 * the resource module
 *
 * Sometimes, changes between versions involve
 * alterations to database structures and other
 * major things that may break installations.
 *
 * The upgrade function in this file will attempt
 * to perform all the necessary actions to upgrade
 * your older installtion to the current version.
 *
 * If there's something it cannot do itself, it
 * will tell you what you need to do.
 *
 * The commands in here will all be database-neutral,
 * using the methods of database_manager class
 *
 * Please do not forget to use upgrade_set_timeout()
 * before any action that may take longer time to finish.
 *
 * @package   mod-resource
 * @copyright 2009 Petr Skoda (http://skodak.org)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_resource_upgrade($oldversion)
{
    global $CFG, $DB;
    require_once "{$CFG->dirroot}/mod/resource/db/upgradelib.php";
    $dbman = $DB->get_manager();
    $result = true;
    //===== 1.9.0 upgrade line ======//
    if ($result && $oldversion < 2009042000) {
        // Rename field summary on table resource to intro
        $table = new xmldb_table('resource');
        $field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'reference');
        // Launch rename field summary
        $dbman->rename_field($table, $field, 'intro');
        // resource savepoint reached
        upgrade_mod_savepoint($result, 2009042000, 'resource');
    }
    if ($result && $oldversion < 2009042001) {
        // Define field introformat to be added to resource
        $table = new xmldb_table('resource');
        $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
        // Launch add field introformat
        $dbman->add_field($table, $field);
        // set format to current
        $DB->set_field('resource', 'introformat', FORMAT_MOODLE, array());
        // resource savepoint reached
        upgrade_mod_savepoint($result, 2009042001, 'resource');
    }
    if ($result && $oldversion < 2009062500) {
        // fix log actions
        update_log_display_entry('resource', 'view all', 'resource', 'name');
        // resource savepoint reached
        upgrade_mod_savepoint($result, 2009062500, 'resource');
    }
    if ($result && $oldversion < 2009062501) {
        resource_20_prepare_migration();
        // resource savepoint reached
        upgrade_mod_savepoint($result, 2009062501, 'resource');
    }
    if ($result && $oldversion < 2009062600) {
        $res_count = $DB->count_records('resource');
        $old_count = $DB->count_records('resource_old', array('migrated' => 0));
        if ($res_count != $old_count) {
            //we can not continue, something is very wrong!!
            upgrade_log(UPGRADE_LOG_ERROR, null, 'Resource migration failed.');
            upgrade_mod_savepoint(false, 2009062600, 'resource');
        }
        // Drop obsoleted fields from resource table
        $table = new xmldb_table('resource');
        $fields = array('type', 'reference', 'alltext', 'popup', 'options');
        foreach ($fields as $fname) {
            $field = new xmldb_field($fname);
            $dbman->drop_field($table, $field);
        }
        // resource savepoint reached
        upgrade_mod_savepoint($result, 2009062600, 'resource');
    }
    if ($result && $oldversion < 2009062601) {
        $table = new xmldb_table('resource');
        // Define field tobemigrated to be added to resource
        $field = new xmldb_field('tobemigrated', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'introformat');
        // Conditionally launch add field tobemigrated
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field mainfile to be added to resource
        $field = new xmldb_field('mainfile', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'tobemigrated');
        // Conditionally launch add field mainfile
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field legacyfiles to be added to resource
        $field = new xmldb_field('legacyfiles', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'mainfile');
        // Conditionally launch add field legacyfiles
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field legacyfileslast to be added to resource
        $field = new xmldb_field('legacyfileslast', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'legacyfiles');
        // Conditionally launch add field legacyfileslast
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field display to be added to resource
        $field = new xmldb_field('display', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'legacyfileslast');
        // Conditionally launch add field display
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field displayoptions to be added to resource
        $field = new xmldb_field('displayoptions', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'display');
        // Conditionally launch add field displayoptions
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field filterfiles to be added to resource
        $field = new xmldb_field('filterfiles', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'displayoptions');
        // Conditionally launch add field filterfiles
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define field revision to be added to resource
        $field = new xmldb_field('revision', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'filterfiles');
        // Conditionally launch add field revision
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        //mark all records as awaiting migration
        $DB->set_field('resource', 'tobemigrated', 1, array());
        // resource savepoint reached
        upgrade_mod_savepoint($result, 2009062601, 'resource');
    }
    if ($result && $oldversion < 2009062603) {
        resource_20_migrate();
        upgrade_mod_savepoint($result, 2009062603, 'resource');
    }
    if ($result && $oldversion < 2009063000) {
        //migrate and prune old settings - admins need to review and set up all module settings anyway
        if (!empty($CFG->resource_framesize)) {
            set_config('framesize', $CFG->resource_framesize, 'resource');
        }
        if (!empty($CFG->resource_popupheight)) {
            set_config('popupheight', $CFG->resource_popupheight, 'resource');
        }
        if (!empty($CFG->resource_popupwidth)) {
            set_config('popupwidth', $CFG->resource_popupwidth, 'resource');
        }
        $cleanupsettings = array('resource_framesize', 'resource_popupheight', 'resource_popupwidth', 'resource_popupmenubar', 'resource_websearch', 'resource_defaulturl', 'resource_allowlocalfiles', 'resource_popup', 'resource_popupresizable', 'resource_popupscrollbars', 'resource_popupdirectories', 'resource_popuplocation', 'resource_popuptoolbar', 'resource_popupstatus');
        foreach ($cleanupsettings as $setting) {
            unset_config($setting);
        }
        upgrade_mod_savepoint($result, 2009063000, 'resource');
    }
    return $result;
}