本文整理汇总了PHP中field::find方法的典型用法代码示例。如果您正苦于以下问题:PHP field::find方法的具体用法?PHP field::find怎么用?PHP field::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类field
的用法示例。
在下文中一共展示了field::find方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elisprogram_archive_pre26upgradesteps
/**
* Run all upgrade steps from before elis 2.6.
*
* @param int $oldversion The currently installed version of the old component.
* @return bool Success/Failure.
*/
function elisprogram_archive_pre26upgradesteps($oldversion)
{
$result = true;
if ($result && $oldversion < 2011100700) {
// rename field
$field = field::find(new field_filter('shortname', '_elis_curriculum_archive'));
if ($field->valid()) {
$field = $field->current();
$field->shortname = ARCHIVE_FIELD;
$field->name = get_string('archive_field_name', 'elisprogram_archive');
$field->save();
}
upgrade_plugin_savepoint($result, 2011100700, 'pmplugins', 'archive');
}
if ($result && $oldversion < 2011101200) {
$field = field::find(new field_filter('shortname', ARCHIVE_FIELD));
if ($field->valid()) {
$field = $field->current();
if ($owner = new field_owner(!isset($field->owners) || !isset($field->owners['manual']) ? false : $field->owners['manual'])) {
$owner->fieldid = $field->id;
$owner->plugin = 'manual';
//$owner->exclude = 0; // TBD
$owner->param_help_file = 'elisprogram_archive/archive_program';
$owner->save();
}
}
upgrade_plugin_savepoint($result, 2011101200, 'pmplugins', 'archive');
}
return $result;
}
示例2: elisprogram_usetclassify_pre26upgradesteps
/**
* Run all upgrade steps from before elis 2.6.
*
* @param int $oldversion The currently installed version of the old component.
* @return bool Success/Failure.
*/
function elisprogram_usetclassify_pre26upgradesteps($oldversion)
{
global $CFG, $THEME, $DB;
$dbman = $DB->get_manager();
$result = true;
if ($oldversion < 2011071400) {
// Rename field.
$field = field::find(new field_filter('shortname', '_elis_cluster_classification'));
if ($field->valid()) {
$field = $field->current();
$field->shortname = USERSET_CLASSIFICATION_FIELD;
if ($field->name == 'Cluster classification') {
// Rhe field name hasn't been changed from the old default.
$field->name = get_string('classification_field_name', 'elisprogram_usetclassify');
}
$field->save();
$category = $field->category;
if ($category->name == 'Cluster classification') {
// The field name hasn't been changed from the old default.
$category->name = get_string('classification_category_name', 'elisprogram_usetclassify');
$category->save();
}
}
upgrade_plugin_savepoint($result, 2011071400, 'pmplugins', 'userset_classification');
}
if ($result && $oldversion < 2011101200) {
$field = field::find(new field_filter('shortname', USERSET_CLASSIFICATION_FIELD));
if ($field->valid()) {
$field = $field->current();
if ($owner = new field_owner(!isset($field->owners) || !isset($field->owners['manual']) ? false : $field->owners['manual'])) {
$owner->fieldid = $field->id;
$owner->plugin = 'manual';
//$owner->exclude = 0; // TBD
$owner->param_help_file = 'elisprogram_usetclassify/cluster_classification';
$owner->save();
}
}
upgrade_plugin_savepoint($result, 2011101200, 'pmplugins', 'userset_classification');
}
if ($result && $oldversion < 2011101800) {
// Userset -> 'User Set'.
$field = field::find(new field_filter('shortname', USERSET_CLASSIFICATION_FIELD));
if ($field->valid()) {
$field = $field->current();
if (stripos($field->name, 'Userset') !== false) {
$field->name = str_ireplace('Userset', 'User Set', $field->name);
$field->save();
}
$category = $field->category;
if (stripos($category->name, 'Userset') !== false) {
$category->name = str_ireplace('Userset', 'User Set', $category->name);
$category->save();
}
}
upgrade_plugin_savepoint($result, 2011101800, 'pmplugins', 'userset_classification');
}
if ($result && $oldversion < 2011110300) {
// Make sure to rename the default classification name from "Cluster" to "User set".
require_once elispm::file('plugins/usetclassify/usersetclassification.class.php');
// Make sure there are no custom fields with invalid categories.
pm_fix_orphaned_fields();
$field = field::find(new field_filter('shortname', USERSET_CLASSIFICATION_FIELD));
if ($field->valid()) {
$field = $field->current();
$category = $field->category;
$default = usersetclassification::find(new field_filter('shortname', 'regular'));
if ($default->valid()) {
$default = $default->current();
$default->name = get_string('cluster', 'local_elisprogram');
$default->save();
}
// Upgrade field owner data for the default User Set field.
$field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_USERSET, $category);
$owners = field_owner::find(new field_filter('fieldid', $field->id));
if ($owners->valid()) {
foreach ($owners as $owner) {
if ($owner->plugin == 'cluster_classification') {
$owner->plugin = 'userset_classification';
$owner->save();
} else {
if ($owner->plugin == 'manual') {
$owner->param_options_source = 'userset_classifications';
$owner->param_help_file = 'elisprogram_usetclassify/cluster_classification';
$owner->save();
}
}
}
}
upgrade_plugin_savepoint($result, 2011110300, 'pmplugins', 'userset_classification');
}
}
return $result;
}
示例3: elisprogram_usetthemes_pre26upgradesteps
/**
* Run all upgrade steps from before elis 2.6.
*
* @param int $oldversion The currently installed version of the old component.
* @return bool Success/Failure.
*/
function elisprogram_usetthemes_pre26upgradesteps($oldversion)
{
global $CFG, $THEME, $DB;
$dbman = $DB->get_manager();
$result = true;
if ($oldversion < 2011071300) {
// Rename fields.
$fieldnames = array('theme', 'themepriority');
foreach ($fieldnames as $fieldname) {
$field = field::find(new field_filter('shortname', 'cluster_' . $fieldname));
if ($field->valid()) {
$field = $field->current();
$field->shortname = '_elis_userset_' . $fieldname;
$field->save();
}
}
upgrade_plugin_savepoint($result, 2011071300, 'pmplugins', 'userset_themes');
}
if ($result && $oldversion < 2011101800) {
// Userset -> 'User Set'.
$fieldnames = array('theme', 'themepriority');
foreach ($fieldnames as $fieldname) {
$fname = '_elis_userset_' . $fieldname;
$field = field::find(new field_filter('shortname', $fname));
if ($field->valid()) {
$field = $field->current();
// Add help file.
if ($owner = new field_owner(!isset($field->owners) || !isset($field->owners['manual']) ? false : $field->owners['manual'])) {
$owner->fieldid = $field->id;
$owner->plugin = 'manual';
//$owner->exclude = 0; // TBD
$owner->param_help_file = "elisprogram_usetthemes/{$fname}";
$owner->save();
}
$category = $field->category;
if (stripos($category->name, 'Userset') !== false) {
$category->name = str_ireplace('Userset', 'User Set', $category->name);
$category->save();
}
}
}
upgrade_plugin_savepoint($result, 2011101800, 'pmplugins', 'userset_themes');
}
if ($oldversion < 2013020400) {
// Rename field if it is still 'Cluster Theme'.
$field = field::find(new field_filter('shortname', '_elis_userset_theme'));
if ($field->valid()) {
$field = $field->current();
$category = $field->category;
if ($category->name == 'Cluster Theme') {
// The field name hasn't been changed from the old default.
$category->name = get_string('userset_theme_category', 'elisprogram_usetthemes');
$category->save();
}
}
upgrade_plugin_savepoint($result, 2013020400, 'pmplugins', 'userset_themes');
}
return $result;
}
示例4: elisprogram_usetgroups_pre26upgradesteps
/**
* Run all upgrade steps from before elis 2.6.
*
* @param int $oldversion The currently installed version of the old component.
* @return bool Success/Failure.
*/
function elisprogram_usetgroups_pre26upgradesteps($oldversion)
{
global $CFG, $THEME, $DB;
$dbman = $DB->get_manager();
$result = true;
if ($oldversion < 2011072600) {
// Rename fields.
$fieldnames = array('group', 'groupings');
foreach ($fieldnames as $fieldname) {
$field = field::find(new field_filter('shortname', 'cluster_' . $fieldname));
if ($field->valid()) {
$field = $field->current();
$field->shortname = 'userset_' . $fieldname;
$field->save();
}
}
upgrade_plugin_savepoint($result, 2011072600, 'pmplugins', 'userset_groups');
}
if ($result && $oldversion < 2011101300) {
// Rename field help.
$fieldmap = array('userset_group' => 'elisprogram_usetgroups/userset_group', 'userset_groupings' => 'elisprogram_usetgroups/autoenrol_groupings');
foreach ($fieldmap as $key => $val) {
$field = field::find(new field_filter('shortname', $key));
if ($field->valid()) {
$field = $field->current();
if ($owner = new field_owner(!isset($field->owners) || !isset($field->owners['manual']) ? false : $field->owners['manual'])) {
$owner->fieldid = $field->id;
$owner->plugin = 'manual';
//$owner->exclude = 0; // TBD
$owner->params = serialize(array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'checkbox', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => $val));
$owner->save();
}
}
}
upgrade_plugin_savepoint($result, 2011101300, 'pmplugins', 'userset_groups');
}
return $result;
}
示例5: get_for_context_and_field
/**
* Gets the custom field data for a specified context and field. If a
* field value is not set, the default value will be given.
*
* @param object $context the context to get the field data from
* @param mixed $field the field shortname, or a field object
* @param boolean $include_default whether to include the default value in
* the result set (only applies if no actual data exists)
*/
public static function get_for_context_and_field($context, $field, $include_default = true)
{
if (is_string($field)) {
$find = field::find(array(new field_filter('shortname', $field), new join_filter('id', field_contextlevel::TABLE, 'fieldid', new field_filter('contextlevel', $context->contextlevel))));
foreach ($find as $rec) {
$field = $rec;
}
if (is_string($field)) {
// no field found
return null;
}
}
$fielddatatype = "field_data_{$field->data_type()}";
if ($context) {
$filter = array();
$filter[] = new field_filter('contextid', $context->id);
$filter[] = new field_filter('fieldid', $field->id);
$count = $fielddatatype::count($filter);
if ($count) {
return $fielddatatype::find($filter);
}
}
//no "actual" data found
if ($include_default) {
//return the default value
return $fielddatatype::find(array(new field_filter('contextid', null), new field_filter('fieldid', $field->id)));
} else {
//return an empty recordset
return $fielddatatype::find(new select_filter('0 = 1'));
}
}
示例6: elisprogram_usetdisppriority_pre26upgradesteps
/**
* Run all upgrade steps from before elis 2.6.
*
* @param int $oldversion The currently installed version of the old component.
* @return bool Success/Failure.
*/
function elisprogram_usetdisppriority_pre26upgradesteps($oldversion)
{
global $CFG, $THEME, $DB;
$dbman = $DB->get_manager();
$result = true;
if ($oldversion < 2011071200) {
// Rename field.
$field = field::find(new field_filter('shortname', '_elis_cluster_display_priority'));
if ($field->valid()) {
$field = $field->current();
$field->shortname = USERSET_DISPLAY_PRIORITY_FIELD;
$field->save();
$category = $field->category;
if ($category->name == 'Cluster Display Settings') {
// The field name hasn't been changed from the old default.
$category->name = get_string('display_settings_category_name', 'elisprogram_usetdisppriority');
$category->save();
}
}
upgrade_plugin_savepoint($result, 2011071200, 'pmplugins', 'userset_display_priority');
}
if ($result && $oldversion < 2011101200) {
$field = field::find(new field_filter('shortname', USERSET_DISPLAY_PRIORITY_FIELD));
if ($field->valid()) {
$field = $field->current();
if ($owner = new field_owner(!isset($field->owners) || !isset($field->owners['manual']) ? false : $field->owners['manual'])) {
$owner->fieldid = $field->id;
$owner->plugin = 'manual';
//$owner->exclude = 0; // TBD
$owner->param_help_file = 'elisprogram_usetdisppriority/display_priority';
$owner->save();
}
}
upgrade_plugin_savepoint($result, 2011101200, 'pmplugins', 'userset_display_priority');
}
if ($result && $oldversion < 2011101800) {
// Userset -> 'User Set'.
$field = field::find(new field_filter('shortname', USERSET_DISPLAY_PRIORITY_FIELD));
if ($field->valid()) {
$field = $field->current();
$category = $field->category;
if (stripos($category->name, 'Userset') !== false) {
$category->name = str_ireplace('Userset', 'User Set', $category->name);
$category->save();
}
}
upgrade_plugin_savepoint($result, 2011101800, 'pmplugins', 'userset_display_priority');
}
return $result;
}
示例7: elisprogram_preposttest_pre26upgradesteps
/**
* Run all upgrade steps from before elis 2.6.
*
* @param int $oldversion The currently installed version of the old component.
* @return bool Success/Failure.
*/
function elisprogram_preposttest_pre26upgradesteps($oldversion)
{
$result = true;
if ($result && $oldversion < 2011101200) {
$field = field::find(new field_filter('shortname', PRE_TEST_FIELD));
if ($field->valid()) {
$field = $field->current();
if ($owner = new field_owner(!isset($field->owners) || !isset($field->owners['manual']) ? false : $field->owners['manual'])) {
$owner->fieldid = $field->id;
$owner->plugin = 'manual';
//$owner->exclude = 0; // TBD
$owner->param_help_file = 'elisprogram_preposttest/pre_test';
$owner->save();
}
}
$field = field::find(new field_filter('shortname', POST_TEST_FIELD));
if ($field->valid()) {
$field = $field->current();
if ($owner = new field_owner(!isset($field->owners) || !isset($field->owners['manual']) ? false : $field->owners['manual'])) {
$owner->fieldid = $field->id;
$owner->plugin = 'manual';
//$owner->exclude = 0; // TBD
$owner->param_help_file = 'elisprogram_preposttest/post_test';
$owner->save();
}
}
upgrade_plugin_savepoint($result, 2011101200, 'pmplugins', 'pre_post_test');
}
return $result;
}