• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP filter_set_local_state函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: process_active

    public function process_active($data) {

        $data = (object)$data;

        if (!filter_is_enabled($data->filter)) { // Not installed or not enabled, nothing to do
            return;
        }
        filter_set_local_state($data->filter, $this->task->get_contextid(), $data->active);
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:9,代码来源:restore_stepslib.php


示例2: process_active

 public function process_active($data)
 {
     $data = (object) $data;
     if (strpos($data->filter, 'filter/') === 0) {
         $data->filter = substr($data->filter, 7);
     } else {
         if (strpos($data->filter, '/') !== false) {
             // Unsupported old filter.
             return;
         }
     }
     if (!filter_is_enabled($data->filter)) {
         // Not installed or not enabled, nothing to do
         return;
     }
     filter_set_local_state($data->filter, $this->task->get_contextid(), $data->active);
 }
开发者ID:Jinelle,项目名称:moodle,代码行数:17,代码来源:restore_stepslib.php


示例3: redirect

    $settingsform = new $formname($CFG->wwwroot . '/filter/manage.php', $forfilter, $context);
    if ($settingsform->is_cancelled()) {
        redirect($baseurl);
    } else {
        if ($data = $settingsform->get_data()) {
            $settingsform->save_changes($data);
            redirect($baseurl);
        }
    }
}
/// Process any form submission.
if ($forfilter == '' && optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
    foreach ($availablefilters as $filter => $filterinfo) {
        $newstate = optional_param(str_replace('/', '_', $filter), false, PARAM_INT);
        if ($newstate !== false && $newstate != $filterinfo->localstate) {
            filter_set_local_state($filter, $context->id, $newstate);
        }
    }
    redirect($CFG->wwwroot . '/filter/manage.php?contextid=' . $context->id, get_string('changessaved'), 1);
}
/// Work out an appropriate page title.
if ($forfilter) {
    $a = new stdClass();
    $a->filter = filter_get_name($forfilter);
    $a->context = $contextname;
    $title = get_string('filtersettingsforin', 'filters', $a);
} else {
    $title = get_string('filtersettingsin', 'filters', $contextname);
}
$straction = get_string('filters', 'admin');
// Used by tabs.php
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:manage.php


示例4: test_filter_delete_all_for_context

 public function test_filter_delete_all_for_context()
 {
     // Setup fixture.
     filter_set_global_state('filter/name', TEXTFILTER_ON);
     filter_set_local_state('filter/name', 123, TEXTFILTER_OFF);
     filter_set_local_config('filter/name', 123, 'settingname', 'A value');
     filter_set_local_config('filter/other', 123, 'settingname', 'Other value');
     filter_set_local_config('filter/other', 122, 'settingname', 'Other value');
     // Exercise SUT.
     filter_delete_all_for_context(123);
     // Validate.
     $this->assertEqual(1, $this->testdb->count_records('filter_active'));
     $this->assertTrue($this->testdb->record_exists('filter_active', array('contextid' => $this->syscontext->id)));
     $this->assertEqual(1, $this->testdb->count_records('filter_config'));
     $this->assertTrue($this->testdb->record_exists('filter_config', array('filter' => 'filter/other')));
 }
开发者ID:rolandovanegas,项目名称:moodle,代码行数:16,代码来源:testfilterconfig.php


示例5: populate_test_database

function populate_test_database($syscontext, $numcategories, $numcourses, $nummodules, $numoverrides, $numconfigs)
{
    global $DB, $OUTPUT;
    set_time_limit(600);
    $syscontext->id = $DB->insert_record('context', $syscontext);
    // Category contexts.
    $categoryparents = array($syscontext);
    $categories = array();
    for ($i = 0; $i < $numcategories; $i++) {
        $context = insert_context(CONTEXT_COURSECAT, $i, $categoryparents[array_rand($categoryparents)]);
        $categoryparents[] = $context;
        $categories[$context->id] = $context;
    }
    echo $OUTPUT->notification('Created ' . $numcategories . ' course category contexts.', 'notifysuccess');
    flush();
    // Course contexts.
    $courses = array();
    for ($i = 0; $i < $numcourses; $i++) {
        $context = insert_context(CONTEXT_COURSE, $i, $categories[array_rand($categories)]);
        $courses[$context->id] = $context;
    }
    echo $OUTPUT->notification('Created ' . $numcourses . ' course contexts.', 'notifysuccess');
    flush();
    // Activities contexts.
    $mods = array();
    $prog = new progress_bar('modbar', 500, true);
    $transaction = $DB->start_delegated_transaction();
    for ($i = 0; $i < $nummodules; $i++) {
        $context = insert_context(CONTEXT_MODULE, $i, $courses[array_rand($courses)]);
        $mods[$context->id] = $context;
        if ($i % 50) {
            $prog->update($i, $nummodules, '');
        }
    }
    $transaction->allow_commit();
    echo $OUTPUT->notification('Created ' . $nummodules . ' module contexts.', 'notifysuccess');
    flush();
    $contexts = $categories + $courses + $mods;
    // Global settings.
    $installedfilters = filter_get_all_installed();
    $counts = array(TEXTFILTER_DISABLED => 0, TEXTFILTER_OFF => 0, TEXTFILTER_ON => 0);
    foreach ($installedfilters as $filter => $notused) {
        $state = array_rand($counts);
        filter_set_global_state($filter, $state);
        $counts[$state]++;
    }
    echo $OUTPUT->notification('Set global setting: ' . $counts[TEXTFILTER_DISABLED] . ' disabled, ' . $counts[TEXTFILTER_OFF] . ' off and ' . $counts[TEXTFILTER_ON] . ' on.', 'notifysuccess');
    flush();
    // Local overrides.
    $localstates = array(TEXTFILTER_OFF => 0, TEXTFILTER_ON => 0);
    $prog = new progress_bar('locbar', 500, true);
    $transaction = $DB->start_delegated_transaction();
    for ($i = 0; $i < $numoverrides; $i++) {
        filter_set_local_state(array_rand($installedfilters), array_rand($contexts), array_rand($localstates));
        if ($i % 50) {
            $prog->update($i, $numoverrides, '');
        }
    }
    $transaction->allow_commit();
    echo $OUTPUT->notification('Set ' . $numoverrides . ' local overrides.', 'notifysuccess');
    flush();
    // Local config.
    $variablenames = array('frog' => 0, 'toad' => 0, 'elver' => 0, 'eft' => 0, 'tadpole' => 0);
    $prog = new progress_bar('confbar', 500, true);
    $transaction = $DB->start_delegated_transaction();
    for ($i = 0; $i < $numconfigs; $i++) {
        filter_set_local_config(array_rand($installedfilters), array_rand($contexts), array_rand($variablenames), random_string(rand(20, 40)));
        if ($i % 50) {
            $prog->update($i, $numconfigs, '');
        }
    }
    $transaction->allow_commit();
    echo $OUTPUT->notification('Set ' . $numconfigs . ' local configs.', 'notifysuccess');
    flush();
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:75,代码来源:filtersettingsperformancetester.php


示例6: restore_write_local_filter_settings

/**
 * Write any per-context filter settings from the backup XML to the DB.
 * @param object $restore the restore we are part of.
 * @param object $data sata loaded from the XML.
 * @param object $newmodcontext the restored context object.
 */
function restore_write_local_filter_settings($restore, $data, $newcontext)
{
    if (filter_context_may_have_filter_settings($newcontext)) {
        return;
    }
    $installedfilters = filter_get_all_installed();
    if (!isset($data->filteractives)) {
        $data->filteractives = array();
    }
    foreach ($data->filteractives as $filter => $state) {
        if (isset($installedfilters[$filter])) {
            filter_set_local_state($filter, $newcontext->id, $state);
        }
    }
    if (!isset($data->filterconfigs)) {
        $data->filterconfigs = array();
    }
    foreach ($data->filterconfigs as $fc) {
        if (isset($installedfilters[$fc->filter])) {
            filter_set_local_config($fc->filter, $newcontext->id, $fc->name, $fc->value);
        }
    }
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:29,代码来源:restorelib.php


示例7: taskchain_navigation_accesscontrol_form


//.........这里部分代码省略.........
                    case 'completiondate':
                        update_course_module_completion('course_modules', $cm->id, $setting, $completiondate, $updated, $skipped, $completion_updated);
                        break;
                    case 'completionview':
                        if (array_key_exists($cm->modname, $completionfields[$setting]->mods)) {
                            update_course_module_completion('course_modules', $cm->id, $setting, $completionview, $updated, $skipped, $completion_updated);
                        }
                        break;
                    case 'completiongrade':
                        if (array_key_exists($cm->modname, $completionfields[$setting]->mods)) {
                            // course_modules.completiongradeitemnumber
                            // see "set_moduleinfo_defaults()" in "course/modlib.php"
                            // null=disabled, 0=enabled (i.e. require grade)
                            $completiongradeitemnumber = $completiongrade ? 0 : null;
                            update_course_module_completion('course_modules', $cm->id, 'completiongradeitemnumber', $completiongradeitemnumber, $updated, $skipped, $completion_updated);
                        }
                        break;
                    case 'competencyrule':
                        $data = (object) array('coursemodule' => $cm->id, 'competencies' => array(), 'competency_rule' => $competencyrule);
                        // see "admin/tool/lp/lib.php"
                        $data = tool_lp_coursemodule_edit_post_actions($data, $course);
                        $updated = true;
                        break;
                    default:
                        if (array_key_exists($setting, $completionfields)) {
                            $field = $completionfields[$setting];
                            if (array_key_exists($cm->modname, $field->mods)) {
                                update_course_module_completion($cm->modname, $cm->instance, $setting, ${$setting}, $updated, $skipped, $completion_updated);
                            }
                        } else {
                            if (substr($setting, 0, 6) == 'filter') {
                                $filter = substr($setting, 6);
                                if (in_array(${$setting}, array(TEXTFILTER_ON, TEXTFILTER_OFF, TEXTFILTER_INHERIT))) {
                                    filter_set_local_state($filter, $modulecontext->id, ${$setting});
                                    $reset_filter_caches = true;
                                    $updated = true;
                                } else {
                                    $skipped = true;
                                }
                            } else {
                                // unexpected setting - shouldn't happen !!
                                echo 'Unknown setting, ' . $setting . ', not processed' . html_writer::empty_tag('br');
                            }
                        }
                }
                // end switch
            }
            // end foreach $selected_settings
            if ($completion_updated) {
                $completion = $completiontracking;
                // if automatic completion (=2) is requested,
                // check that some completion conditions are set
                if ($completion == 2) {
                    $completion = 0;
                    $table = 'course_modules';
                    $params = array('id' => $cm->id);
                    $names = array('completionview' => 0, 'completionexpected' => 0, 'completiongradeitemnumber' => null);
                    foreach ($names as $name => $disabled) {
                        $value = $DB->get_field($table, $name, $params);
                        if (isset($value)) {
                            $value = intval($value);
                        }
                        if ($value !== $disabled) {
                            $completion = $completiontracking;
                        }
                    }
开发者ID:gbateson,项目名称:moodle-block_taskchain_navigation,代码行数:67,代码来源:accesscontrol.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP filter_sql函数代码示例发布时间:2022-05-15
下一篇:
PHP filter_set_local_config函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap