本文整理汇总了PHP中backup_nested_element::set_source_array方法的典型用法代码示例。如果您正苦于以下问题:PHP backup_nested_element::set_source_array方法的具体用法?PHP backup_nested_element::set_source_array怎么用?PHP backup_nested_element::set_source_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backup_nested_element
的用法示例。
在下文中一共展示了backup_nested_element::set_source_array方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define_structure
protected function define_structure()
{
// Create really simple structure (1 nested with 1 attr and 2 fields)
$test = new backup_nested_element('test', array('id'), array('field1', 'field2'));
$test->set_source_array(array(array('id' => 1, 'field1' => 'value1', 'field2' => 'value2')));
return $test;
}
示例2: define_structure
protected function define_structure()
{
global $DB;
// Get the block
$block = $DB->get_record('block_instances', array('id' => $this->task->get_blockid()));
// Extract configdata
$config = unserialize(base64_decode($block->configdata));
// Get array of used rss feeds
if (!empty($config->rssid)) {
$feedids = $config->rssid;
// Get the IN corresponding query
list($in_sql, $in_params) = $DB->get_in_or_equal($feedids);
// Define all the in_params as sqlparams
foreach ($in_params as $key => $value) {
$in_params[$key] = backup_helper::is_sqlparam($value);
}
}
// Define each element separated
$rss_client = new backup_nested_element('rss_client', array('id'), null);
$feeds = new backup_nested_element('feeds');
$feed = new backup_nested_element('feed', array('id'), array('title', 'preferredtitle', 'description', 'shared', 'url'));
// Build the tree
$rss_client->add_child($feeds);
$feeds->add_child($feed);
// Define sources
$rss_client->set_source_array(array((object) array('id' => $this->task->get_blockid())));
// Only if there are feeds
if (!empty($config->rssid)) {
$feed->set_source_sql("\n SELECT *\n FROM {block_rss_client}\n WHERE id {$in_sql}", $in_params);
}
// Annotations (none)
// Return the root element (rss_client), wrapped into standard block structure
return $this->prepare_block_structure($rss_client);
}
示例3: define_structure
protected function define_structure()
{
//error_log("in define_structure()");
global $DB, $CFG;
// To know if we are including userinfo
$userinfo = $this->get_setting_value('users');
// Get the block
$block = $DB->get_record('block_instances', array('id' => $this->task->get_blockid()));
// Extract configdata
$config = unserialize(base64_decode($block->configdata));
//$pre=$CFG->prefix.'block_timetracker_';
$pre = 'block_timetracker_';
//error_log($pre);
$timetracker_main = new backup_nested_element('timetracker', array('id'), null);
// Define each element separated
$workerinfo = new backup_nested_element('workerinfo', array('id'), array('active', 'address', 'budget', 'comments', 'currpayrate', 'dept', 'email', 'firstname', 'idnum', 'institution', 'lastname', 'maxtermearnings', 'phonenumber', 'supervisor', 'timetrackermethod', 'mdluserid'));
//annotate mdluserid
$terms = new backup_nested_element('term', array('id'), array('name', 'month', 'day'));
$config = new backup_nested_element('config', array('id'), array('name', 'value'));
$alertunits = new backup_nested_element('alerunits', array('id'), array('timein', 'lasteditedby', 'lastedited', 'message', 'origtimein', 'origtimeout', 'payrate', 'todelete', 'alerttime'));
$alertcom = new backup_nested_element('alert_com', array('id'), array('mdluserid'));
$pending = new backup_nested_element('pending', array('id'), array('timein'));
$workunits = new backup_nested_element('workunit', array('id'), array('timein', 'timeout', 'lastedited', 'lasteditedby', 'payrate'));
// Build the tree -- isn't this all of the dependencies?
$timetracker_main->add_child($workerinfo);
$timetracker_main->add_child($terms);
$timetracker_main->add_child($config);
$workerinfo->add_child($alertunits);
$workerinfo->add_child($pending);
$alertunits->add_child($alertcom);
$workerinfo->add_child($workunits);
// Define sources
$timetracker_main->set_source_array(array((object) array('id' => $this->task->get_blockid())));
$terms->set_source_table($pre . 'term', array('courseid' => backup::VAR_COURSEID));
$config->set_source_table($pre . 'config', array('courseid' => backup::VAR_COURSEID));
if ($userinfo) {
$workerinfo->set_source_table($pre . 'workerinfo', array('courseid' => backup::VAR_COURSEID));
$alertunits->set_source_table($pre . 'alertunits', array('courseid' => backup::VAR_COURSEID, 'userid' => '../id'));
/*
//need to fix all of this
$alertcom->set_source_table($pre.'alert_com',
array('courseid' => backup::VAR_COURSEID,
'alertid'=>'../id'));
*/
$pending->set_source_table($pre . 'pending', array('courseid' => backup::VAR_COURSEID, 'userid' => '../id'));
$workunits->set_source_table($pre . 'workunit', array('courseid' => backup::VAR_COURSEID, 'userid' => '../id'));
}
// Annotations (none)
$alertcom->annotate_ids('user', 'mdluserid');
$workerinfo->annotate_ids('user', 'mdluserid');
// Return the root element (timetracker), wrapped into standard block structure
return $this->prepare_block_structure($timetracker_main);
}
示例4: define_structure
protected function define_structure()
{
global $DB;
// Get the block
$block = $DB->get_record('block_instances', array('id' => $this->task->get_blockid()));
// Extract configdata
$config = unserialize(base64_decode($block->configdata));
// Define each element separated
$pearson = new backup_nested_element('pearson', array('id'), null);
// Define sources
$pearson->set_source_array(array((object) array('id' => $this->task->get_blockid())));
// Annotations (none)
// Return the root element (pearson), wrapped into standard block structure
return $this->prepare_block_structure($pearson);
}
示例5: define_structure
protected function define_structure()
{
global $DB;
$params = array('courseid' => $this->get_courseid());
$context = get_context_instance(CONTEXT_COURSE, $params['courseid']);
$quickmail_logs = $DB->get_records('block_quickmail_log', $params);
$include_history = $this->get_setting_value('include_quickmail_log');
$backup_logs = new backup_nested_element('emaillogs', array('courseid'), null);
$log = new backup_nested_element('log', array('id'), array('userid', 'courseid', 'alternateid', 'mailto', 'subject', 'message', 'attachment', 'format', 'time'));
$backup_logs->add_child($log);
$backup_logs->set_source_array(array((object) $params));
if (!empty($quickmail_logs) and $include_history) {
$log->set_source_sql('SELECT * FROM {block_quickmail_log}
WHERE courseid = ?', array(array('sqlparam' => $this->get_courseid())));
}
$log->annotate_ids('user', 'userid');
$log->annotate_files('block_quickmail', 'log', 'id', $context->id);
$log->annotate_files('block_quickmail', 'attachment_log', 'id', $context->id);
return $this->prepare_block_structure($backup_logs);
}
示例6: define_structure
protected function define_structure()
{
global $DB;
$params = array('courseid' => $this->get_courseid());
$context = context_course::instance($params['courseid']);
//LOGS
$quickmail_logs = $DB->get_records('block_quickmail_log', $params);
$include_history = $this->get_setting_value('include_quickmail_log');
// QM BLOCK CONFIG BACKUP
// attempt to create block settings step for quickmail, so people can restore their quickmail settings
// WHY IS CONFIGS TABLE SET TO COURSES WITH AN S ID????????
$paramsTwo = array('coursesid' => $this->get_courseid());
$quickmail_block_level_settings = $DB->get_records('block_quickmail_config', $paramsTwo);
$include_config = $this->get_setting_value('include_quickmail_config');
//LOGS
$backup_logs_and_settings = new backup_nested_element('emaillogs', array('courseid'), null);
$log = new backup_nested_element('log', array('id'), array('userid', 'courseid', 'alternateid', 'mailto', 'subject', 'message', 'attachment', 'format', 'time', 'failuserids', 'additional_emails'));
// courseid name value
$quickmail_settings = new backup_nested_element('block_level_setting', array('id'), array('courseid', 'name', 'value'));
$backup_logs_and_settings->add_child($log);
$backup_logs_and_settings->add_child($quickmail_settings);
$backup_logs_and_settings->set_source_array(array((object) $params));
if (!empty($quickmail_logs) and $include_history) {
$log->set_source_sql('SELECT * FROM {block_quickmail_log}
WHERE courseid = ?', array(array('sqlparam' => $this->get_courseid())));
}
if (!empty($quickmail_block_level_settings) and $include_config) {
$quickmail_settings->set_source_sql('SELECT * FROM {block_quickmail_config}
WHERE coursesid = ?', array(array('sqlparam' => $this->get_courseid())));
}
$log->annotate_ids('user', 'userid');
//$quickmail_settings->annotate_ids('setting');
$log->annotate_files('block_quickmail', 'log', 'id', $context->id);
$log->annotate_files('block_quickmail', 'attachment_log', 'id', $context->id);
// $quickmail_settings->annotate_files('block_quickmail', 'settings', 'courseid', $context->id);
return $this->prepare_block_structure($backup_logs_and_settings);
}
示例7: define_structure
protected function define_structure()
{
global $DB;
// Define each element separated
$block = new backup_nested_element('block', array('id', 'contextid', 'version'), array('blockname', 'parentcontextid', 'showinsubcontexts', 'pagetypepattern', 'subpagepattern', 'defaultregion', 'defaultweight', 'configdata'));
$positions = new backup_nested_element('block_positions');
$position = new backup_nested_element('block_position', array('id'), array('contextid', 'pagetype', 'subpage', 'visible', 'region', 'weight'));
// Build the tree
$block->add_child($positions);
$positions->add_child($position);
// Transform configdata information if needed (process links and friends)
$blockrec = $DB->get_record('block_instances', array('id' => $this->task->get_blockid()));
if ($attrstotransform = $this->task->get_configdata_encoded_attributes()) {
$configdata = (array) unserialize(base64_decode($blockrec->configdata));
foreach ($configdata as $attribute => $value) {
if (in_array($attribute, $attrstotransform)) {
$configdata[$attribute] = $this->contenttransformer->process($value);
}
}
$blockrec->configdata = base64_encode(serialize((object) $configdata));
}
$blockrec->contextid = $this->task->get_contextid();
// Get the version of the block
$blockrec->version = $DB->get_field('block', 'version', array('name' => $this->task->get_blockname()));
// Define sources
$block->set_source_array(array($blockrec));
$position->set_source_table('block_positions', array('blockinstanceid' => backup::VAR_PARENTID));
// File anotations (for fileareas specified on each block)
foreach ($this->task->get_fileareas() as $filearea) {
$block->annotate_files('block_' . $this->task->get_blockname(), $filearea, null);
}
// Return the root element (block)
return $block;
}