本文整理汇总了PHP中block_base::instance_config_save方法的典型用法代码示例。如果您正苦于以下问题:PHP block_base::instance_config_save方法的具体用法?PHP block_base::instance_config_save怎么用?PHP block_base::instance_config_save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block_base
的用法示例。
在下文中一共展示了block_base::instance_config_save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function instance_config_save($data)
{
if (empty($data->quizid)) {
$data->quizid = $this->get_owning_quiz();
}
parent::instance_config_save($data);
}
示例2:
function instance_config_save($data, $nolongerused = false)
{
if (empty($data->quizid)) {
$data->quizid = $this->get_owning_quiz();
}
parent::instance_config_save($data);
}
示例3: instance_config_save
public function instance_config_save($data)
{
if (get_config('simplehtml', 'Allow_HTML') == '1') {
$data->text = strip_tags($data->text);
}
// And now forward to the default implementation defined in the parent class
return parent::instance_config_save($data);
}
示例4: array
/**
* Serialize and store config data
*/
function instance_config_save($data, $nolongerused = false)
{
global $DB;
$config = clone $data;
// Move embedded files into a proper filearea and adjust HTML links to match
$config->text = file_save_draft_area_files($data->text['itemid'], $this->context->id, 'block_html', 'content', 0, array('subdirs' => true), $data->text['text']);
$config->format = $data->text['format'];
parent::instance_config_save($config, $nolongerused);
}
示例5:
function instance_config_save($data)
{
$savedata = null;
if (isset($data->general['moduleUrl'])) {
$savedata->moduleUrl = $data->general['moduleUrl'];
}
$savedata->configuration = $data->configuration;
$savedata->preferences = $data->preferences;
return parent::instance_config_save($savedata);
}
示例6: stdClass
/**
* @desc Saves the form data from configuration into the wwassignment_bridge table.
*/
function instance_config_save($data)
{
$webworkcourse = $data->webwork_link_id;
$moodlecourse = $data->courseid;
$wwassignmentbridge = new stdClass();
$wwassignmentbridge->course = $moodlecourse;
$wwassignmentbridge->webwork_course = $webworkcourse;
//has this mapping been defined
$record = get_record('wwassignment_bridge', 'course', $moodlecourse);
if (!$record) {
//new one
insert_record('wwassignment_bridge', $wwassignmentbridge);
} else {
//update
$wwassignmentbridge->id = $record->id;
update_record('wwassignment_bridge', $wwassignmentbridge);
}
return parent::instance_config_save($data);
}
示例7: instance_config_save
public function instance_config_save($data)
{
global $DB, $USER;
$alerts = $DB->get_records('block_itutor_profiler_alerts', array('course_id' => $data->courseid));
foreach ($alerts as $alert) {
$s = 'isalerting' . $alert->id;
//alert has been unticked
if (!isset($data->{$s})) {
//remove alert from database
$DB->delete_records('block_itutor_profiler_alerts', array('id' => $alert->id));
}
unset($data->{$s});
}
//If new alert create => add it to the DB
if ($data->alerttype != 0) {
$record = new stdClass();
$record->course_id = $data->courseid;
$record->alert_date = $data->alertdate;
$record->alert_type = $data->alerttype;
$record->alert_data = $data->alertdata;
$record->alert_message = $data->alertmessage;
if (isset($data->sendtostaff)) {
$record->alert_sendto = $USER->id;
} else {
$record->alert_sendto = null;
}
$DB->insert_record('block_itutor_profiler_alerts', $record, false);
//false, no return, no bulk
}
unset($data->courseid);
unset($data->alertdate);
unset($data->alerttype);
unset($data->alertdata);
unset($data->alertmessage);
unset($data->sendtostaff);
//Call normal save functionality
return parent::instance_config_save($data);
}
示例8: foreach
/**
* Override the instance_config_save method
*/
function instance_config_save($data, $nolongerused = false)
{
parent::instance_config_save($data, $nolongerused);
global $DB, $COURSE;
foreach ($data as $name => $value) {
$rec = $DB->get_record('block_timetracker_config', array('courseid' => $COURSE->id, 'name' => $name));
$conf = new stdClass();
$conf->name = $name;
$conf->value = $value;
$conf->courseid = $COURSE->id;
if ($rec) {
$conf->id = $rec->id;
$DB->update_record('block_timetracker_config', $conf);
} else {
$DB->insert_record('block_timetracker_config', $conf);
}
}
}
示例9: instance_config_save
/**
* Used to save the form config data
* @param stdclass $data
* @param bool $nolongerused
*/
public function instance_config_save($data, $nolongerused = false)
{
global $DB;
if (empty($data->activitygradeitemid)) {
// Figure out info about parent module.
$info = $this->get_owning_activity();
$data->activitygradeitemid = $info->id;
if ($info->id < 1) {
// No activity was selected.
$info->itemmodule = '';
$info->iteminstance = '';
} else {
$data->activityparent = $info->itemmodule;
$data->activityparentid = $info->iteminstance;
}
} else {
// Lookup info about the parent module (we have the id from mdl_grade_items.
$info = $DB->get_record('grade_items', array('id' => $data->activitygradeitemid));
$data->activityparent = $info->itemmodule;
$data->activityparentid = $info->iteminstance;
}
parent::instance_config_save($data);
}
示例10:
function instance_config_save($data, $nolongerused = false)
{
parent::instance_config_save($data);
}
示例11:
function instance_config_save($data, $notused = false)
{
global $USER;
// check if curent user forcing a filelocationadminoverride can really do it
// in case it seems to be forced, set it to empty anyway.
if (!has_capability('block/dashboard:systempathaccess', context_system::instance())) {
$data->filepathadminoverride = '';
}
// retrieve sql params directly from POST
$data->sqlparams = @$_POST['sqlparams'];
// print_object($data);
return parent::instance_config_save($data, $notused);
}
示例12: array
function instance_config_save($data, $nolongerused = false)
{
//append stuff to data - this is BAD
//chapters
$chapters = array();
$lastIndex = 0;
$total = 0;
if ($data->chapEnable == 0) {
$data->subChapEnable = 0;
}
$chapterNames = optional_param_array('chapterNames', array(), PARAM_RAW_TRIMMED);
$childrenElementsNo = optional_param_array('chapterChildElementsNumber', array(), PARAM_INT);
$chapterCounts = optional_param_array('chapterCounts', array(), PARAM_INT);
$childElementTypes = optional_param_array('childElementTypes', array(), PARAM_ALPHANUMEXT);
$childElementCounts = optional_param_array('childElementCounts', array(), PARAM_INT);
$childElementNames = optional_param_array('childElementNames', array(), PARAM_RAW_TRIMMED);
if ($this->page->course->id != SITEID) {
//save chapters
foreach ($chapterNames as $k => $name) {
$chapter = array();
$chapter['name'] = $name;
$chapter['childElements'] = array();
for ($i = $lastIndex; $i < $lastIndex + $childrenElementsNo[$k]; $i++) {
$child = array();
if ($data->chapEnable == 0) {
//only one subchapter
$child['type'] = "subchapter";
$child['count'] = count($this->get_sections());
$child['name'] = get_string("subchapter", "block_course_menu") . " 1-1";
} elseif ($data->subChapEnable == 0) {
$child['type'] = "subchapter";
$xx = $k + 1;
$child['name'] = get_string("subchapter", "block_course_menu") . " {$xx}-1";
$child['count'] = $chapterCounts[$k];
} else {
$child['type'] = $childElementTypes[$i];
if ($child['type'] == "subchapter") {
$child['count'] = $childElementCounts[$i];
$total += $child['count'];
$child['name'] = $childElementNames[$i];
}
}
$chapter['childElements'][] = $child;
}
$lastIndex = $i;
$chapters[] = $chapter;
}
} else {
$data->chapEnable = 0;
$data->subChapEnable = 0;
$data->subChaptersCount = 1;
$data->chapters = array();
$chapter = array();
$chapter['name'] = get_string("chapter", "{$this->blockname}") . " 1";
$child = array();
$child['type'] = "subchapter";
$child['name'] = get_string("subchapter", "{$this->blockname}") . " 1";
$child['count'] = 0;
$chapter['childElements'] = array($child);
$chapters[] = $chapter;
}
$data->chapters = $chapters;
// elements
$data->elements = array();
$ids = optional_param_array('ids', array(), PARAM_RAW_TRIMMED);
$urls = optional_param_array('urls', array(), PARAM_RAW_TRIMMED);
$icons = optional_param_array('icons', array(), PARAM_RAW_TRIMMED);
$canHides = optional_param_array('canHides', array(), PARAM_INT);
$visibles = optional_param_array('visibles', array(), PARAM_INT);
foreach ($ids as $k => $id) {
if (empty($id)) {
continue;
}
if (strpos($id, 'link') !== false) {
$index = str_replace('link', '', $id);
$name = optional_param('cm_link_name' . $index, '', PARAM_RAW_TRIMMED);
if (!$name) {
$name = get_string('link', 'block_course_menu');
}
} else {
$name = $this->get_name($id);
}
$data->elements[] = $this->create_element($id, $name, $urls[$k], $icons[$k], $canHides[$k], $visibles[$k]);
}
//links
$linkCounter = optional_param_array('linkCounter', array(), PARAM_INT);
$data->links = array();
foreach ($linkCounter as $k => $notimportant) {
$url = optional_param('cm_link_url' . $k, '', PARAM_RAW_TRIMMED);
// if (empty($url)) { //no empty urls
// continue;
// }
$link = array();
$link['name'] = optional_param('cm_link_name' . $k, '', PARAM_RAW_TRIMMED);
$link['target'] = optional_param('cm_link_target' . $k, '', PARAM_RAW_TRIMMED);
$link['icon'] = optional_param('cm_link_icon' . $k, '', PARAM_RAW_TRIMMED);
// url
$link['url'] = $url;
if (!preg_match('/http(s)?:\\/\\//i', $link['url'])) {
$link['url'] = 'http://' . $link['url'];
//.........这里部分代码省略.........
示例13: stdClass
/**
* Serialize and store config data
*/
function instance_config_save($data, $nolongerused = false)
{
global $USER, $COURSE;
$config = new stdClass();
foreach ($data as $fieldname => $fieldvalue) {
if (is_array($fieldvalue)) {
$config->{$fieldname} = array();
} else {
$config->{$fieldname} = $fieldvalue;
}
}
$fileoptions = array('subdirs' => false, 'maxfiles' => 1, 'maxbytes' => $COURSE->maxbytes, 'accepted_types' => 'web_image', 'return_types' => FILE_INTERNAL);
$saved = 0;
for ($i = 0; $i < $data->slides; $i++) {
$usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
$draftfiles = $fs->get_area_files($usercontext->id, 'user', 'draft', $data->imageslide[$i], 'id');
if (count($draftfiles) > 1 || isset($data->title[$i]) && !empty($data->title[$i]) || isset($data->caption[$i]) && !empty($data->caption[$i]) || isset($data->link[$i]) && !empty($data->link[$i])) {
$config->enabled[$saved] = 0;
if (isset($data->enabled[$i]) && !empty($data->enabled[$i])) {
$config->enabled[$saved] = $data->enabled[$i];
if ($data->firstslide >= $saved) {
$config->firstslide = $saved;
}
}
if (isset($data->imageslide[$i]) && !empty($data->imageslide[$i])) {
$config->imageslide[$saved] = $data->imageslide[$i];
file_save_draft_area_files($config->imageslide[$saved], $this->context->id, 'block_slideshow', 'slides', $saved, $fileoptions);
}
$config->imageposition[$saved] = isset($data->imageposition[$i]) && !empty($data->imageposition[$i]) ? $data->imageposition[$i] : '';
$config->title[$saved] = isset($data->title[$i]) && !empty($data->title[$i]) ? $data->title[$i] : '';
$config->caption[$saved] = isset($data->caption[$i]) && !empty($data->caption[$i]) ? $data->caption[$i] : '';
$config->captionposition[$saved] = isset($data->captionposition[$i]) && !empty($data->captionposition[$i]) ? $data->captionposition[$i] : '';
$config->link[$saved] = isset($data->link[$i]) && !empty($data->link[$i]) ? $data->link[$i] : '';
$saved++;
}
}
for ($i = $saved; $i < $data->slides; $i++) {
file_save_draft_area_files($data->imageslide[$i], $this->context->id, 'block_slideshow', 'slides', $i, $fileoptions);
}
$config->slides = $saved;
parent::instance_config_save($config, $nolongerused);
}
示例14: switch
/**
* the method overrides the standard instance_config_save()
* it tries to apply selected settings to similar blocks
* in other courses in which this user can edit blocks
*
* @param object $data contains the new config form data
* @param boolean $pinned (optional, default=false)
* @return xxx
*/
function instance_config_save($data, $pinned = false)
{
global $COURSE, $DB, $USER;
// do nothing if user hit the "cancel" button
if (optional_param('cancel', 0, PARAM_INT)) {
return true;
}
$name = 'showactivitygrades';
$types = $name . 'types';
switch (true) {
case empty($data->{$name}):
$data->{$name} = array();
break;
case $data->{$name} == 'all':
$data->{$name} = array('all');
break;
case $data->{$name} == 'specific':
if (empty($data->{$types})) {
$data->{$name} = array();
} else {
$data->{$name} = $data->{$types};
}
break;
default:
$data->{$name} = array();
}
if (isset($data->{$types})) {
unset($data->{$types});
}
$js = '';
if (empty($data->showactivitygrades)) {
$data->showactivitygrades = '';
} else {
$data->showactivitygrades = implode(',', $data->showactivitygrades);
$js .= "<script type=\"text/javascript\">\n";
$js .= "//<![CDATA[\n";
$js .= "var src = location.href.replace(new RegExp('^(.*?)/course/view.php.*\$'), '\$1');\n";
$js .= "src += '/mod/taskchain/courselinks.js.php?id=';\n";
$js .= "src += location.href.replace(new RegExp('^.*?id=([0-9]+).*\$'), '\$1');\n";
$js .= "src += '&rnd='+Math.ceil(10000*Math.random());\n";
$js .= "src += '&showgrades=1';\n";
$js .= "src += '&showaverages={$data->showaverages}';\n";
$js .= "src += '&displayasblock=1';\n";
$js .= "src += '&mods={$data->showactivitygrades}';\n";
$js .= "document.writeln('<scr'+'ipt type=\"text/javascr'+'ipt\" src=\"'+src+'\"></scr'+'ipt>');\n";
$js .= "//]]>\n";
$js .= "</script>\n";
}
$modinfo = get_fast_modinfo($COURSE, $USER->id);
$section = $this->get_section_info($modinfo, 0);
$search = '/<script[^>]+>.*?<\\/script>[\\n\\r]*/s';
$summary = preg_replace($search, '', $section->summary);
$summary .= $js;
if ($summary != $section->summary) {
$DB->set_field('course_sections', 'summary', $summary, array('id' => $section->id));
rebuild_course_cache($COURSE->id, true);
}
if ($data->singlesection) {
if (function_exists('course_get_format')) {
// Moodle >= 2.3
$update = false;
if ($options = course_get_format($COURSE)->get_format_options()) {
if (empty($options['coursedisplay'])) {
$update = true;
$options['coursedisplay'] = 1;
// COURSE_DISPLAY_MULTIPAGE;
}
if (empty($options['hiddensections'])) {
$update = true;
$options['hiddensections'] = 1;
// completely invisible
}
}
if ($update) {
course_get_format($COURSE)->update_course_format_options($options);
}
}
}
// expand "select_sectiontextlength", if required
if (isset($data->select_sectiontextlength)) {
$configs = array('name', 'head', 'tail');
$langs = get_string_manager()->get_list_of_translations();
$langs = array_keys($langs);
array_unshift($langs, '');
foreach ($langs as $lang) {
$lang = substr($lang, 0, 2);
foreach ($configs as $config) {
$selectname = 'select_' . $config . 'length' . $lang;
$data->{$selectname} = $data->select_sectiontextlength;
}
}
//.........这里部分代码省略.........
示例15: localLibRafl
function instance_config_save($data, $pinned = false, $updaterafl = true)
{
global $CFG;
// if in rafl mode then attempt to update the rafl tables
if ($CFG->raflmodeenabled && $updaterafl) {
$course = get_record('course', 'id', $this->instance->pageid);
if ($course->learning_path_mode == LEARNING_PATH_MODE_RAFL) {
// look up raflitem id
if ($pageitem = get_record('format_page_items', 'blockinstance', $this->instance->id)) {
require_once $CFG->dirroot . '/mod/rafl/locallib.php';
$rafl = new localLibRafl();
$rafl->update_share_item($course->id, $pageitem->rafl_item, $data->text);
} else {
error_log('no matching rafl item could be found');
}
}
}
// And now forward to the default implementation defined in the parent class
return parent::instance_config_save($data);
}