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


PHP process_new_icon函数代码示例

本文整理汇总了PHP中process_new_icon函数的典型用法代码示例。如果您正苦于以下问题:PHP process_new_icon函数的具体用法?PHP process_new_icon怎么用?PHP process_new_icon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了process_new_icon函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: useredit_update_picture

/**
 * Updates the provided users profile picture based upon the expected fields
 * returned from the edit or edit_advanced forms.
 *
 * @global moodle_database $DB
 * @param stdClass $usernew An object that contains some information about the user being updated
 * @param moodleform $userform The form that was submitted to edit the form
 * @return bool True if the user was updated, false if it stayed the same.
 */
function useredit_update_picture(stdClass $usernew, moodleform $userform) {
    global $CFG, $DB;
    require_once("$CFG->libdir/gdlib.php");

    $context = get_context_instance(CONTEXT_USER, $usernew->id, MUST_EXIST);
    // This will hold the value to set to the user's picture field at the end of
    // this function
    $picturetouse = null;
    if (!empty($usernew->deletepicture)) {
        // The user has chosen to delete the selected users picture
        $fs = get_file_storage();
        $fs->delete_area_files($context->id, 'user', 'icon'); // drop all areas
        $picturetouse = 0;
    } else if ($iconfile = $userform->save_temp_file('imagefile')) {
        // There is a new image that has been uploaded
        // Process the new image and set the user to make use of it.
        // NOTE: This may be overridden by Gravatar
        if (process_new_icon($context, 'user', 'icon', 0, $iconfile)) {
            $picturetouse = 1;
        }
        // Delete the file that has now been processed
        @unlink($iconfile);
    }

    // If we have a picture to set we can now do so. Note this will still be NULL
    // unless the user has changed their picture or caused a change by selecting
    // to delete their picture or use gravatar
    if (!is_null($picturetouse)) {
        $DB->set_field('user', 'picture', $picturetouse, array('id' => $usernew->id));
        return true;
    }

    return false;
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:43,代码来源:editlib.php

示例2: tool_mergeusers_old_user_suspend

/**
 * Suspend the old user, by suspending its account, and updating the profile picture
 * to a generic one.
 * @param object $event stdClass with all event data.
 * @global moodle_database $DB
 */
function tool_mergeusers_old_user_suspend($event)
{
    global $DB, $CFG;
    if ($CFG->branch < 26) {
        $oldid = $event->oldid;
    } else {
        $oldid = $event->other['usersinvolved']['fromid'];
    }
    // Check configuration to see if the old user gets suspended
    $enabled = (int) get_config('tool_mergeusers', 'suspenduser');
    if ($enabled !== 1) {
        return true;
    }
    // 1. update auth type
    $olduser = new stdClass();
    $olduser->id = $oldid;
    $olduser->suspended = 1;
    $olduser->timemodified = time();
    $DB->update_record('user', $olduser);
    // 2. update profile picture
    // get source, common image
    $fullpath = dirname(dirname(__DIR__)) . "/pix/suspended.jpg";
    if (!file_exists($fullpath)) {
        return;
        //do nothing; aborting, given that the image does not exist
    }
    // put the common image as the profile picture.
    $context = context_user::instance($oldid);
    if ($newrev = process_new_icon($context, 'user', 'icon', 0, $fullpath)) {
        $DB->set_field('user', 'picture', $newrev, array('id' => $oldid));
    }
    return true;
}
开发者ID:ndunand,项目名称:moodle-tool_mergeusers,代码行数:39,代码来源:olduser.php

示例3: useredit_update_picture

/**
 * Updates the provided users profile picture based upon the expected fields
 * returned from the edit or edit_advanced forms.
 *
 * @global moodle_database $DB
 * @param stdClass $usernew An object that contains some information about the user being updated
 * @param moodleform $userform The form that was submitted to edit the form
 * @return bool True if the user was updated, false if it stayed the same.
 */
function useredit_update_picture(stdClass $usernew, moodleform $userform)
{
    global $CFG, $DB;
    require_once "{$CFG->libdir}/gdlib.php";
    $context = get_context_instance(CONTEXT_USER, $usernew->id, MUST_EXIST);
    $user = $DB->get_record('user', array('id' => $usernew->id), 'id, picture', MUST_EXIST);
    $newpicture = $user->picture;
    if (!empty($usernew->deletepicture)) {
        // The user has chosen to delete the selected users picture
        $fs = get_file_storage();
        $fs->delete_area_files($context->id, 'user', 'icon');
        // drop all images in area
        $newpicture = 0;
    } else {
        if ($iconfile = $userform->save_temp_file('imagefile')) {
            // There is a new image that has been uploaded
            // Process the new image and set the user to make use of it.
            // NOTE: Uploaded images always take over Gravatar
            $newpicture = (int) process_new_icon($context, 'user', 'icon', 0, $iconfile);
            // Delete the file that has now been processed
            @unlink($iconfile);
        }
    }
    if ($newpicture != $user->picture) {
        $DB->set_field('user', 'picture', $newpicture, array('id' => $user->id));
        return true;
    } else {
        return false;
    }
}
开发者ID:nmicha,项目名称:moodle,代码行数:39,代码来源:editlib.php

示例4: useredit_update_picture

/**
 * Updates the provided users profile picture based upon the expected fields
 * returned from the edit or edit_advanced forms.
 *
 * @global moodle_database $DB
 * @param stdClass $usernew An object that contains some information about the user being updated
 * @param moodleform $userform The form that was submitted to edit the form
 * @return bool True if the user was updated, false if it stayed the same.
 */
function useredit_update_picture(stdClass $usernew, moodleform $userform, $filemanageroptions = array()) {
    global $CFG, $DB;
    require_once("$CFG->libdir/gdlib.php");

    $context = context_user::instance($usernew->id, MUST_EXIST);
    $user = $DB->get_record('user', array('id'=>$usernew->id), 'id, picture', MUST_EXIST);

    $newpicture = $user->picture;
    // Get file_storage to process files.
    $fs = get_file_storage();
    if (!empty($usernew->deletepicture)) {
        // The user has chosen to delete the selected users picture
        $fs->delete_area_files($context->id, 'user', 'icon'); // drop all images in area
        $newpicture = 0;

    } else {
        // Save newly uploaded file, this will avoid context mismatch for newly created users.
        file_save_draft_area_files($usernew->imagefile, $context->id, 'user', 'newicon', 0, $filemanageroptions);
        if (($iconfiles = $fs->get_area_files($context->id, 'user', 'newicon')) && count($iconfiles) == 2) {
            // Get file which was uploaded in draft area
            foreach ($iconfiles as $file) {
                if (!$file->is_directory()) {
                    break;
                }
            }
            // Copy file to temporary location and the send it for processing icon
            if ($iconfile = $file->copy_content_to_temp()) {
                // There is a new image that has been uploaded
                // Process the new image and set the user to make use of it.
                // NOTE: Uploaded images always take over Gravatar
                $newpicture = (int)process_new_icon($context, 'user', 'icon', 0, $iconfile);
                // Delete temporary file
                @unlink($iconfile);
                // Remove uploaded file.
                $fs->delete_area_files($context->id, 'user', 'newicon');
            } else {
                // Something went wrong while creating temp file.
                // Remove uploaded file.
                $fs->delete_area_files($context->id, 'user', 'newicon');
                return false;
            }
        }
    }

    if ($newpicture != $user->picture) {
        $DB->set_field('user', 'picture', $newpicture, array('id' => $user->id));
        return true;
    } else {
        return false;
    }
}
开发者ID:JP-Git,项目名称:moodle,代码行数:60,代码来源:editlib.php

示例5: useredit_update_picture

function useredit_update_picture(&$usernew, $userform)
{
    global $CFG, $DB;
    require_once "{$CFG->libdir}/gdlib.php";
    $fs = get_file_storage();
    $context = get_context_instance(CONTEXT_USER, $usernew->id, MUST_EXIST);
    if (isset($usernew->deletepicture) and $usernew->deletepicture) {
        $fs->delete_area_files($context->id, 'user', 'icon');
        // drop all areas
        $DB->set_field('user', 'picture', 0, array('id' => $usernew->id));
    } else {
        if ($iconfile = $userform->save_temp_file('imagefile')) {
            if (process_new_icon($context, 'user', 'icon', 0, $iconfile)) {
                $DB->set_field('user', 'picture', 1, array('id' => $usernew->id));
            }
            @unlink($iconfile);
        }
    }
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:19,代码来源:editlib.php

示例6: updateProfilePicture

 public function updateProfilePicture()
 {
     global $CFG;
     $has_picture = 0;
     $mhr_user = $this->getUserOnInstitution();
     if (!$mhr_user) {
         return $has_picture;
     }
     $picture_id = $mhr_user->getObject()->profileicon;
     if (!$picture_id || $picture_id == '') {
         return $has_picture;
     }
     $old_picture = $this->app->selectFromMdlTable('gcr_profile_picture', 'user_id', $this->obj->id, true);
     if (!$old_picture || $old_picture->picture_id != $picture_id) {
         $iconfile = gcr::moodledataDir . $mhr_user->getApp()->getShortName() . '/artefact/file/profileicons/originals/' . $picture_id % 256 . '/' . $picture_id;
         require_once "{$CFG->libdir}/gdlib.php";
         $context = get_context_instance(CONTEXT_USER, $this->obj->id, MUST_EXIST);
         if (process_new_icon($context, 'user', 'icon', 0, $iconfile)) {
             if ($old_picture) {
                 $this->app->updateMdlTable('gcr_profile_picture', array('picture_id' => $picture_id), array('user_id' => $this->obj->id));
             } else {
                 $this->app->insertIntoMdlTable('gcr_profile_picture', array('user_id' => $this->obj->id, 'picture_id' => $picture_id));
             }
             $has_picture = 1;
         } else {
             $fs = get_file_storage();
             $fs->delete_area_files($context->id, 'user', 'icon');
             $this->app->deleteFromMdlTable('gcr_profile_picture', 'user_id', $this->obj->id);
             $has_picture = 0;
         }
     } else {
         $has_picture = 1;
     }
     if ($this->obj->picture != $has_picture) {
         $this->app->updateMdlTable('user', array('picture' => $has_picture), array('id' => $this->obj->id));
     }
     return $has_picture;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:38,代码来源:GcrCurrentMdlUser.class.php

示例7: array

    $u->lang = 'en';
    $u->description = 'Who\'s your daddy?';
    $u->url = 'http://moodle.org';
    $u->idnumber = '';
    $u->institution = 'Moodle HQ';
    $u->department = 'Rock on!';
    $u->phone1 = '';
    $u->phone2 = '';
    $u->address = '';
    // Adds an avatar to the user. Will slow down the process.
    if (MDK_AVATAR) {
        $params = array('size' => 160, 'force' => 'y', 'default' => 'wavatar');
        $url = new moodle_url('http://www.gravatar.com/avatar/' . md5($u->id . ':' . $u->username), $params);
        // Temporary file name
        if (empty($CFG->tempdir)) {
            $tempdir = $CFG->dataroot . "/temp";
        } else {
            $tempdir = $CFG->tempdir;
        }
        $picture = $tempdir . '/' . 'mdk_script_users.jpg';
        download_file_content($url->out(false), null, null, false, 5, 2, false, $picture);
        // Ensures retro compatibility
        if (class_exists('context_user')) {
            $context = context_user::instance($u->id);
        } else {
            $context = get_context_instance(CONTEXT_USER, $u->id, MUST_EXIST);
        }
        $u->picture = process_new_icon($context, 'user', 'icon', 0, $picture);
    }
    $DB->update_record('user', $u);
}
开发者ID:rajeshtaneja,项目名称:docker,代码行数:31,代码来源:users.php

示例8: loginpage_hook


//.........这里部分代码省略.........
                     $user = (object) array_merge((array) $user, (array) $newuser);
                 }
                 complete_user_login($user);
                 // Let's save/update the access token for this user.
                 $cansaveaccesstoken = get_config('auth/googleoauth2', 'saveaccesstoken');
                 if (!empty($cansaveaccesstoken)) {
                     $existingaccesstoken = $DB->get_record('auth_googleoauth2_user_idps', array('userid' => $user->id, 'provider' => $authprovider));
                     if (empty($existingaccesstoken)) {
                         $accesstokenrow = new stdClass();
                         $accesstokenrow->userid = $user->id;
                         switch ($authprovider) {
                             case 'battlenet':
                                 $accesstokenrow->provideruserid = $userdetails->id;
                                 break;
                             default:
                                 $accesstokenrow->provideruserid = $userdetails->uid;
                                 break;
                         }
                         $accesstokenrow->provider = $authprovider;
                         $accesstokenrow->accesstoken = $accesstoken;
                         $accesstokenrow->refreshtoken = $refreshtoken;
                         $accesstokenrow->expires = $tokenexpires;
                         $DB->insert_record('auth_googleoauth2_user_idps', $accesstokenrow);
                     } else {
                         $existingaccesstoken->accesstoken = $accesstoken;
                         $DB->update_record('auth_googleoauth2_user_idps', $existingaccesstoken);
                     }
                 }
                 // Check if the user picture is the default and retrieve the provider picture.
                 if (empty($user->picture)) {
                     switch ($authprovider) {
                         case 'battlenet':
                             require_once $CFG->libdir . '/filelib.php';
                             require_once $CFG->libdir . '/gdlib.php';
                             $imagefilename = $CFG->tempdir . '/googleoauth2-portrait-' . $user->id;
                             $imagecontents = download_file_content($userdetails->portrait_url);
                             file_put_contents($imagefilename, $imagecontents);
                             if ($newrev = process_new_icon(context_user::instance($user->id), 'user', 'icon', 0, $imagefilename)) {
                                 $DB->set_field('user', 'picture', $newrev, array('id' => $user->id));
                             }
                             unlink($imagefilename);
                             break;
                         default:
                             // TODO retrieve other provider profile pictures.
                             break;
                     }
                 }
                 // Create event for authenticated user.
                 $event = \auth_googleoauth2\event\user_loggedin::create(array('context' => context_system::instance(), 'objectid' => $user->id, 'relateduserid' => $user->id, 'other' => array('accesstoken' => $accesstoken)));
                 $event->trigger();
                 // Redirection.
                 if (user_not_fully_set_up($USER)) {
                     $urltogo = $CFG->wwwroot . '/user/edit.php';
                     // We don't delete $SESSION->wantsurl yet, so we get there later.
                 } else {
                     if (isset($SESSION->wantsurl) and strpos($SESSION->wantsurl, $CFG->wwwroot) === 0) {
                         $urltogo = $SESSION->wantsurl;
                         // Because it's an address in this site.
                         unset($SESSION->wantsurl);
                     } else {
                         // No wantsurl stored or external - go to homepage.
                         $urltogo = $CFG->wwwroot . '/';
                         unset($SESSION->wantsurl);
                     }
                 }
                 $loginrecord = array('userid' => $USER->id, 'time' => time(), 'auth' => 'googleoauth2', 'subtype' => $authprovider);
                 $DB->insert_record('auth_googleoauth2_logins', $loginrecord);
                 redirect($urltogo);
             } else {
                 // Authenticate_user_login() failure, probably email registered by another auth plugin.
                 // Do a check to confirm this hypothesis.
                 $userexist = $DB->get_record('user', array('email' => $useremail));
                 if (!empty($userexist) and $userexist->auth != 'googleoauth2') {
                     $a = new stdClass();
                     $a->loginpage = (string) new moodle_url(empty($CFG->alternateloginurl) ? '/login/index.php' : $CFG->alternateloginurl);
                     $a->forgotpass = (string) new moodle_url('/login/forgot_password.php');
                     throw new moodle_exception('couldnotauthenticateuserlogin', 'auth_googleoauth2', '', $a);
                 } else {
                     throw new moodle_exception('couldnotauthenticate', 'auth_googleoauth2');
                 }
             }
         } else {
             throw new moodle_exception('couldnotgetgoogleaccesstoken', 'auth_googleoauth2');
         }
     } else {
         // If you are having issue with the display buttons option, add the button code directly in the theme login page.
         if (get_config('auth/googleoauth2', 'oauth2displaybuttons') and empty($_POST['username']) and empty($_POST['password'])) {
             // Display the button on the login page.
             require_once $CFG->dirroot . '/auth/googleoauth2/lib.php';
             // Insert the html code below the login field.
             // Code/Solution from Elcentra plugin: https://moodle.org/plugins/view/auth_elcentra.
             global $PAGE, $CFG;
             $PAGE->requires->jquery();
             $content = str_replace(array("\n", "\r"), array("\\\n", "\\\r"), auth_googleoauth2_display_buttons(false));
             $PAGE->requires->css('/auth/googleoauth2/style.css');
             $PAGE->requires->js_init_code("buttonsCodeOauth2 = '{$content}';");
             $PAGE->requires->js(new moodle_url($CFG->wwwroot . "/auth/googleoauth2/script.js"));
         }
     }
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:auth.php

示例9: assign_photo

 /**
  * Assign photo to Moodle user account.
  *
  * @param string|array $params Requested user parameters.
  * @param string $skiptoken A skiptoken param from a previous get_users query. For pagination.
  * @return boolean True on photo updated.
  */
 public function assign_photo($muserid, $user)
 {
     global $DB, $CFG, $PAGE;
     require_once "{$CFG->libdir}/gdlib.php";
     $record = $DB->get_record('local_o365_appassign', array('muserid' => $muserid));
     $photoid = '';
     if (!empty($record->photoid)) {
         $photoid = $record->photoid;
     }
     $result = false;
     $apiclient = $this->construct_outlook_api($muserid, true);
     $size = $apiclient->get_photo_metadata($user);
     $muser = $DB->get_record('user', array('id' => $muserid), 'id, picture', MUST_EXIST);
     // If there is no meta data, there is no photo.
     if (empty($size)) {
         // Profile photo has been deleted.
         if (!empty($muser->picture)) {
             // User has no photo. Deleting previous profile photo.
             $fs = \get_file_storage();
             $fs->delete_area_files($context->id, 'user', 'icon');
             $DB->set_field('user', 'picture', 0, array('id' => $muser->id));
         }
         $result = false;
     } else {
         if ($size['@odata.mediaEtag'] !== $photoid) {
             if (!empty($size['height']) && !empty($size['width'])) {
                 $image = $apiclient->get_photo($user, $size['height'], $size['width']);
             } else {
                 $image = $apiclient->get_photo($user);
             }
             // Check if json error message was returned.
             if (!preg_match('/^{/', $image)) {
                 // Update profile picture.
                 $tempfile = tempnam($CFG->tempdir . '/', 'profileimage') . '.jpg';
                 if (!($fp = fopen($tempfile, 'w+b'))) {
                     @unlink($tempfile);
                     return false;
                 }
                 fwrite($fp, $image);
                 fclose($fp);
                 $context = \context_user::instance($muserid, MUST_EXIST);
                 $newpicture = process_new_icon($context, 'user', 'icon', 0, $tempfile);
                 $photoid = $size['@odata.mediaEtag'];
                 if ($newpicture != $muser->picture) {
                     $DB->set_field('user', 'picture', $newpicture, array('id' => $muser->id));
                     $result = true;
                 }
                 @unlink($tempfile);
             }
         }
     }
     if (empty($record)) {
         $record = new \stdClass();
         $record->muserid = $muserid;
         $record->assigned = 0;
     }
     $record->photoid = $photoid;
     $record->photoupdated = time();
     if (empty($record->id)) {
         $DB->insert_record('local_o365_appassign', $record);
     } else {
         $DB->update_record('local_o365_appassign', $record);
     }
     return $result;
 }
开发者ID:andrewnicols,项目名称:o365-moodle,代码行数:72,代码来源:main.php

示例10: my_save_profile_image

/**
 * Try to save the given file (specified by its full path) as the
 * picture for the user with the given id.
 *
 * @param integer $id the internal id of the user to assign the
 *                picture file to.
 * @param string $originalfile the full path of the picture file.
 *
 * @return mixed new unique revision number or false if not saved
 */
function my_save_profile_image($id, $originalfile)
{
    $context = context_user::instance($id);
    return process_new_icon($context, 'user', 'icon', 0, $originalfile);
}
开发者ID:evltuma,项目名称:moodle,代码行数:15,代码来源:picture.php

示例11: 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

示例12: create_joomdle_user


//.........这里部分代码省略.........
         }
         if ($timezone) {
             $DB->set_field('user', 'timezone', $timezone, $conditions);
         }
         if ($phone1) {
             $DB->set_field('user', 'phone1', $phone1, $conditions);
         }
         if ($phone2) {
             $DB->set_field('user', 'phone2', $phone2, $conditions);
         }
         if ($address) {
             $DB->set_field('user', 'address', $address, $conditions);
         }
         if ($description) {
             $DB->set_field('user', 'description', $description, $conditions);
         }
         if ($institution) {
             $DB->set_field('user', 'institution', $institution, $conditions);
         }
         if ($url) {
             $DB->set_field('user', 'url', $url, $conditions);
         }
         if ($icq) {
             $DB->set_field('user', 'icq', $icq, $conditions);
         }
         if ($skype) {
             $DB->set_field('user', 'skype', $skype, $conditions);
         }
         if ($aim) {
             $DB->set_field('user', 'aim', $aim, $conditions);
         }
         if ($yahoo) {
             $DB->set_field('user', 'yahoo', $yahoo, $conditions);
         }
         if ($msn) {
             $DB->set_field('user', 'msn', $msn, $conditions);
         }
         if ($idnumber) {
             $DB->set_field('user', 'idnumber', $idnumber, $conditions);
         }
         if ($department) {
             $DB->set_field('user', 'department', $department, $conditions);
         }
         if ($lastnamephonetic) {
             $DB->set_field('user', 'lastnamephonetic', $lastnamephonetic, $conditions);
         }
         if ($firstnamephonetic) {
             $DB->set_field('user', 'firstnamephonetic', $firstnamephonetic, $conditions);
         }
         if ($middlename) {
             $DB->set_field('user', 'middlename', $middlename, $conditions);
         }
         if ($alternatename) {
             $DB->set_field('user', 'alternatename', $alternatename, $conditions);
         }
     }
     /* Get user pic */
     if (array_key_exists('pic_url', $juser_info) && $juser_info['pic_url']) {
         if ($juser_info['pic_url'] != 'none') {
             $joomla_url = get_config('auth/joomdle', 'joomla_url');
             if (strncmp($juser_info['pic_url'], 'http', 4) != 0) {
                 $pic_url = $joomla_url . '/' . $juser_info['pic_url'];
             } else {
                 $pic_url = $juser_info['pic_url'];
             }
             $pic = $this->get_file($pic_url);
             if ($pic) {
                 //$pic = file_get_contents ($pic_url, false, NULL);
                 $pic = $this->get_file_curl($pic_url);
                 $tmp_file = $CFG->dataroot . '/temp/' . 'tmp_pic';
                 file_put_contents($tmp_file, $pic);
                 $user = get_complete_user_data('username', $username);
                 // We need this to get user id
                 $context = context_user::instance($user->id);
                 process_new_icon($context, 'user', 'icon', 0, $tmp_file);
                 $conditions = array('id' => $user->id);
                 $DB->set_field('user', 'picture', 1, $conditions);
             }
         }
     }
     /* Custom fields */
     if ($fields = $DB->get_records('user_info_field')) {
         foreach ($fields as $field) {
             if (array_key_exists('cf_' . $field->id, $juser_info) && $juser_info['cf_' . $field->id]) {
                 $data = new stdClass();
                 $data->fieldid = $field->id;
                 $data->data = $juser_info['cf_' . $field->id];
                 $data->userid = $user->id;
                 /* update custom field */
                 if ($dataid = $DB->get_field('user_info_data', 'id', array('userid' => $user->id, 'fieldid' => $data->fieldid))) {
                     $data->id = $dataid;
                     $DB->update_record('user_info_data', $data);
                 } else {
                     $DB->insert_record('user_info_data', $data);
                 }
             }
         }
     }
     return 1;
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:101,代码来源:auth.php

示例13: badges_process_badge_image

/**
 * Process badge image from form data
 *
 * @param badge $badge Badge object
 * @param string $iconfile Original file
 */
function badges_process_badge_image(badge $badge, $iconfile)
{
    global $CFG, $USER;
    require_once $CFG->libdir . '/gdlib.php';
    if (!empty($CFG->gdversion)) {
        process_new_icon($badge->get_context(), 'badges', 'badgeimage', $badge->id, $iconfile, true);
        @unlink($iconfile);
        // Clean up file draft area after badge image has been saved.
        $context = context_user::instance($USER->id, MUST_EXIST);
        $fs = get_file_storage();
        $fs->delete_area_files($context->id, 'user', 'draft');
    }
}
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:19,代码来源:badgeslib.php

示例14: 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

示例15: my_save_profile_image

/**
 * Try to save the given file (specified by its full path) as the
 * picture for the user with the given id.
 *
 * @param integer $id the internal id of the user to assign the
 *                picture file to.
 * @param string $originalfile the full path of the picture file.
 *
 * @return bool
 */
function my_save_profile_image($id, $originalfile)
{
    $context = get_context_instance(CONTEXT_USER, $id);
    return process_new_icon($context, 'user', 'icon', 0, $originalfile);
}
开发者ID:vuchannguyen,项目名称:web,代码行数:15,代码来源:uploadpicture.php


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