当前位置: 首页>>代码示例>>PHP>>正文


PHP stdClass::save_temp_file方法代码示例

本文整理汇总了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));
    }
}
开发者ID:rushi963,项目名称:moodle,代码行数:35,代码来源:lib.php

示例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));
    }
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:28,代码来源:lib.php

示例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);
    }
}
开发者ID:nmicha,项目名称:moodle,代码行数:26,代码来源:lib.php


注:本文中的stdClass::save_temp_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。