当前位置: 首页>>代码示例>>PHP>>正文


PHP get_recordset函数代码示例

本文整理汇总了PHP中get_recordset函数的典型用法代码示例。如果您正苦于以下问题:PHP get_recordset函数的具体用法?PHP get_recordset怎么用?PHP get_recordset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_recordset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xmldb_blocktype_taggedposts_upgrade

function xmldb_blocktype_taggedposts_upgrade($oldversion = 0)
{
    if ($oldversion < 2015011500) {
        $table = new XMLDBTable('blocktype_taggedposts_tags');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
        $table->addFieldInfo('block_instance', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
        $table->addFieldInfo('tag', XMLDB_TYPE_CHAR, 128, null, XMLDB_NOTNULL);
        $table->addFieldInfo('tagtype', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('tagtagtypeix', XMLDB_INDEX_NOTUNIQUE, array('tag', 'tagtype'));
        if (!table_exists($table)) {
            create_table($table);
            $rs = get_recordset('block_instance', 'blocktype', 'taggedposts', 'id', 'id, configdata');
            while ($bi = $rs->FetchRow()) {
                // Each block will have only one tag (because we combined this upgrade block
                // with the upgrade block for the "multiple tags" enhancement.
                $configdata = unserialize($bi['configdata']);
                if (!empty($configdata['tagselect'])) {
                    $todb = new stdClass();
                    $todb->block_instance = $bi['id'];
                    $todb->tag = $configdata['tagselect'];
                    $todb->tagtype = PluginBlocktypeTaggedposts::TAGTYPE_INCLUDE;
                    insert_record('blocktype_taggedposts_tags', $todb);
                }
            }
        }
    }
    return true;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:29,代码来源:upgrade.php

示例2: get_all_elements

 function get_all_elements()
 {
     $elements = array();
     $rs = get_recordset('course_categories', '', '', '', 'id');
     while ($course = rs_fetch_next_record($rs)) {
         $elements[] = $course->id;
     }
     return $elements;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:9,代码来源:report.class.php

示例3: allow_override

                allow_override($fromroleid, $targetroleid);
            }
        }
    }
    /// Updated allowoverrides sitewide, so force a premissions refresh, and redirect.
    mark_context_dirty($systemcontext->path);
    add_to_log(SITEID, 'role', 'edit allow override', 'admin/roles/allowoverride.php', '', '', $USER->id);
    redirect($CFG->wwwroot . '/' . $CFG->admin . '/roles/allowoverride.php');
}
/// Load the current settings
$allowed = array();
foreach ($roles as $role) {
    // Make an array $role->id => false. This is probalby too clever for its own good.1
    $allowed[$role->id] = array_combine(array_keys($roles), array_fill(0, count($roles), false));
}
$raas = get_recordset('role_allow_override');
foreach ($raas as $raa) {
    $raa = (object) $raa;
    $allowed[$raa->roleid][$raa->allowoverride] = true;
}
/// Display the editing form.
admin_externalpage_setup('defineroles', '', array(), $CFG->wwwroot . '/' . $CFG->admin . '/roles/allowoverride.php');
admin_externalpage_print_header();
$currenttab = 'allowoverride';
require_once 'managetabs.php';
$table->tablealign = 'center';
$table->cellpadding = 5;
$table->cellspacing = 0;
$table->width = '90%';
$table->align[] = 'left';
$table->rotateheaders = true;
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:allowoverride.php

示例4: backup_messages

function backup_messages($bf, $preferences)
{
    global $CFG;
    $status = true;
    /// Check we have something to backup
    $unreads = count_records('message');
    $reads = count_records('message_read');
    $contacts = count_records('message_contacts');
    if ($unreads || $reads || $contacts) {
        $counter = 0;
        /// message open tag
        fwrite($bf, start_tag("MESSAGES", 2, true));
        if ($unreads) {
            $rs_unreads = get_recordset('message');
            /// Iterate over every unread
            while ($unread = rs_fetch_next_record($rs_unreads)) {
                /// start message
                fwrite($bf, start_tag("MESSAGE", 3, true));
                fwrite($bf, full_tag("ID", 4, false, $unread->id));
                fwrite($bf, full_tag("STATUS", 4, false, "UNREAD"));
                fwrite($bf, full_tag("USERIDFROM", 4, false, $unread->useridfrom));
                fwrite($bf, full_tag("USERIDTO", 4, false, $unread->useridto));
                fwrite($bf, full_tag("MESSAGE", 4, false, $unread->message));
                fwrite($bf, full_tag("FORMAT", 4, false, $unread->format));
                fwrite($bf, full_tag("TIMECREATED", 4, false, $unread->timecreated));
                fwrite($bf, full_tag("MESSAGETYPE", 4, false, $unread->messagetype));
                /// end message
                fwrite($bf, end_tag("MESSAGE", 3, true));
                /// Do some output
                $counter++;
                if ($counter % 20 == 0) {
                    echo ".";
                    if ($counter % 400 == 0) {
                        echo "<br />";
                    }
                    backup_flush(300);
                }
            }
            rs_close($rs_unreads);
        }
        if ($reads) {
            $rs_reads = get_recordset('message_read');
            /// Iterate over every unread
            while ($read = rs_fetch_next_record($rs_reads)) {
                /// start message
                fwrite($bf, start_tag("MESSAGE", 3, true));
                fwrite($bf, full_tag("ID", 4, false, $read->id));
                fwrite($bf, full_tag("STATUS", 4, false, "READ"));
                fwrite($bf, full_tag("USERIDFROM", 4, false, $read->useridfrom));
                fwrite($bf, full_tag("USERIDTO", 4, false, $read->useridto));
                fwrite($bf, full_tag("MESSAGE", 4, false, $read->message));
                fwrite($bf, full_tag("FORMAT", 4, false, $read->format));
                fwrite($bf, full_tag("TIMECREATED", 4, false, $read->timecreated));
                fwrite($bf, full_tag("MESSAGETYPE", 4, false, $read->messagetype));
                fwrite($bf, full_tag("TIMEREAD", 4, false, $read->timeread));
                fwrite($bf, full_tag("MAILED", 4, false, $read->mailed));
                /// end message
                fwrite($bf, end_tag("MESSAGE", 3, true));
                /// Do some output
                $counter++;
                if ($counter % 20 == 0) {
                    echo ".";
                    if ($counter % 400 == 0) {
                        echo "<br />";
                    }
                    backup_flush(300);
                }
            }
            rs_close($rs_reads);
        }
        if ($contacts) {
            fwrite($bf, start_tag("CONTACTS", 3, true));
            $rs_contacts = get_recordset('message_contacts');
            /// Iterate over every contact
            while ($contact = rs_fetch_next_record($rs_contacts)) {
                /// start contact
                fwrite($bf, start_tag("CONTACT", 4, true));
                fwrite($bf, full_tag("ID", 5, false, $contact->id));
                fwrite($bf, full_tag("USERID", 5, false, $contact->userid));
                fwrite($bf, full_tag("CONTACTID", 5, false, $contact->contactid));
                fwrite($bf, full_tag("BLOCKED", 5, false, $contact->blocked));
                /// end contact
                fwrite($bf, end_tag("CONTACT", 4, true));
                /// Do some output
                $counter++;
                if ($counter % 20 == 0) {
                    echo ".";
                    if ($counter % 400 == 0) {
                        echo "<br />";
                    }
                    backup_flush(300);
                }
            }
            rs_close($rs_contacts);
            fwrite($bf, end_tag("CONTACTS", 3, true));
        }
        /// messages close tag
        $status = fwrite($bf, end_tag("MESSAGES", 2, true));
    }
    return $status;
//.........这里部分代码省略.........
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:101,代码来源:backuplib.php

示例5: get_records_menu

/**
 * Get the first two columns from a number of records as an associative array.
 *
 * Arguments as for @see function get_recordset.
 * 
 * If no errors occur, and at least one records is found, the return value
 * is an associative whose keys come from the first field of each record,
 * and whose values are the corresponding second fields. If no records are found,
 * or an error occurs, false is returned.
 *
 * @param string $table the table to query.
 * @param string $field a field to check (optional).
 * @param string $value the value the field must have (requred if field1 is given, else optional).
 * @param string $sort an order to sort the results in (optional, a valid SQL ORDER BY parameter).
 * @param string $fields a comma separated list of fields to return (optional, by default all fields are returned).
 * @return mixed an associative array, or false if no records were found or an error occured.
 */
function get_records_menu($table, $field = '', $value = '', $sort = '', $fields = '*')
{
    $rs = get_recordset($table, $field, $value, $sort, $fields);
    return recordset_to_menu($rs);
}
开发者ID:pzingg,项目名称:saugus_elgg,代码行数:22,代码来源:datalib.php

示例6: xmldb_main_upgrade


//.........这里部分代码省略.........
        $table->addKeyInfo('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
        $table->addKeyInfo('rawscaleid', XMLDB_KEY_FOREIGN, array('rawscaleid'), 'scale', array('id'));
        $table->addKeyInfo('usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
        $table->addKeyInfo('loggeduser', XMLDB_KEY_FOREIGN, array('loggeduser'), 'user', array('id'));
        /// Adding indexes to table grade_grades_history
        $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
        /// Launch create table for grade_grades_history
        $result = $result && create_table($table);
        /// Define table scale_history to be created
        $table = new XMLDBTable('scale_history');
        /// Adding fields to table scale_history
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('action', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
        $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
        $table->addFieldInfo('loggeduser', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('scale', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('description', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table scale_history
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'scale', array('id'));
        $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
        $table->addKeyInfo('loggeduser', XMLDB_KEY_FOREIGN, array('loggeduser'), 'user', array('id'));
        /// Adding indexes to table scale_history
        $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
        /// Launch create table for scale_history
        $result = $result && create_table($table);
        /// upgrade the old 1.8 gradebook - migrade data into new grade tables
        if ($result) {
            if ($rs = get_recordset('course')) {
                while ($course = rs_fetch_next_record($rs)) {
                    // this function uses SQL only, it must not be changed after 1.9 goes stable!!
                    if (!upgrade_18_gradebook($course->id)) {
                        $result = false;
                        break;
                    }
                }
                rs_close($rs);
            }
        }
        upgrade_main_savepoint($result, 2007072200);
    }
    if ($result && $oldversion < 2007072400) {
        /// Dropping one DEFAULT in a TEXT column. It's was only one remaining
        /// since Moodle 1.7, so new servers won't have those anymore.
        /// Changing the default of field sessdata on table sessions2 to drop it
        $table = new XMLDBTable('sessions2');
        $field = new XMLDBField('sessdata');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'modified');
        /// Launch change of default for field sessdata
        $result = $result && change_field_default($table, $field);
        upgrade_main_savepoint($result, 2007072400);
    }
    if ($result && $oldversion < 2007073100) {
        /// Define table grade_outcomes_courses to be created
        $table = new XMLDBTable('grade_outcomes_courses');
        /// Adding fields to table grade_outcomes_courses
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('outcomeid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table grade_outcomes_courses
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:67,代码来源:upgrade.php

示例7: moodle_install_roles

/**
 * Installs the roles system.
 * This function runs on a fresh install as well as on an upgrade from the old
 * hard-coded student/teacher/admin etc. roles to the new roles system.
 */
function moodle_install_roles()
{
    global $CFG, $db;
    /// Create a system wide context for assignemnt.
    $systemcontext = $context = get_context_instance(CONTEXT_SYSTEM);
    /// Create default/legacy roles and capabilities.
    /// (1 legacy capability per legacy role at system level).
    $adminrole = create_role(addslashes(get_string('administrator')), 'admin', addslashes(get_string('administratordescription')), 'moodle/legacy:admin');
    $coursecreatorrole = create_role(addslashes(get_string('coursecreators')), 'coursecreator', addslashes(get_string('coursecreatorsdescription')), 'moodle/legacy:coursecreator');
    $editteacherrole = create_role(addslashes(get_string('defaultcourseteacher')), 'editingteacher', addslashes(get_string('defaultcourseteacherdescription')), 'moodle/legacy:editingteacher');
    $noneditteacherrole = create_role(addslashes(get_string('noneditingteacher')), 'teacher', addslashes(get_string('noneditingteacherdescription')), 'moodle/legacy:teacher');
    $studentrole = create_role(addslashes(get_string('defaultcoursestudent')), 'student', addslashes(get_string('defaultcoursestudentdescription')), 'moodle/legacy:student');
    $guestrole = create_role(addslashes(get_string('guest')), 'guest', addslashes(get_string('guestdescription')), 'moodle/legacy:guest');
    $userrole = create_role(addslashes(get_string('authenticateduser')), 'user', addslashes(get_string('authenticateduserdescription')), 'moodle/legacy:user');
    /// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles
    if (!assign_capability('moodle/site:doanything', CAP_ALLOW, $adminrole, $systemcontext->id)) {
        error('Could not assign moodle/site:doanything to the admin role');
    }
    if (!update_capabilities()) {
        error('Had trouble upgrading the core capabilities for the Roles System');
    }
    /// Look inside user_admin, user_creator, user_teachers, user_students and
    /// assign above new roles. If a user has both teacher and student role,
    /// only teacher role is assigned. The assignment should be system level.
    $dbtables = $db->MetaTables('TABLES');
    /// Set up the progress bar
    $usertables = array('user_admins', 'user_coursecreators', 'user_teachers', 'user_students');
    $totalcount = $progresscount = 0;
    foreach ($usertables as $usertable) {
        if (in_array($CFG->prefix . $usertable, $dbtables)) {
            $totalcount += count_records($usertable);
        }
    }
    print_progress(0, $totalcount, 5, 1, 'Processing role assignments');
    /// Upgrade the admins.
    /// Sort using id ASC, first one is primary admin.
    if (in_array($CFG->prefix . 'user_admins', $dbtables)) {
        if ($rs = get_recordset_sql('SELECT * from ' . $CFG->prefix . 'user_admins ORDER BY ID ASC')) {
            while ($admin = rs_fetch_next_record($rs)) {
                role_assign($adminrole, $admin->userid, 0, $systemcontext->id);
                $progresscount++;
                print_progress($progresscount, $totalcount, 5, 1, 'Processing role assignments');
            }
            rs_close($rs);
        }
    } else {
        // This is a fresh install.
    }
    /// Upgrade course creators.
    if (in_array($CFG->prefix . 'user_coursecreators', $dbtables)) {
        if ($rs = get_recordset('user_coursecreators')) {
            while ($coursecreator = rs_fetch_next_record($rs)) {
                role_assign($coursecreatorrole, $coursecreator->userid, 0, $systemcontext->id);
                $progresscount++;
                print_progress($progresscount, $totalcount, 5, 1, 'Processing role assignments');
            }
            rs_close($rs);
        }
    }
    /// Upgrade editting teachers and non-editting teachers.
    if (in_array($CFG->prefix . 'user_teachers', $dbtables)) {
        if ($rs = get_recordset('user_teachers')) {
            while ($teacher = rs_fetch_next_record($rs)) {
                // removed code here to ignore site level assignments
                // since the contexts are separated now
                // populate the user_lastaccess table
                $access = new object();
                $access->timeaccess = $teacher->timeaccess;
                $access->userid = $teacher->userid;
                $access->courseid = $teacher->course;
                insert_record('user_lastaccess', $access);
                // assign the default student role
                $coursecontext = get_context_instance(CONTEXT_COURSE, $teacher->course);
                // needs cache
                // hidden teacher
                if ($teacher->authority == 0) {
                    $hiddenteacher = 1;
                } else {
                    $hiddenteacher = 0;
                }
                if ($teacher->editall) {
                    // editting teacher
                    role_assign($editteacherrole, $teacher->userid, 0, $coursecontext->id, $teacher->timestart, $teacher->timeend, $hiddenteacher, $teacher->enrol, $teacher->timemodified);
                } else {
                    role_assign($noneditteacherrole, $teacher->userid, 0, $coursecontext->id, $teacher->timestart, $teacher->timeend, $hiddenteacher, $teacher->enrol, $teacher->timemodified);
                }
                $progresscount++;
                print_progress($progresscount, $totalcount, 5, 1, 'Processing role assignments');
            }
            rs_close($rs);
        }
    }
    /// Upgrade students.
    if (in_array($CFG->prefix . 'user_students', $dbtables)) {
        if ($rs = get_recordset('user_students')) {
//.........这里部分代码省略.........
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:accesslib.php

示例8: print_header

}
print_header();
if (empty($_POST['goahead'])) {
    print '<p>Are you sure you want to wipe all the load test data?</p>';
    print '<form enctype="multipart/form-data" action="wipe.php" method="post">
<input type="hidden" name="goahead" value="1" />
<input type="submit" value="Do it!"/>
</form>';
    print_footer();
    exit;
}
print '<ul><li>Deleting occurences</li>';
flush();
$before = get_field_sql('SELECT COUNT(*) FROM ' . $CFG->prefix . 'block_ousearch_occurrences');
$count = 0;
$rs = get_recordset('block_ousearch_documents', 'plugin', 'test/test', '', 'id');
while ($rec = rs_fetch_next_record($rs)) {
    delete_records('block_ousearch_occurrences', 'documentid', $rec->id);
    delete_records('block_ousearch_documents', 'id', $rec->id);
    $count++;
}
rs_close($rs);
$after = get_field_sql('SELECT COUNT(*) FROM ' . $CFG->prefix . 'block_ousearch_occurrences');
$occurrences = $before - $after;
print "<li>{$count} documents deleted ({$occurrences} occurrences)</li>";
flush();
$before = get_field_sql('SELECT COUNT(*) FROM ' . $CFG->prefix . 'block_ousearch_words');
delete_records_select('block_ousearch_words', 'NOT(id IN (select wordid FROM ' . $CFG->prefix . 'block_ousearch_occurrences))');
$after = get_field_sql('SELECT COUNT(*) FROM ' . $CFG->prefix . 'block_ousearch_words');
$words = $before - $after;
print "<li>{$words} words deleted</li></ul>";
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:wipe.php

示例9: get_recordset

 static function get_recordset($table, $field = '', $value = '', $sort = '', $fields = '*', $limitfrom = '', $limitnum = '')
 {
     $rs = get_recordset($table, $field, $value, $sort, $fields, $limitfrom, $limitnum);
     if (!$rs) {
         throw new forum_exception("Failed to get SQL recordset for {$sql}");
     }
     return $rs;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:8,代码来源:forum_utils.php

示例10: create_from_old_forum


//.........这里部分代码省略.........
         $newcm->completion = $cm->completion;
         $newcm->completiongradeitemnumber = $cm->completiongradeitemnumber;
         $newcm->completionview = $cm->completionview;
         $newcm->availablefrom = $cm->availablefrom;
         $newcm->availableuntil = $cm->availableuntil;
         $newcm->showavailability = $cm->showavailability;
         $newcm->parentpagename = $cm->parentpagename;
     }
     // Add
     $newcm->id = forum_utils::insert_record('course_modules', $newcm);
     // Update section
     if ($insection) {
         $section = forum_utils::get_record('course_sections', 'id', $newcm->section);
         $updatesection = (object) array('id' => $section->id, 'sequence' => str_replace($cm->id, $cm->id . ',' . $newcm->id, $section->sequence));
         if ($updatesection->sequence == $section->sequence) {
             throw new forum_exception("Unable to update sequence");
         }
         forum_utils::update_record('course_sections', $updatesection);
     }
     // Construct forum object for new forum
     $newforum = self::get_from_id($forumng->id, forum::CLONE_DIRECT);
     if ($progress) {
         print ' ' . get_string('convert_process_state_done', 'forumng') . '</li>';
     }
     if (!$nodata) {
         // Convert subscriptions
         switch ($newforum->get_effective_subscription_option()) {
             case self::SUBSCRIPTION_PERMITTED:
                 if ($progress) {
                     print '<li>' . get_string('convert_process_subscriptions_normal', 'forumng');
                     flush();
                 }
                 // Standard subscription - just copy subscriptions
                 $rs = forum_utils::get_recordset('forum_subscriptions', 'forum', $forum->id);
                 while ($rec = rs_fetch_next_record($rs)) {
                     forum_utils::insert_record('forumng_subscriptions', (object) array('forumid' => $forumng->id, 'userid' => $rec->userid, 'subscribed' => 1));
                 }
                 rs_close($rs);
                 if ($progress) {
                     print ' ' . get_string('convert_process_state_done', 'forumng') . '</li>';
                 }
                 break;
             case self::SUBSCRIPTION_INITIALLY_SUBSCRIBED:
                 // Initial subscription is handled differently; the old forum
                 // stores all the subscriptions in the database, while in this
                 // forum we only store people who chose to unsubscribe
                 if ($progress) {
                     print '<li>' . get_string('convert_process_subscriptions_initial', 'forumng');
                     flush();
                 }
                 // Get list of those subscribed on old forum
                 $rs = forum_utils::get_recordset('forum_subscriptions', 'forum', $forum->id);
                 $subscribedbefore = array();
                 while ($rec = rs_fetch_next_record($rs)) {
                     $subscribedbefore[$rec->userid] = true;
                 }
                 rs_close();
                 // Get list of those subscribed on new forum
                 $new = $newforum->get_subscribers();
                 // For anyone in the new list but not the old list, add an
                 // unsubscribe
                 foreach ($new as $user) {
                     if (!array_key_exists($user->id, $subscribedbefore)) {
                         forum_utils::insert_record('forumng_subscriptions', (object) array('forumid' => $forumng->id, 'userid' => $user->id, 'subscribed' => 0));
                     }
                 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:67,代码来源:forum.php

示例11: xmldb_ouwiki_upgrade


//.........这里部分代码省略.........
        $key = new XMLDBKey('oucontent_comments_pagesectionid_fk');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('pagesectionid'), 'ouwiki_sections', array('id'));
        /// Launch drop key oucontent_comments_pagesectionid_fk
        $result = $result && drop_key($table, $key);
        /// Define key ouwiki_comments_sectionid_fk (foreign) to be added to ouwiki_comments
        $table = new XMLDBTable('ouwiki_comments');
        $key = new XMLDBKey('ouwiki_comments_sectionid_fk');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('sectionid'), 'ouwiki_sections', array('id'));
        /// Launch add key oucontent_comments_sectionid_fk
        $result = $result && add_key($table, $key);
    }
    if ($result && $oldversion < 2007041701) {
        /// Define key oucontent_comments_userid_fk (foreign) to be dropped form ouwiki_comments
        $table = new XMLDBTable('ouwiki_comments');
        $key = new XMLDBKey('oucontent_comments_userid_fk');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
        /// Launch drop key oucontent_comments_userid_fk
        $result = $result && drop_key($table, $key);
        /// Define key ouwiki_comments_userid_fk (foreign) to be added to ouwiki_comments
        $table = new XMLDBTable('ouwiki_comments');
        $key = new XMLDBKey('ouwiki_comments_userid_fk');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
        /// Launch add key ouwiki_comments_userid_fk
        $result = $result && add_key($table, $key);
    }
    if ($result && $oldversion < 2007102900) {
        /// Define field magic to be added to ouwiki_subwikis
        $table = new XMLDBTable('ouwiki_subwikis');
        $field = new XMLDBField('magic');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '16', XMLDB_UNSIGNED, null, null, null, null, null, 'userid');
        /// Launch add field magic
        $result = $result && add_field($table, $field);
        /// Set up all existing field values
        $rs = get_recordset('ouwiki_subwikis', '', '', '', 'id');
        while ($rec = rs_fetch_next_record($rs)) {
            $magicnumber = ouwiki_generate_magic_number();
            set_field('ouwiki_subwikis', 'magic', $magicnumber, 'id', $rec->id);
        }
        rs_close($rs);
        /// Changing nullability of field magic on table ouwiki_subwikis to not null
        $field->setAttributes(XMLDB_TYPE_INTEGER, '16', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'userid');
        /// Launch change of nullability for field magic
        $result = $result && change_field_notnull($table, $field);
    }
    if ($result && $oldversion < 2008073000) {
        /// Define field completionpages to be added to ouwiki
        $table = new XMLDBTable('ouwiki');
        $field = new XMLDBField('completionpages');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '9', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'editend');
        /// Launch add field completionpages
        $result = $result && add_field($table, $field);
        /// Define field completionedits to be added to ouwiki
        $field = new XMLDBField('completionedits');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '9', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'completionpages');
        /// Launch add field completionedits
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2008100600) {
        /// Define field deletedat to be added to ouwiki_versions
        $table = new XMLDBTable('ouwiki_versions');
        $field = new XMLDBField('deletedat');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'changeprevsize');
        /// Launch add field deletedat (provided field does not already exist)
        if (!field_exists($table, $field)) {
            $result = $result && add_field($table, $field);
        }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:67,代码来源:upgrade.php

示例12: xmldb_block_curr_admin_upgrade


//.........这里部分代码省略.........
        $table->addFieldInfo('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('fieldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('data', XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table crlm_field_data
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        /// Adding indexes to table crlm_field_data
        $table->addIndexInfo('context_idx', XMLDB_INDEX_NOTUNIQUE, array('contextid'));
        /// Launch create table for crlm_field_data
        $result = $result && create_table($table);
    }
    //if ($result && $oldversion < 2010040501) {
    //    require_once($CFG->dirroot . '/blocks/curr_admin/lib.php');
    //    $result = $result && create_views(); // create with default prefix
    //    $result = $result && create_views(''); // create with no prefix
    //}
    if ($result && $oldversion < 2010040501) {
        $table = new XMLDBTable('crlm_field_map');
        /// Adding fields to table crlm_field_data
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('context', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('type', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('elis_field', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('data_field', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table crlm_field_data
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        /// Launch create table for crlm_field_data
        $result = $result && create_table($table);
    }
    if ($result && $oldversion < 2010040501) {
        require_once "{$CFG->dirroot}/curriculum/lib/customfield.class.php";
        // make sure all ELIS users have a context
        update_capabilities('block/curr_admin');
        $ctxlvl = context_level_base::get_custom_context_level('user', 'block_curr_admin');
        $rs = get_recordset('crlm_user');
        while ($rec = rs_fetch_next_record($rs)) {
            get_context_instance($ctxlvl, $rec->id);
        }
        // sync profile fields
        $fields = field::get_for_context_level($ctxlvl);
        $fields = $fields ? $fields : array();
        require_once $CFG->dirroot . '/curriculum/plugins/moodle_profile/custom_fields.php';
        foreach ($fields as $field) {
            $fieldobj = new field($field);
            $sync_profile_field_with_moodle();
        }
    }
    if ($result && $oldversion < 2010040501) {
        require_once $CFG->dirroot . '/curriculum/lib/notifications.php';
        if (!empty($CFG->coursemanager)) {
            $context_course = CONTEXT_COURSE;
            $sql = "SELECT role_assignments.* FROM {$CFG->prefix}role_assignments role_assignments\n                    JOIN {$CFG->prefix}context context\n                    ON role_assignments.contextid = context.id\n                    WHERE role_assignments.roleid IN ({$CFG->coursemanager})\n                    AND context.contextlevel = {$context_course}";
            if ($records = get_records_sql($sql)) {
                foreach ($records as $record) {
                    cm_assign_instructor_from_mdl($record);
                }
            }
        }
    }
    if ($result && $oldversion < 2010063001) {
        $table = new XMLDBTable('crlm_curriculum_assignment');
        $field = new XMLDBField('user_idnumber');
        $result = $result && drop_field($table, $field);
        $table = new XMLDBTable('crlm_class_enrolment');
        $field = new XMLDBField('user_idnumber');
        $result = $result && drop_field($table, $field);
        $table = new XMLDBTable('crlm_class_instructor');
开发者ID:remotelearner,项目名称:elis.cm,代码行数:67,代码来源:upgrade.php

示例13: rebuild_users

 public static function rebuild_users()
 {
     log_debug('Starting rebuild_users()');
     self::delete_bytype('user');
     $users = get_recordset('usr', 'deleted', '0');
     safe_require('artefact', 'internal');
     $publicfields = array_keys(ArtefactTypeProfile::get_public_fields());
     while ($user = $users->FetchRow()) {
         if ($user['id'] == 0) {
             continue;
         }
         self::index_user($user);
     }
     $users->close();
     log_debug('Completed rebuild_users()');
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:16,代码来源:lib.php

示例14: allow_assign

                allow_assign($fromroleid, $targetroleid);
            }
        }
    }
    /// Updated allowassigns sitewide, so force a premissions refresh, and redirect.
    mark_context_dirty($systemcontext->path);
    add_to_log(SITEID, 'role', 'edit allow assign', 'admin/roles/allowassign.php', '', '', $USER->id);
    redirect($CFG->wwwroot . '/' . $CFG->admin . '/roles/allowassign.php');
}
/// Load the current settings
$allowed = array();
foreach ($roles as $role) {
    // Make an array $role->id => false. This is probalby too clever for its own good.1
    $allowed[$role->id] = array_combine(array_keys($roles), array_fill(0, count($roles), false));
}
$raas = get_recordset('role_allow_assign');
foreach ($raas as $raa) {
    $raa = (object) $raa;
    $allowed[$raa->roleid][$raa->allowassign] = true;
}
/// Display the editing form.
admin_externalpage_setup('defineroles', '', array(), $CFG->wwwroot . '/' . $CFG->admin . '/roles/allowassign.php');
admin_externalpage_print_header();
$currenttab = 'allowassign';
require_once 'managetabs.php';
$table->tablealign = 'center';
$table->cellpadding = 5;
$table->cellspacing = 0;
$table->width = '90%';
$table->align[] = 'left';
$table->rotateheaders = true;
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:allowassign.php

示例15: action_default

 function action_default()
 {
     global $CFG, $CURMAN;
     require_once $CFG->dirroot . '/curriculum/form/configform.class.php';
     $configform = new cmconfigform('index.php', $this);
     $configform->set_data($CURMAN->config);
     if ($configdata = $configform->get_data()) {
         $old_cluster_groups = $CURMAN->config->cluster_groups;
         $old_site_course_cluster_groups = $CURMAN->config->site_course_cluster_groups;
         $old_cluster_groupings = $CURMAN->config->cluster_groupings;
         // Track settings
         self::config_set_value($configdata, 'userdefinedtrack', 0);
         // Course catalog / Learning plan settings
         self::config_set_value($configdata, 'disablecoursecatalog', 0);
         self::config_set_value($configdata, 'catalog_collapse_count');
         // Curriculum expiration settings (ELIS-1172)
         $curassupdate = false;
         // We need to check for an required update before setting the variable as the API call requires the
         // variable to be set before the changes can take place.
         if (isset($configdata->curriculum_expiration_start) && $configdata->curriculum_expiration_start != $CURMAN->config->curriculum_expiration_start) {
             $curassupdate = true;
         }
         self::config_set_value($configdata, 'enable_curriculum_expiration', 0);
         self::config_set_value($configdata, 'curriculum_expiration_start', '');
         // If this setting is changed, we need to update the existing curriclum expiration values
         if ($curassupdate) {
             if ($rs = get_recordset(CURASSTABLE, '', '', '', 'id, userid, curriculumid')) {
                 $timenow = time();
                 while ($curass = rs_fetch_next_record($rs)) {
                     $update = new stdClass();
                     $update->id = $curass->id;
                     $update->timeexpired = calculate_curriculum_expiry(false, $curass->curriculumid, $curass->userid);
                     $update->timemodified = $timenow;
                     update_record(CURASSTABLE, $update);
                 }
                 rs_close($rs);
             }
         }
         // Certificate settings
         self::config_set_value($configdata, 'disablecertificates', 0);
         self::config_set_value($configdata, 'certificate_border_image', 'Fancy1-blue.jpg');
         self::config_set_value($configdata, 'certificate_seal_image', 'none');
         self::config_set_value($configdata, 'certificate_template_file', 'default.php');
         // Interface settings
         self::config_set_value($configdata, 'time_format_12h', 0);
         self::config_set_value($configdata, 'mymoodle_redirect', 0);
         // User settings
         self::config_set_value($configdata, 'auto_assign_user_idnumber', 0);
         $old_cfg = $CURMAN->config->auto_assign_user_idnumber;
         // if this setting is changed to true, synchronize the users
         if (isset($configdata->auto_assign_user_idnumber) && $configdata->auto_assign_user_idnumber != 0 && $old_cfg == 0) {
             cm_migrate_moodle_users(true, 0);
         }
         self::config_set_value($configdata, 'default_instructor_role', 0);
         self::config_set_value($configdata, 'restrict_to_elis_enrolment_plugin', 0);
         // Cluster settings
         self::config_set_value($configdata, 'cluster_groups', 0);
         self::config_set_value($configdata, 'site_course_cluster_groups', 0);
         self::config_set_value($configdata, 'cluster_groupings', 0);
         //settings specifically for the curriculum administration block
         self::config_set_value($configdata, 'num_block_icons', 5);
         self::config_set_value($configdata, 'display_clusters_at_top_level', 1);
         self::config_set_value($configdata, 'display_curricula_at_top_level', 0);
         //default role assignments on cm entities
         self::config_set_value($configdata, 'default_cluster_role_id', 0);
         self::config_set_value($configdata, 'default_curriculum_role_id', 0);
         self::config_set_value($configdata, 'default_course_role_id', 0);
         self::config_set_value($configdata, 'default_class_role_id', 0);
         self::config_set_value($configdata, 'default_track_role_id', 0);
         //enrolment synchronization roles
         $old_role_sync = $CURMAN->config->enrolment_role_sync_student_role;
         self::config_set_value($configdata, 'enrolment_role_sync_student_role', 0);
         if (isset($configdata->enrolment_role_sync_student_role) && $configdata->enrolment_role_sync_student_role != 0 && $configdata->enrolment_role_sync_student_role != $old_role_sync) {
             require_once CURMAN_DIRLOCATION . '/plugins/enrolment_role_sync/lib.php';
             enrolment_role_sync::student_sync_role_set();
         }
         $old_role_sync = $CURMAN->config->enrolment_role_sync_instructor_role;
         self::config_set_value($configdata, 'enrolment_role_sync_instructor_role', 0);
         if (isset($configdata->enrolment_role_sync_instructor_role) && $configdata->enrolment_role_sync_instructor_role != 0 && $configdata->enrolment_role_sync_instructor_role != $old_role_sync) {
             require_once CURMAN_DIRLOCATION . '/plugins/enrolment_role_sync/lib.php';
             enrolment_role_sync::instructor_sync_role_set();
         }
         // autocreate settings
         self::config_set_value($configdata, 'autocreated_unknown_is_yes', 0);
         // legacy settings
         self::config_set_value($configdata, 'legacy_show_inactive_users', 0);
         //trigger events
         if (!empty($configdata->cluster_groups) && empty($old_cluster_groups)) {
             events_trigger('crlm_cluster_groups_enabled', 0);
         }
         if (!empty($configdata->site_course_cluster_groups) && empty($old_site_course_cluster_groups)) {
             events_trigger('crlm_site_course_cluster_groups_enabled', 0);
         }
         if (!empty($configdata->cluster_groupings) && empty($old_cluster_groupings)) {
             events_trigger('crlm_cluster_groupings_enabled', 0);
         }
     }
     $configform->display();
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:99,代码来源:configpage.class.php


注:本文中的get_recordset函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。