本文整理汇总了PHP中feedback_create_template函数的典型用法代码示例。如果您正苦于以下问题:PHP feedback_create_template函数的具体用法?PHP feedback_create_template怎么用?PHP feedback_create_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了feedback_create_template函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: feedback_save_as_template
/**
* creates new template items.
* all items will be copied and the attribute feedback will be set to 0
* and the attribute template will be set to the new templateid
* @param object $feedback
* @param string $name the name of template shown in the templatelist
* @param int $ispublic 0:privat 1:public
* @return boolean
*/
function feedback_save_as_template($feedback, $name, $ispublic = 0)
{
$feedbackitems = get_records('feedback_item', 'feedback', $feedback->id);
if (!is_array($feedbackitems)) {
return false;
}
if (!($newtempl = feedback_create_template($feedback->course, $name, $ispublic))) {
return false;
}
//create items of this new template
foreach ($feedbackitems as $item) {
$item->id = '';
$item->feedback = 0;
$item->template = $newtempl;
$item->name = addslashes($item->name);
$item->presentation = addslashes($item->presentation);
insert_record('feedback_item', $item);
}
return true;
}
示例2: feedback_save_as_template
/**
* creates new template items.
* all items will be copied and the attribute feedback will be set to 0
* and the attribute template will be set to the new templateid
*
* @global object
* @uses CONTEXT_MODULE
* @uses CONTEXT_COURSE
* @param object $feedback
* @param string $name the name of template shown in the templatelist
* @param int $ispublic 0:privat 1:public
* @return boolean
*/
function feedback_save_as_template($feedback, $name, $ispublic = 0) {
global $DB;
$fs = get_file_storage();
if (!$feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedback->id))) {
return false;
}
if (!$newtempl = feedback_create_template($feedback->course, $name, $ispublic)) {
return false;
}
//files in the template_item are in the context of the current course or
//if the template is public the files are in the system context
//files in the feedback_item are in the feedback_context of the feedback
if ($ispublic) {
$s_context = get_system_context();
} else {
$s_context = get_context_instance(CONTEXT_COURSE, $newtempl->course);
}
$cm = get_coursemodule_from_instance('feedback', $feedback->id);
$f_context = get_context_instance(CONTEXT_MODULE, $cm->id);
//create items of this new template
//depend items we are storing temporary in an mapping list array(new id => dependitem)
//we also store a mapping of all items array(oldid => newid)
$dependitemsmap = array();
$itembackup = array();
foreach ($feedbackitems as $item) {
$t_item = clone($item);
unset($t_item->id);
$t_item->feedback = 0;
$t_item->template = $newtempl->id;
$t_item->id = $DB->insert_record('feedback_item', $t_item);
//copy all included files to the feedback_template filearea
$itemfiles = $fs->get_area_files($f_context->id,
'mod_feedback',
'item',
$item->id,
"id",
false);
if ($itemfiles) {
foreach ($itemfiles as $ifile) {
$file_record = new stdClass();
$file_record->contextid = $s_context->id;
$file_record->component = 'mod_feedback';
$file_record->filearea = 'template';
$file_record->itemid = $t_item->id;
$fs->create_file_from_storedfile($file_record, $ifile);
}
}
$itembackup[$item->id] = $t_item->id;
if ($t_item->dependitem) {
$dependitemsmap[$t_item->id] = $t_item->dependitem;
}
}
//remapping the dependency
foreach ($dependitemsmap as $key => $dependitem) {
$newitem = $DB->get_record('feedback_item', array('id'=>$key));
$newitem->dependitem = $itembackup[$newitem->dependitem];
$DB->update_record('feedback_item', $newitem);
}
return true;
}
示例3: feedback_save_as_template
/**
* creates new template items.
* all items will be copied and the attribute feedback will be set to 0
* and the attribute template will be set to the new templateid
*
* @global object
* @param object $feedback
* @param string $name the name of template shown in the templatelist
* @param int $ispublic 0:privat 1:public
* @return boolean
*/
function feedback_save_as_template($feedback, $name, $ispublic = 0)
{
global $DB;
if (!($feedbackitems = $DB->get_records('feedback_item', array('feedback' => $feedback->id)))) {
return false;
}
if (!($newtempl = feedback_create_template($feedback->course, $name, $ispublic))) {
return false;
}
//create items of this new template
foreach ($feedbackitems as $item) {
unset($item->id);
$item->feedback = 0;
$item->template = $newtempl;
$DB->insert_record('feedback_item', $nitem);
}
return true;
}