本文整理匯總了PHP中stdClass::save_temp_file方法的典型用法代碼示例。如果您正苦於以下問題:PHP stdClass::save_temp_file方法的具體用法?PHP stdClass::save_temp_file怎麽用?PHP stdClass::save_temp_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類stdClass
的用法示例。
在下文中一共展示了stdClass::save_temp_file方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: groups_update_group_icon
/**
* Update the group icon from form data
*
* @param stdClass $group group information
* @param stdClass $data
* @param stdClass $editform
*/
function groups_update_group_icon($group, $data, $editform)
{
global $CFG, $DB;
require_once "{$CFG->libdir}/gdlib.php";
$fs = get_file_storage();
$context = context_course::instance($group->courseid, MUST_EXIST);
$newpicture = $group->picture;
if (!empty($data->deletepicture)) {
$fs->delete_area_files($context->id, 'group', 'icon', $group->id);
$newpicture = 0;
} else {
if ($iconfile = $editform->save_temp_file('imagefile')) {
if ($rev = process_new_icon($context, 'group', 'icon', $group->id, $iconfile)) {
$newpicture = $rev;
} else {
$fs->delete_area_files($context->id, 'group', 'icon', $group->id);
$newpicture = 0;
}
@unlink($iconfile);
}
}
if ($newpicture != $group->picture) {
$DB->set_field('groups', 'picture', $newpicture, array('id' => $group->id));
$group->picture = $newpicture;
// Invalidate the group data as we've updated the group record.
cache_helper::invalidate_by_definition('core', 'groupdata', array(), array($group->courseid));
}
}
示例2: groups_update_group_icon
/**
* Update the group icon from form data
*
* @param stdClass $group group information
* @param stdClass $data
* @param stdClass $editform
*/
function groups_update_group_icon($group, $data, $editform)
{
global $CFG, $DB;
require_once "{$CFG->libdir}/gdlib.php";
$fs = get_file_storage();
$context = context_course::instance($group->courseid, MUST_EXIST);
//TODO: it would make sense to allow picture deleting too (skodak)
if ($iconfile = $editform->save_temp_file('imagefile')) {
if (process_new_icon($context, 'group', 'icon', $group->id, $iconfile)) {
$DB->set_field('groups', 'picture', 1, array('id' => $group->id));
$group->picture = 1;
} else {
$fs->delete_area_files($context->id, 'group', 'icon', $group->id);
$DB->set_field('groups', 'picture', 0, array('id' => $group->id));
$group->picture = 0;
}
@unlink($iconfile);
// Invalidate the group data as we've updated the group record.
cache_helper::invalidate_by_definition('core', 'groupdata', array(), array($group->courseid));
}
}
示例3: groups_update_group_icon
/**
* Update the group icon from form data
*
* @param stdClass $group group information
* @param stdClass $data
* @param stdClass $editform
*/
function groups_update_group_icon($group, $data, $editform)
{
global $CFG, $DB;
require_once "{$CFG->libdir}/gdlib.php";
$fs = get_file_storage();
$context = get_context_instance(CONTEXT_COURSE, $group->courseid, MUST_EXIST);
//TODO: it would make sense to allow picture deleting too (skodak)
if ($iconfile = $editform->save_temp_file('imagefile')) {
if (process_new_icon($context, 'group', 'icon', $group->id, $iconfile)) {
$DB->set_field('groups', 'picture', 1, array('id' => $group->id));
$group->picture = 1;
} else {
$fs->delete_area_files($context->id, 'group', 'icon', $group->id);
$DB->set_field('groups', 'picture', 0, array('id' => $group->id));
$group->picture = 0;
}
@unlink($iconfile);
}
}