public function write_setting($data) { // your custom validation logic here if ($data == '') { $data = random_string(60); } return parent::write_setting($data); }
/** * @param string $name * @param string $visiblename * @param string $description * @param mixed $defaultsetting string or array * @param mixed $paramtype */ public function __construct($name, $visiblename, $description, $defaultsetting, $paramtype = PARAM_RAW, $cols = '60', $rows = '8', $filearea = 'bcumarketingimages') { $this->rows = $rows; $this->cols = $cols; $this->filearea = $filearea; parent::__construct($name, $visiblename, $description, $defaultsetting, $paramtype); editors_head_setup(); }
public function config_write($name, $value) { if ($value === '') { // We do not want empty values in config table, // delete it instead. $value = null; } return parent::config_write($name, $value); }
public function validate($data) { global $PAGE; // Don't force the plugin to be fully set up when installing. if ($PAGE->pagelayout === 'maintenance' && strlen($data) === 0) { return true; } return parent::validate($data); }
/** * Config text constructor * * @param string $name unique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting' * for ones in config_plugins. * @param string $visiblename localised * @param string $description long localised info * @param string $defaultsetting * @param mixed $paramtype int means PARAM_XXX type, string is a allowed format in regex * @param int $size default field size */ public function __construct($name, $visiblename, $description, $defaultsetting, $paramtype = PARAM_RAW_TRIMMED, $size = null) { $this->paramtype = $paramtype; if (!is_null($size)) { $this->size = $size; } else { $this->size = $paramtype === PARAM_INT ? 5 : 30; } parent::__construct($name, $visiblename, $description, $defaultsetting); }
/** * Validate data. * * @param string $data * @return mixed True on success, else error message */ public function validate($data) { $result = parent::validate($data); if ($result !== true) { return $result; } if ((int) $data < 1) { return get_string('awaittimeerror', 'realtimequiz'); } return true; }
/** * Validate data. * * This ensures that key ID is specified if URL is provided * * @param string $data * @return mixed True on success, else error message. */ public function validate($data) { $result = parent::validate($data); if ($result !== true) { return $result; } $url = get_config('filter_cloudfront_signurl', 'distributionurl'); if ($url != '' && empty($data)) { return get_string('errornokeyid', 'filter_cloudfront_signurl'); } return true; }
/** * Set the cron field for the gdata block record * to the number of sections set in this setting. * * @return boolean **/ function config_write($name, $value) { global $DB; if (empty($value)) { $cron = 0; } else { $cron = $value * MINSECS; } if ($DB->set_field('block', 'cron', $cron, array('name' => 'gdata'))) { return parent::config_write($name, $value); } return false; }
/** * Validate data before storage * @param string data * @return mixed true if ok string if error found */ public function validate($data) { $validated = parent::validate($data); // Pass parent validation first. if ($validated == true) { $matches = preg_match($this->regex, $data); if ($matches === false) { $validated = 'preg_match() error.'; } else { if ($matches == 0) { $validated = '\'' . $data . '\'' . $this->error; } } } return $validated; }
/** * Validate data before storage * @param string data * @return mixed true if ok string if error found */ public function validate($data) { $validated = parent::validate($data); // Pass parent validation first. if ($validated == true) { if ($data < $this->lower) { $validated = get_string('asconfigintlower', 'theme_essential', array('value' => $data, 'lower' => $this->lower)); } else { if ($data > $this->upper) { $validated = get_string('asconfigintupper', 'theme_essential', array('value' => $data, 'upper' => $this->upper)); } else { $validated = true; } } } return $validated; }
/** * Validate data. * * This ensures that unix socket setting is correct and ClamAV is running. * * @param string $data * @return mixed True on success, else error message. */ public function validate($data) { $result = parent::validate($data); if ($result !== true) { return $result; } $runningmethod = get_config('antivirus_clamav', 'runningmethod'); if ($runningmethod === 'unixsocket') { $socket = stream_socket_client('unix://' . $data, $errno, $errstr, ANTIVIRUS_CLAMAV_SOCKET_TIMEOUT); if (!$socket) { return get_string('errorcantopensocket', 'antivirus_clamav', "{$errstr} ({$errno})"); } else { // Send PING query to ClamAV socket to check its running state. fwrite($socket, "nPING\n"); $response = stream_get_line($socket, 4); fclose($socket); if ($response !== 'PONG') { return get_string('errorclamavnoresponse', 'antivirus_clamav'); } } } return true; }
public function add_text($setting, $default = '') { $text = new admin_setting_configtext($this->name_for($setting), $this->title_for($setting), $this->description_for($setting), $default); $text->set_updatedcallback('theme_reset_all_caches'); $this->settingspage->add($text); }
function admin_setting_special_backupsaveto() { $name = 'backup_sche_destination'; $visiblename = get_string('saveto'); $description = get_string('backupsavetohelp'); parent::admin_setting_configtext($name, $visiblename, $description, ''); }
public function __construct($name, $visiblename, $description, $defaultsetting) { parent::__construct($name, $visiblename, $description, $defaultsetting, PARAM_RAW, 50); }
public function add_texts($setting, $instance, $default = '') { $text = new admin_setting_configtext($this->name_for($setting . $instance), $this->title_for($setting, $instance), $this->description_for($setting), $default); $text->set_updatedcallback('theme_reset_all_caches'); return $text; }
$timezone = 0; } else { if ($timezone > 0) { $timezone = $timezone - 24; } } $options = array(); for ($i = 0; $i <= 23; $i++) { $options[($i - $timezone) % 24] = gmdate('H:i', $i * HOURSECS); } $settings->add(new admin_setting_configmultiselect('hotpot_enablecron', get_string('enablecron', 'mod_hotpot'), get_string('configenablecron', 'mod_hotpot'), array(), $options)); // enable embedding of swf media objects inhotpot quizzes (default=1) $settings->add(new admin_setting_configcheckbox('hotpot_enableswf', get_string('enableswf', 'mod_hotpot'), get_string('configenableswf', 'mod_hotpot'), 1)); // enable obfuscation of javascript in html files (default=1) $settings->add(new admin_setting_configcheckbox('hotpot_enableobfuscate', get_string('enableobfuscate', 'mod_hotpot'), get_string('configenableobfuscate', 'mod_hotpot'), 1)); $options = array(hotpot::BODYSTYLES_BACKGROUND => get_string('bodystylesbackground', 'mod_hotpot'), hotpot::BODYSTYLES_COLOR => get_string('bodystylescolor', 'mod_hotpot'), hotpot::BODYSTYLES_FONT => get_string('bodystylesfont', 'mod_hotpot'), hotpot::BODYSTYLES_MARGIN => get_string('bodystylesmargin', 'mod_hotpot')); $settings->add(new admin_setting_configmultiselect('hotpot_bodystyles', get_string('bodystyles', 'mod_hotpot'), get_string('configbodystyles', 'mod_hotpot'), array(), $options)); // hotpot navigation frame height (default=85) $settings->add(new admin_setting_configtext('hotpot_frameheight', get_string('frameheight', 'mod_hotpot'), get_string('configframeheight', 'mod_hotpot'), 85, PARAM_INT, 4)); // lock hotpot navigation frame so it is not scrollable (default=0) $settings->add(new admin_setting_configcheckbox('hotpot_lockframe', get_string('lockframe', 'mod_hotpot'), get_string('configlockframe', 'mod_hotpot'), 0)); // store raw xml details of HotPot quiz attempts (default=1) $str = get_string('cleardetails', 'mod_hotpot'); $url = new moodle_url('/mod/hotpot/tools/clear_details.php', array('sesskey' => sesskey())); $link = html_writer::link($url, $str, array('class' => 'small', 'style' => 'white-space: nowrap', 'onclick' => "this.target='_blank'")) . "\n"; $settings->add(new admin_setting_configcheckbox('hotpot_storedetails', get_string('storedetails', 'mod_hotpot'), get_string('configstoredetails', 'mod_hotpot') . ' ' . $link, 0)); // maximum duration of a single calendar event (default=5 mins) $setting = new admin_setting_configtext('hotpot_maxeventlength', get_string('maxeventlength', 'mod_hotpot'), get_string('configmaxeventlength', 'mod_hotpot'), 5, PARAM_INT, 4); $setting->set_updatedcallback('hotpot_refresh_events'); $settings->add($setting); unset($i, $link, $options, $setting, $str, $timezone, $datetime, $url);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Defines the form for editing activity results block instances. * * @package block_activity_results * @copyright 2016 Stephen Bourget * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; if ($ADMIN->fulltree) { // Default high scores. $setting = new admin_setting_configtext('block_activity_results/config_showbest', new lang_string('defaulthighestgrades', 'block_activity_results'), new lang_string('defaulthighestgrades_desc', 'block_activity_results'), 3, PARAM_INT); $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); $settings->add($setting); // Default low scores. $setting = new admin_setting_configtext('block_activity_results/config_showworst', new lang_string('defaultlowestgrades', 'block_activity_results'), new lang_string('defaultlowestgrades_desc', 'block_activity_results'), 0, PARAM_INT); $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); $settings->add($setting); // Default group display. $yesno = array(0 => get_string('no'), 1 => get_string('yes')); $setting = new admin_setting_configselect('block_activity_results/config_usegroups', new lang_string('defaultshowgroups', 'block_activity_results'), new lang_string('defaultshowgroups_desc', 'block_activity_results'), 0, $yesno); $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); $settings->add($setting); // Default privacy settings. $nameoptions = array(B_ACTIVITYRESULTS_NAME_FORMAT_FULL => get_string('config_names_full', 'block_activity_results'), B_ACTIVITYRESULTS_NAME_FORMAT_ID => get_string('config_names_id', 'block_activity_results'), B_ACTIVITYRESULTS_NAME_FORMAT_ANON => get_string('config_names_anon', 'block_activity_results')); $setting = new admin_setting_configselect('block_activity_results/config_nameformat', new lang_string('defaultnameoptions', 'block_activity_results'), new lang_string('defaultnameoptions_desc', 'block_activity_results'), B_ACTIVITYRESULTS_NAME_FORMAT_FULL, $nameoptions); $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); $settings->add($setting); // Default grade display settings. $gradeoptions = array(B_ACTIVITYRESULTS_GRADE_FORMAT_PCT => get_string('config_format_percentage', 'block_activity_results'), B_ACTIVITYRESULTS_GRADE_FORMAT_FRA => get_string('config_format_fraction', 'block_activity_results'), B_ACTIVITYRESULTS_GRADE_FORMAT_ABS => get_string('config_format_absolute', 'block_activity_results')); $setting = new admin_setting_configselect('block_activity_results/config_gradeformat', new lang_string('defaultgradedisplay', 'block_activity_results'), new lang_string('defaultgradedisplay_desc', 'block_activity_results'), B_ACTIVITYRESULTS_GRADE_FORMAT_PCT, $gradeoptions);
/** * Save the selected setting * * @param string $data The selected site * @return string empty string or error message */ public function write_setting($data) { if ($data === '') { $data = (int) $this->defaultsetting; } else { $data = $data; } return parent::write_setting($data); }
function write_setting($data) { $return = parent::write_setting($data); get_list_of_languages(true); //refresh the list return $return; }
<?php // This file defines settingpages and externalpages under the "appearance" category $capabilities = array('moodle/my:configsyspages', 'moodle/tag:manage'); if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // speedup for non-admins, add all caps used on this page $ADMIN->add('appearance', new admin_category('themes', new lang_string('themes'))); // "themesettings" settingpage $temp = new admin_settingpage('themesettings', new lang_string('themesettings', 'admin')); $setting = new admin_setting_configtext('themelist', new lang_string('themelist', 'admin'), new lang_string('configthemelist', 'admin'), '', PARAM_NOTAGS); $setting->set_force_ltr(true); $temp->add($setting); $setting = new admin_setting_configcheckbox('themedesignermode', new lang_string('themedesignermode', 'admin'), new lang_string('configthemedesignermode', 'admin'), 0); $setting->set_updatedcallback('theme_reset_all_caches'); $temp->add($setting); $temp->add(new admin_setting_configcheckbox('allowuserthemes', new lang_string('allowuserthemes', 'admin'), new lang_string('configallowuserthemes', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('allowcoursethemes', new lang_string('allowcoursethemes', 'admin'), new lang_string('configallowcoursethemes', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('allowcategorythemes', new lang_string('allowcategorythemes', 'admin'), new lang_string('configallowcategorythemes', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('allowthemechangeonurl', new lang_string('allowthemechangeonurl', 'admin'), new lang_string('configallowthemechangeonurl', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('allowuserblockhiding', new lang_string('allowuserblockhiding', 'admin'), new lang_string('configallowuserblockhiding', 'admin'), 1)); $temp->add(new admin_setting_configcheckbox('allowblockstodock', new lang_string('allowblockstodock', 'admin'), new lang_string('configallowblockstodock', 'admin'), 1)); $temp->add(new admin_setting_configtextarea('custommenuitems', new lang_string('custommenuitems', 'admin'), new lang_string('configcustommenuitems', 'admin'), '', PARAM_RAW, '50', '10')); $temp->add(new admin_setting_configtextarea('customusermenuitems', new lang_string('customusermenuitems', 'admin'), new lang_string('configcustomusermenuitems', 'admin'), 'grades,grades|/grade/report/mygrades.php|grades messages,message|/message/index.php|message preferences,moodle|/user/preferences.php|preferences', PARAM_RAW, '50', '10')); $temp->add(new admin_setting_configcheckbox('enabledevicedetection', new lang_string('enabledevicedetection', 'admin'), new lang_string('configenabledevicedetection', 'admin'), 1)); $temp->add(new admin_setting_devicedetectregex('devicedetectregex', new lang_string('devicedetectregex', 'admin'), new lang_string('devicedetectregex_desc', 'admin'), '')); $ADMIN->add('themes', $temp); $ADMIN->add('themes', new admin_externalpage('themeselector', new lang_string('themeselector', 'admin'), $CFG->wwwroot . '/theme/index.php')); // settings for each theme foreach (core_component::get_plugin_list('theme') as $theme => $themedir) {
require_once dirname(__FILE__) . '/lib.php'; // Start of "scheduling" section $settings->add(new admin_setting_heading('dhexport_version1elis/scheduling', get_string('exportfilesheading', 'dhexport_version1elis'), '')); // Export filename settings $settings->add(new admin_setting_configtext('dhexport_version1elis/export_path', get_string('export_path', 'dhexport_version1elis'), get_string('config_export_path', 'dhexport_version1elis'), '/datahub/dhexport_version1elis')); $settings->add(new admin_setting_configtext('dhexport_version1elis/export_file', get_string('export_file', 'dhexport_version1elis'), get_string('config_export_file', 'dhexport_version1elis'), 'export_version1elis.csv')); // Timestamp export file $settings->add(new admin_setting_configcheckbox('dhexport_version1elis/export_file_timestamp', get_string('export_file_timestamp_label', 'dhexport_version1elis'), get_string('config_export_file_timestamp', 'dhexport_version1elis'), 1)); // Start of "logging" section $settings->add(new admin_setting_heading('dhexport_version1elis/logging', get_string('logging', 'dhexport_version1elis'), '')); // Log file location $settings->add(new admin_setting_configtext('dhexport_version1elis/logfilelocation', get_string('logfilelocation', 'dhexport_version1elis'), get_string('configlogfilelocation', 'dhexport_version1elis'), RLIP_DEFAULT_LOG_PATH)); // Email notification $settings->add(new admin_setting_configtext('dhexport_version1elis/emailnotification', get_string('emailnotification', 'dhexport_version1elis'), get_string('configemailnotification', 'dhexport_version1elis'), '')); /** * Time period settings */ // Header $headerstring = get_string('timeperiodheader', 'dhexport_version1elis'); $settings->add(new admin_setting_heading('dhexport_version1elis_timeperiod', $headerstring, '')); // Checkbox for enabling $displaystring = get_string('nonincremental', 'dhexport_version1elis'); $infostring = get_string('confignonincremental', 'dhexport_version1elis'); $settings->add(new admin_setting_configcheckbox('dhexport_version1elis/nonincremental', $displaystring, $infostring, 0)); // Time delta $displaystring = get_string('incrementaldelta', 'dhexport_version1elis'); $infostring = get_string('configincrementaldelta', 'dhexport_version1elis'); $setting = new admin_setting_configtext('dhexport_version1elis/incrementaldelta', $displaystring, $infostring, '1d'); // Callback to sanitize time delta $setting->set_updatedcallback('rlipexport_version1elis_incrementaldelta_updatedcallback'); $settings->add($setting);
/** * Validate data. * * This ensures that account token is specified if cloud-hosted player is * selected. * * @param string $data * @return mixed True on success, else error message. */ public function validate($data) { $result = parent::validate($data); if ($result !== true) { return $result; } $hostingmethod = get_config('filter_jwplayer', 'hostingmethod'); if ($hostingmethod === 'cloud' && empty($data)) { return get_string('errornoaccounttoken', 'filter_jwplayer'); } return true; }
$title = get_string("activateSlideshow", 'theme_archaius'); $description = get_string('activateSlideshowdesc', 'theme_archaius'); $setting = new admin_setting_configcheckbox($name, $title, $description, 0); $setting->set_updatedcallback('theme_reset_all_caches'); $slideshow_options->add($setting); //Activate pause/play Slideshow $name = "theme_archaius/activatePausePlaySlideshow"; $title = get_string("activatePausePlaySlideshow", 'theme_archaius'); $description = get_string('activatePausePlaySlideshowdesc', 'theme_archaius'); $setting = new admin_setting_configcheckbox($name, $title, $description, 0); $setting->set_updatedcallback('theme_reset_all_caches'); $slideshow_options->add($setting); // Slideshow Timeout $name = 'theme_archaius/slideshowTimeout'; $title = get_string('slideshowTimeout', 'theme_archaius'); $description = get_string('slideshowTimeoutdesc', 'theme_archaius'); $default = 1500; $setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_INT); $setting->set_updatedcallback('theme_reset_all_caches'); $slideshow_options->add($setting); // Slideshow height $name = 'theme_archaius/slideshowheight'; $title = get_string('slideshowheight', 'theme_archaius'); $description = get_string('slideshowheightdesc', 'theme_archaius'); $default = 200; $setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_RAW); $setting->set_updatedcallback('theme_reset_all_caches'); $slideshow_options->add($setting); //Add options to admin tree $ADMIN->add('theme_archaius', $slideshow_options); }
/** * Constructor: uses parent::__construct * * @param string $name unique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting' for ones in config_plugins. * @param string $visiblename localised * @param string $description long localised info * @param string $defaultsetting default value for the setting * @param boolean $lowercase if true, lowercase the value before writing it to the db. * @param boolean $enabled if true, the input field is enabled, otherwise it's disabled. */ public function __construct($name, $visiblename, $description, $defaultsetting, $lowercase = false, $enabled = true) { $this->lowercase = $lowercase; $this->enabled = $enabled; parent::__construct($name, $visiblename, $description, $defaultsetting); }
/** * Constructor * @param string $name unique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting' for ones in config_plugins. * @param string $visiblename localised * @param string $description long localised info * @param array $defaultsetting ('value'=>string, '__construct'=>bool) * @param mixed $paramtype int means PARAM_XXX type, string is a allowed format in regex * @param int $size default field size */ public function __construct($name, $visiblename, $description, $defaultsetting, $paramtype = PARAM_RAW, $size = null) { parent::__construct($name, $visiblename, $description, $defaultsetting['value'], $paramtype, $size); $this->set_advanced_flag_options(admin_setting_flag::ENABLED, !empty($defaultsetting['adv'])); }
function kaltura_admin_setting_configtext($name, $visiblename, $description, $defaultsetting, $mandatory = true, $paramtype = PARAM_RAW, $size = null) { $this->mandatory = $mandatory; parent::admin_setting_configtext($name, $visiblename, $description, $defaultsetting, $paramtype, $size); }
/** * Saves the new settings passed in $data * * @todo Add vartype handling to ensure $data is an array * @param array $data * @return mixed string or Array */ public function write_setting($data) { $error = parent::write_setting($data['value']); if (!$error) { $value = empty($data['adv']) ? 0 : 1; $this->config_write($this->name . '_adv', $value); } return $error; }
$setting->set_updatedcallback('theme_reset_all_caches'); $generalsettings->add($setting); // Caption text. $name = 'theme_essentials/slide' . $i . 'caption'; $title = get_string('slidecaption', 'theme_essential'); $description = get_string('slidecaptiondesc', 'theme_essential'); $default = ''; $setting = new admin_setting_confightmleditor($name, $title, $description, $default); $setting->set_updatedcallback('theme_reset_all_caches'); $generalsettings->add($setting); // URL. $name = 'theme_essentials/slide' . $i . 'url'; $title = get_string('slideurl', 'theme_essential'); $description = get_string('slideurldesc', 'theme_essential'); $default = ''; $setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_URL); $setting->set_updatedcallback('theme_reset_all_caches'); $generalsettings->add($setting); // URL target. $name = 'theme_essentials/slide' . $i . 'target'; $title = get_string('slideurltarget', 'theme_essential'); $description = get_string('slideurltargetdesc', 'theme_essential'); $target1 = get_string('slideurltargetself', 'theme_essential'); $target2 = get_string('slideurltargetnew', 'theme_essential'); $target3 = get_string('slideurltargetparent', 'theme_essential'); $default = '_blank'; $choices = array('_self' => $target1, '_blank' => $target2, '_parent' => $target3); $setting = new admin_setting_configselect($name, $title, $description, $default, $choices); $setting->set_updatedcallback('theme_reset_all_caches'); $generalsettings->add($setting); }
$setting = new admin_setting_configtext($name, $title, $description, '', PARAM_URL); $setting->set_updatedcallback('theme_reset_all_caches'); $temp->add($setting); // This is the descriptor for icon eight $name = 'theme_pioneer/navicon8info'; $heading = get_string('navicon8', 'theme_pioneer'); $information = get_string('navicondesc', 'theme_pioneer'); $setting = new admin_setting_heading($name, $heading, $information); $temp->add($setting); $name = 'theme_pioneer/nav8icon'; $title = get_string('navicon', 'theme_pioneer'); $description = get_string('navicondesc', 'theme_pioneer'); $default = ''; $setting = new admin_setting_configtext($name, $title, $description, $default); $setting->set_updatedcallback('theme_reset_all_caches'); $temp->add($setting); $name = 'theme_pioneer/nav8buttontext'; $title = get_string('naviconbuttontext', 'theme_pioneer'); $description = get_string('naviconbuttontextdesc', 'theme_pioneer'); $default = ''; $setting = new admin_setting_configtext($name, $title, $description, $default); $setting->set_updatedcallback('theme_reset_all_caches'); $temp->add($setting); $name = 'theme_pioneer/nav8buttonurl'; $title = get_string('naviconbuttonurl', 'theme_pioneer'); $description = get_string('naviconbuttonurldesc', 'theme_pioneer'); $default = ''; $setting = new admin_setting_configtext($name, $title, $description, '', PARAM_URL); $setting->set_updatedcallback('theme_reset_all_caches'); $temp->add($setting); $ADMIN->add('theme_pioneer', $temp);
/** * Validate data. * * This ensures that license key is specified for any hosting mode. * * @param string $data * @return mixed True on success, else error message. */ public function validate($data) { $result = parent::validate($data); if ($result !== true) { return $result; } if (empty($data)) { return get_string('errornolicensekey', 'filter_jwplayer'); } return true; }