本文整理汇总了PHP中set_field函数的典型用法代码示例。如果您正苦于以下问题:PHP set_field函数的具体用法?PHP set_field怎么用?PHP set_field使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_field函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_artefact_ilps_upgrade
function xmldb_artefact_ilps_upgrade($oldversion = 0)
{
if ($oldversion < 2012160300) {
set_field('artefact', 'container', 1, 'artefacttype', 'ilp');
}
return true;
}
示例2: display
function display()
{
global $CFG, $PAGE;
require_capability('format/page:managepages', $this->context);
$locks = format_page_lock::get_locks();
$mform = new format_page_lock_form($CFG->wwwroot . '/course/format/page/format.php', format_page_lock::decode($this->page->locks));
if ($mform->is_cancelled()) {
redirect($PAGE->url_build('action', 'manage'));
} else {
if ($data = $mform->get_data()) {
$lockdata = array();
foreach ($locks as $lock) {
$lockdata = array_merge($lockdata, $lock->process_form($data));
}
$lockinfo = array();
$lockinfo['showprereqs'] = $data->showprereqs;
$lockinfo['visible'] = $data->visible;
$lockinfo['locks'] = $lockdata;
if (empty($lockinfo['locks'])) {
$lockinfo = '';
} else {
$lockinfo = format_page_lock::encode($lockinfo);
}
if (!set_field('format_page', 'locks', $lockinfo, 'id', $this->page->id)) {
error('Failed to save lock information');
}
redirect($PAGE->url_build('page', $this->page->id, 'action', 'lock'));
} else {
$PAGE->print_tabs('manage');
$mform->display();
}
}
}
示例3: xmldb_artefact_milestones_upgrade
function xmldb_artefact_milestones_upgrade($oldversion = 0)
{
if ($oldversion < 2010072302) {
set_field('artefact', 'container', 1, 'artefacttype', 'milestone');
}
return true;
}
示例4: xmldb_blocktype_externalvideo_upgrade
function xmldb_blocktype_externalvideo_upgrade($oldversion = 0)
{
if ($oldversion < 2014030500) {
$urlpattern = '#\\b(https?://)prezi\\.com/bin/preziloader\\.swf\\?prezi_id=([a-z0-9]+)\\b#';
$matches = array();
$sql = "SELECT id, configdata FROM {block_instance} WHERE blocktype='externalvideo'";
$records = get_records_sql_array($sql, array());
if ($records) {
foreach ($records as $r) {
$configdata = unserialize($r->configdata);
if (isset($configdata['html'])) {
preg_match($urlpattern, $configdata['html'], $matches);
} else {
if (isset($configdata['videoid'])) {
preg_match($urlpattern, $configdata['videoid'], $matches);
}
}
if (count($matches) >= 3) {
$newurl = $matches[1] . 'prezi.com/embed/' . $matches[2];
$width = !empty($configdata['width']) ? $configdata['width'] : 0;
$height = !empty($configdata['height']) ? $configdata['height'] : 0;
$configdata['html'] = $configdata['videoid'] = PluginBlocktypeExternalvideo::iframe_code($newurl, $width, $height);
set_field('block_instance', 'configdata', serialize($configdata), 'id', $r->id);
}
}
}
ensure_record_exists('iframe_source_icon', (object) array('name' => 'Prezi', 'domain' => 'prezi.com'), (object) array('name' => 'Prezi', 'domain' => 'prezi.com'));
ensure_record_exists('iframe_source', (object) array('prefix' => 'prezi.com/embed/', 'name' => 'Prezi'), (object) array('prefix' => 'prezi.com/embed/', 'name' => 'Prezi'));
update_safe_iframe_regex();
}
return true;
}
示例5: xmldb_artefact_cpds_upgrade
function xmldb_artefact_cpds_upgrade($oldversion = 0)
{
if ($oldversion < 2011051501) {
set_field('artefact', 'container', 1, 'artefacttype', 'cpd');
}
return true;
}
示例6: editurl_submit
function editurl_submit(Pieform $form, $values)
{
global $iframesources, $iframedomains, $SESSION;
if (isset($iframesources[$values['url']])) {
$oldname = $iframesources[$values['url']];
$newname = strip_tags($values['name']);
$iframesources[$values['url']] = $newname;
db_begin();
// Update the icon list if necessary
if (!isset($iframedomains[$newname])) {
insert_record('iframe_source_icon', (object) array('name' => $newname, 'domain' => $values['icon']));
} else {
if ($iframedomains[$newname] != $values['icon']) {
set_field('iframe_source_icon', 'domain', $values['icon'], 'name', $newname);
}
}
set_field('iframe_source', 'name', $newname, 'prefix', $values['url']);
if (!in_array($oldname, $iframesources)) {
delete_records('iframe_source_icon', 'name', $oldname);
}
update_safe_iframe_regex();
db_commit();
$SESSION->add_ok_msg(get_string('itemupdated'));
} else {
$SESSION->add_error_msg(get_string('updatefailed'));
}
redirect('/admin/extensions/iframesites.php');
}
示例7: write_setting
/**
* Save the options to the site course's format field.
*
* Possible values: site and page
*
* @return string
**/
function write_setting($data)
{
if ($data == '1') {
$format = 'page';
} else {
$format = 'site';
}
return set_field('course', 'format', $format, 'id', SITEID) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
}
示例8: save_session_and_responses
function save_session_and_responses(&$question, &$state)
{
$responses = 'dataset' . $state->options->datasetitem . '-' . $state->responses[''];
// Set the legacy answer field
if (!set_field('question_states', 'answer', $responses, 'id', $state->id)) {
return false;
}
return true;
}
示例9: questionnaire_upgrade_2006031700
function questionnaire_upgrade_2006031700()
{
/// Upgrade the questionnaire_response table to use integer timestamps.
table_column('questionnaire_response', 'submitted', 'submitted', 'varchar', '20', '', ' ');
/// This will be heavy on the database....
if (($numrecs = count_records('questionnaire_response')) > 0) {
$recstart = 0;
$recstoget = 100;
while ($recstart < $numrecs) {
if ($records = get_records('questionnaire_response', '', '', '', '*', $recstart, $recstoget)) {
foreach ($records as $record) {
$tstampparts = explode(' ', $record->submitted);
$dateparts = explode('-', $tstampparts[0]);
$timeparts = explode(':', $tstampparts[1]);
$time = mktime($timeparts[0], $timeparts[1], $timeparts[2], $dateparts[1], $dateparts[2], $dateparts[0]);
set_field('questionnaire_response', 'submitted', $time, 'id', $record->id);
if ($record->qtype == 'unlimited') {
$qtype = 0;
} else {
if ($record->type == 'once') {
$qtype = 1;
}
}
set_field('questionnaire_response', 'qtype', $qtype, 'id', $record->id);
}
}
$recstart += $recstoget;
}
}
table_column('questionnaire_response', 'submitted', 'submitted', 'integer', '10');
/// This will be heavy on the database....
if (($numrecs = count_records('questionnaire')) > 0) {
$recstart = 0;
$recstoget = 100;
while ($recstart < $numrecs) {
if ($records = get_records('questionnaire', '', '', '', '*', $recstart, $recstoget)) {
foreach ($records as $record) {
if ($record->qtype == 'unlimited') {
$qtype = 0;
} else {
if ($record->qtype == 'once') {
$qtype = 1;
}
}
set_field('questionnaire', 'qtype', $qtype, 'id', $record->id);
}
}
$recstart += $recstoget;
}
}
/// Modify the qtype field of the 'questionnaire' table to be integer instead of enum.
table_column('questionnaire', 'qtype', 'qtype', 'integer', '10');
/// Add response viewing eligibility.
table_column('questionnaire', '', 'resp_view', 'integer', '2', 'unsigned', '0', 'not null', 'resp_eligible');
return true;
}
示例10: backup_set_config
function backup_set_config($name, $value)
{
if (get_field("backup_config", "name", "name", $name)) {
return set_field("backup_config", "value", addslashes($value), "name", $name);
} else {
$config = new object();
$config->name = $name;
$config->value = addslashes($value);
return insert_record("backup_config", $config);
}
}
示例11: cleanup
/**
* Delete the temporary view
*/
public static function cleanup(PluginImportLeap $importer)
{
if (self::$tempview) {
if (self::$savetempview) {
$title = get_string('entriesimportedfromleapexport', 'artefact.comment');
set_field('view', 'title', $title, 'id', self::$tempview);
} else {
delete_records('view', 'id', self::$tempview);
}
}
}
示例12: config_write
function config_write($name, $value)
{
if ($value == 1) {
$format = 'page';
} else {
$format = 'site';
}
if (set_field('course', 'format', $format, 'id', SITEID)) {
return parent::config_write($name, $value);
}
}
示例13: set_ousearch_instance_configdata
/**
* This function sets search-type of the existing block instances to muliactivity as default
* @param void
* @return boolean
*/
function set_ousearch_instance_configdata()
{
if (!($blockid = get_field('block', 'id', 'name', 'ousearch'))) {
return false;
}
$multiactivity = 'Tzo2OiJvYmplY3QiOjQ6e3M6MTM6Ik1BWF9GSUxFX1NJWkUiO3M6OToiMTE1MzQzMzYwIjtzOjE4OiJfcWZfX291c2VhcmNoX2Zvcm0iO3M6MToiMSI7czoxMDoic2VhcmNodHlwZSI7czoxMzoibXVsdGlhY3Rpdml0eSI7czoxMjoic3VibWl0YnV0dG9uIjtzOjEyOiJTYXZlIGNoYW5nZXMiO30=';
if (!set_field('block_instance', 'configdata', $multiactivity, 'blockid', $blockid)) {
error("Could not set the filed 'configdata' in 'block_instance' table");
return false;
}
return true;
}
示例14: set_config
public static function set_config($plugin, $data, $user = 0)
{
if (record_exists('sharing_cart_plugins', 'plugin', $plugin, 'user', $user)) {
return set_field('sharing_cart_plugins', 'data', serialize($data), 'plugin', $plugin, 'user', $user);
} else {
$record = new stdClass();
$record->plugin = $plugin;
$record->user = $user;
$record->data = serialize($data);
return insert_record('sharing_cart_plugins', $record);
}
}
示例15: useredit_update_picture
function useredit_update_picture(&$usernew, &$userform)
{
global $CFG;
if (isset($usernew->deletepicture) and $usernew->deletepicture) {
$location = $CFG->dataroot . '/users/' . $usernew->id;
@remove_dir($location);
set_field('user', 'picture', 0, 'id', $usernew->id);
} else {
if ($usernew->picture = save_profile_image($usernew->id, $userform->get_um(), 'users')) {
set_field('user', 'picture', 1, 'id', $usernew->id);
}
}
}