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


PHP add_to_config_log函数代码示例

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


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

示例1: filter_set_global_state

/**
 * Set the global activated state for a text filter.
 *
 * @param string $filtername The filter name, for example 'tex'.
 * @param int $state One of the values TEXTFILTER_ON, TEXTFILTER_OFF or TEXTFILTER_DISABLED.
 * @param int $move -1 means up, 0 means the same, 1 means down
 */
function filter_set_global_state($filtername, $state, $move = 0)
{
    global $DB;
    // Check requested state is valid.
    if (!in_array($state, array(TEXTFILTER_ON, TEXTFILTER_OFF, TEXTFILTER_DISABLED))) {
        throw new coding_exception("Illegal option '{$state}' passed to filter_set_global_state. " . "Must be one of TEXTFILTER_ON, TEXTFILTER_OFF or TEXTFILTER_DISABLED.");
    }
    if ($move > 0) {
        $move = 1;
    } else {
        if ($move < 0) {
            $move = -1;
        }
    }
    if (strpos($filtername, 'filter/') === 0) {
        //debugging("Old filtername '$filtername' parameter used in filter_set_global_state()", DEBUG_DEVELOPER);
        $filtername = substr($filtername, 7);
    } else {
        if (strpos($filtername, '/') !== false) {
            throw new coding_exception("Invalid filter name '{$filtername}' used in filter_set_global_state()");
        }
    }
    $transaction = $DB->start_delegated_transaction();
    $syscontext = context_system::instance();
    $filters = $DB->get_records('filter_active', array('contextid' => $syscontext->id), 'sortorder ASC');
    $on = array();
    $off = array();
    foreach ($filters as $f) {
        if ($f->active == TEXTFILTER_DISABLED) {
            $off[$f->filter] = $f;
        } else {
            $on[$f->filter] = $f;
        }
    }
    // Update the state or add new record.
    if (isset($on[$filtername])) {
        $filter = $on[$filtername];
        if ($filter->active != $state) {
            add_to_config_log('filter_active', $filter->active, $state, $filtername);
            $filter->active = $state;
            $DB->update_record('filter_active', $filter);
            if ($filter->active == TEXTFILTER_DISABLED) {
                unset($on[$filtername]);
                $off = array($filter->filter => $filter) + $off;
            }
        }
    } else {
        if (isset($off[$filtername])) {
            $filter = $off[$filtername];
            if ($filter->active != $state) {
                add_to_config_log('filter_active', $filter->active, $state, $filtername);
                $filter->active = $state;
                $DB->update_record('filter_active', $filter);
                if ($filter->active != TEXTFILTER_DISABLED) {
                    unset($off[$filtername]);
                    $on[$filter->filter] = $filter;
                }
            }
        } else {
            add_to_config_log('filter_active', '', $state, $filtername);
            $filter = new stdClass();
            $filter->filter = $filtername;
            $filter->contextid = $syscontext->id;
            $filter->active = $state;
            $filter->sortorder = 99999;
            $filter->id = $DB->insert_record('filter_active', $filter);
            $filters[$filter->id] = $filter;
            if ($state == TEXTFILTER_DISABLED) {
                $off[$filter->filter] = $filter;
            } else {
                $on[$filter->filter] = $filter;
            }
        }
    }
    // Move only active.
    if ($move != 0 and isset($on[$filter->filter])) {
        $i = 1;
        foreach ($on as $f) {
            $f->newsortorder = $i;
            $i++;
        }
        $filter->newsortorder = $filter->newsortorder + $move;
        foreach ($on as $f) {
            if ($f->id == $filter->id) {
                continue;
            }
            if ($f->newsortorder == $filter->newsortorder) {
                if ($move == 1) {
                    $f->newsortorder = $f->newsortorder - 1;
                } else {
                    $f->newsortorder = $f->newsortorder + 1;
                }
            }
//.........这里部分代码省略.........
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:101,代码来源:filterlib.php

示例2: add_to_config_log

 /**
  * Log config changes if necessary.
  * @param string $name
  * @param string $oldvalue
  * @param string $value
  */
 protected function add_to_config_log($name, $oldvalue, $value)
 {
     add_to_config_log($name, $oldvalue, $value, $this->plugin);
 }
开发者ID:Alexbado,项目名称:moodle2,代码行数:10,代码来源:adminlib.php

示例3: unprotect_block

 /**
  * Make this block type deletable and addable.
  *
  * @param mixed $blockidorname string or int
  */
 public static function unprotect_block($blockidorname)
 {
     global $DB;
     $syscontext = context_system::instance();
     require_capability('moodle/site:config', $syscontext);
     $block = false;
     if (is_int($blockidorname)) {
         $block = $DB->get_record('block', array('id' => $blockidorname), 'id, name', MUST_EXIST);
     } else {
         $block = $DB->get_record('block', array('name' => $blockidorname), 'id, name', MUST_EXIST);
     }
     $undeletableblocktypes = self::get_undeletable_block_types();
     if (in_array($block->name, $undeletableblocktypes)) {
         $undeletableblocktypes = array_diff($undeletableblocktypes, array($block->name));
         set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
         add_to_config_log('block_protect', "1", "0", $block->name);
     }
 }
开发者ID:stronk7,项目名称:moodle,代码行数:23,代码来源:blocklib.php

示例4: config_write

 /**
  * Used to set a config pair and log change
  *
  * @param string $name
  * @param mixed $value Gets converted to string if not null
  * @return bool Write setting to config table
  */
 public function config_write($name, $value)
 {
     global $DB, $USER, $CFG;
     if ($this->nosave) {
         return true;
     }
     // make sure it is a real change
     $oldvalue = get_config($this->plugin, $name);
     $oldvalue = $oldvalue === false ? null : $oldvalue;
     // normalise
     $value = is_null($value) ? null : (string) $value;
     if ($oldvalue === $value) {
         return true;
     }
     // store change
     set_config($name, $value, $this->plugin);
     // Some admin settings affect course modinfo
     if ($this->affectsmodinfo) {
         // Clear course cache for all courses
         rebuild_course_cache(0, true);
     }
     add_to_config_log($name, $oldvalue, $value, $this->plugin);
     return true;
     // BC only
 }
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:32,代码来源:adminlib.php

示例5: print_error

        print_error('blockdoesnotexist', 'error');
    }
    $DB->set_field('block', 'visible', '0', array('id' => $block->id));
    // Hide block
    add_to_config_log('block_visibility', $block->visible, '0', $block->name);
    core_plugin_manager::reset_caches();
    admin_get_root(true, false);
    // settings not required - only pages
}
if (!empty($show) && confirm_sesskey()) {
    if (!($block = $DB->get_record('block', array('id' => $show)))) {
        print_error('blockdoesnotexist', 'error');
    }
    $DB->set_field('block', 'visible', '1', array('id' => $block->id));
    // Show block
    add_to_config_log('block_visibility', $block->visible, '1', $block->name);
    core_plugin_manager::reset_caches();
    admin_get_root(true, false);
    // settings not required - only pages
}
if (!empty($protect) && confirm_sesskey()) {
    block_manager::protect_block((int) $protect);
    admin_get_root(true, false);
    // settings not required - only pages
}
if (!empty($unprotect) && confirm_sesskey()) {
    block_manager::unprotect_block((int) $unprotect);
    admin_get_root(true, false);
    // settings not required - only pages
}
$undeletableblocktypes = block_manager::get_undeletable_block_types();
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:31,代码来源:blocks.php


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