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


PHP field::update方法代码示例

本文整理汇总了PHP中field::update方法的典型用法代码示例。如果您正苦于以下问题:PHP field::update方法的具体用法?PHP field::update怎么用?PHP field::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在field的用法示例。


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

示例1: xmldb_crlm_cluster_groups_upgrade

/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    elis
 * @subpackage curriculummanagement
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
function xmldb_crlm_cluster_groups_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2010080602) {
        require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php';
        $field = new field(field::get_for_context_level_with_name('cluster', 'cluster_group'));
        if (isset($field->owners['manual'])) {
            $owner = new field_owner($field->owners['manual']);
            $owner->param_help_file = 'crlm_cluster_groups/cluster_groups';
            $owner->update();
        }
    }
    if ($result && $oldversion < 2010080603) {
        //retrieve the cluster context
        $context = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
        //get the cluster classification category
        $category = new field_category();
        $category->name = get_string('cluster_group_category', 'crlm_cluster_groups');
        $field = new field();
        $field->shortname = 'cluster_groupings';
        $field->name = get_string('autoenrol_groupings', 'crlm_cluster_classification');
        $field->datatype = 'bool';
        $field = field::ensure_field_exists_for_context_level($field, $context, $category);
        $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'checkbox', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'crlm_cluster_groups/cluster_groupings');
        field_owner::ensure_field_owner_exists($field, 'manual', $owner_options);
    }
    if ($result && $oldversion < 2010080604) {
        if ($field = new field(field::get_for_context_level_with_name('cluster', 'cluster_site_course_group'))) {
            $field->shortname = 'cluster_groupings';
            $field->update();
        }
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:61,代码来源:upgrade.php

示例2: customfieldpage

 function action_editfield()
 {
     global $CURMAN;
     $level = $this->required_param('level', PARAM_ACTION);
     $ctxlvl = context_level_base::get_custom_context_level($level, 'block_curr_admin');
     if (!$ctxlvl) {
         print_error('invalid_context_level', 'block_curr_admin');
     }
     $id = $this->optional_param('id', NULL, PARAM_INT);
     require_once CURMAN_DIRLOCATION . '/form/customfieldform.class.php';
     $tmppage = new customfieldpage(array('level' => $level, 'action' => 'editfield'), $this);
     $form = new customfieldform($tmppage->get_moodle_url(), $this);
     if ($form->is_cancelled()) {
         $tmppage = new customfieldpage(array('level' => $level));
         redirect($tmppage->get_url(), get_string('edit_cancelled', 'block_curr_admin'));
     } else {
         if ($data = $form->get_data()) {
             $field = new field($data);
             if ($id) {
                 $field->id = $id;
                 $field->update();
             } else {
                 $field->add();
                 // assume each field only belongs to one context level (for now)
                 $fieldcontext = new field_contextlevel();
                 $fieldcontext->fieldid = $field->id;
                 $fieldcontext->contextlevel = $ctxlvl;
                 $fieldcontext->add();
             }
             //don't use !empty here because we might be storing a 0 or similar value
             if ($data->defaultdata != '') {
                 // save the default value
                 $defaultdata = $data->defaultdata;
                 if ($field->multivalued) {
                     // parse as a CSV string
                     // until we can use str_getcsv from PHP 5.3...
                     $temp = fopen("php://memory", "rw");
                     fwrite($temp, $defaultdata);
                     rewind($temp);
                     $defaultdata = fgetcsv($temp);
                     fclose($temp);
                 }
                 field_data::set_for_context_and_field(NULL, $field, $defaultdata);
             } else {
                 if ($field->multivalued) {
                     field_data::set_for_context_and_field(NULL, $field, array());
                 } else {
                     field_data::set_for_context_and_field(NULL, $field, NULL);
                 }
             }
             $plugins = get_list_of_plugins('curriculum/plugins');
             foreach ($plugins as $plugin) {
                 if (is_readable(CURMAN_DIRLOCATION . '/plugins/' . $plugin . '/custom_fields.php')) {
                     include_once CURMAN_DIRLOCATION . '/plugins/' . $plugin . '/custom_fields.php';
                     if (function_exists("{$plugin}_field_save_form_data")) {
                         call_user_func("{$plugin}_field_save_form_data", $form, $field, $data);
                     }
                 }
             }
             $tmppage = new customfieldpage(array('level' => $level));
             redirect($tmppage->get_url(), get_string('field_saved', 'block_curr_admin', $field));
         } else {
             if (!empty($id)) {
                 if ($this->optional_param('from', NULL, PARAM_CLEAN) == 'moodle' && $level == 'user') {
                     $moodlefield = $CURMAN->db->get_record('user_info_field', 'id', $id);
                     if (!$moodlefield) {
                         print_error('invalidfieldid', 'block_curr_admin');
                     }
                     unset($moodlefield->id);
                     $data_array = (array) $moodlefield;
                     $data_array['datatype'] = 'text';
                     $data_array['manual_field_control'] = $moodlefield->datatype;
                     switch ($moodlefield->datatype) {
                         case field::checkbox:
                             $data_array['datatype'] = 'bool';
                             break;
                         case field::menu:
                             $data_array['datatype'] = 'char';
                             $data_array['manual_field_options'] = $moodlefield->param1;
                             break;
                         case field::textarea:
                             $data_array['manual_field_columns'] = $moodlefield->param1;
                             $data_array['manual_field_rows'] = $moodlefield->param2;
                             break;
                         case field::text:
                             if ($moodlefield->param3) {
                                 $data_array['manual_field_control'] = 'password';
                             }
                             $data_array['manual_field_columns'] = $moodlefield->param1;
                             $data_array['manual_field_maxlength'] = $moodlefield->param2;
                             break;
                     }
                 } else {
                     $data = new field($id);
                     $data_array = $data->to_array();
                     $defaultdata = field_data::get_for_context_and_field(NULL, $data);
                     if (!empty($defaultdata)) {
                         if ($data->multivalued) {
                             $values = array();
                             // extract the data
//.........这里部分代码省略.........
开发者ID:remotelearner,项目名称:elis.cm,代码行数:101,代码来源:customfieldpage.class.php


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