本文整理汇总了PHP中field::make_from_moodle_field方法的典型用法代码示例。如果您正苦于以下问题:PHP field::make_from_moodle_field方法的具体用法?PHP field::make_from_moodle_field怎么用?PHP field::make_from_moodle_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类field
的用法示例。
在下文中一共展示了field::make_from_moodle_field方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_make_from_moodle_field
/**
* Test make_from_moodle_field function.
*
* @dataProvider dataprovider_make_from_moodle_field
* @param object $mfielddata Data to create the initial moodle profile with.
* @param array $expectedfielddata Expected data created for the field.
* @param array $expectedmanualownerdata Expected field_owner data created.
*/
public function test_make_from_moodle_field($mfielddata, $expectedfielddata, $expectedmanualownerdata)
{
require_once elis::file('eliscore/lib/data/customfield.class.php');
require_once elis::file('eliscore/fields/moodleprofile/custom_fields.php');
global $DB;
$mfieldid = $DB->insert_record('user_info_field', $mfielddata);
$fieldcat = new field_category();
$fieldcat->name = 'Moodle Fields';
$fieldcat->save();
$efield = field::make_from_moodle_field($mfieldid, $fieldcat, pm_moodle_profile::sync_from_moodle);
$efieldrec = $DB->get_record(field::TABLE, array('shortname' => $efield->shortname));
unset($efieldrec->id);
unset($efieldrec->sortorder);
$expectedfielddata['categoryid'] = (string) $fieldcat->id;
$this->assertEquals($expectedfielddata, (array) $efieldrec);
$manualowner = $DB->get_record(field_owner::TABLE, array('fieldid' => $efield->id, 'plugin' => 'manual'));
ksort($expectedmanualownerdata);
$actualparams = unserialize($manualowner->params);
ksort($actualparams);
$this->assertEquals($expectedmanualownerdata, $actualparams);
$this->assertTrue(moodle_profile_can_sync($efield->shortname));
if ($mfielddata['defaultdata'] != '') {
switch ($efield->datatype) {
case 'bool':
$fielddatatype = 'int';
break;
case 'datetime':
$fielddatatype = 'int';
break;
case 'char':
$fielddatatype = 'char';
break;
default:
$fielddatatype = 'text';
}
$fielddataclass = 'field_data_' . $fielddatatype;
$defaultdata = $DB->get_record($fielddataclass::TABLE, array('fieldid' => $efield->id));
$this->assertNotEmpty($defaultdata);
$this->assertEquals($mfielddata['defaultdata'], $defaultdata->data);
}
}
示例2: local_elisprogram_upgrade_old_tables
//.........这里部分代码省略.........
}
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;
}