當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。