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


PHP core_user::update_picture方法代码示例

本文整理汇总了PHP中core_user::update_picture方法的典型用法代码示例。如果您正苦于以下问题:PHP core_user::update_picture方法的具体用法?PHP core_user::update_picture怎么用?PHP core_user::update_picture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core_user的用法示例。


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

示例1: useredit_update_picture

/**
 * Updates the provided users profile picture based upon the expected fields returned from the edit or edit_advanced forms.
 *
 * @deprecated since Moodle 3.2 MDL-51789 - please use core_user::update_picture() instead.
 * @todo MDL-54858 This will be deleted in Moodle 3.6.
 * @see core_user::update_picture()
 *
 * @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 (unused)
 * @param array $filemanageroptions
 * @return bool True if the user was updated, false if it stayed the same.
 */
function useredit_update_picture(stdClass $usernew, moodleform $userform, $filemanageroptions = array())
{
    debugging('useredit_update_picture() is deprecated. Please use core_user::update_picture() instead.', DEBUG_DEVELOPER);
    return core_user::update_picture($usernew, $filemanageroptions);
}
开发者ID:gabrielrosset,项目名称:moodle,代码行数:18,代码来源:editlib.php

示例2: update_picture

 /**
  * Update or delete the user picture in the site
  *
  * @param  int  $draftitemid id of the user draft file to use as image
  * @param  bool $delete      if we should delete the user picture
  * @param  int $userid       id of the user, 0 for current user
  * @return array warnings and success status
  * @since Moodle 3.2
  * @throws moodle_exception
  */
 public static function update_picture($draftitemid, $delete = false, $userid = 0)
 {
     global $CFG, $USER, $PAGE;
     $params = self::validate_parameters(self::update_picture_parameters(), array('draftitemid' => $draftitemid, 'delete' => $delete, 'userid' => $userid));
     $context = context_system::instance();
     self::validate_context($context);
     if (!empty($CFG->disableuserimages)) {
         throw new moodle_exception('userimagesdisabled', 'admin');
     }
     if (empty($params['userid']) or $params['userid'] == $USER->id) {
         $user = $USER;
         require_capability('moodle/user:editownprofile', $context);
     } else {
         $user = core_user::get_user($params['userid'], '*', MUST_EXIST);
         core_user::require_active_user($user);
         $personalcontext = context_user::instance($user->id);
         require_capability('moodle/user:editprofile', $personalcontext);
         if (is_siteadmin($user) and !is_siteadmin($USER)) {
             // Only admins may edit other admins.
             throw new moodle_exception('useradmineditadmin');
         }
     }
     // Load the appropriate auth plugin.
     $userauth = get_auth_plugin($user->auth);
     if (is_mnet_remote_user($user) or !$userauth->can_edit_profile() or $userauth->edit_profile_url()) {
         throw new moodle_exception('noprofileedit', 'auth');
     }
     $filemanageroptions = array('maxbytes' => $CFG->maxbytes, 'subdirs' => 0, 'maxfiles' => 1, 'accepted_types' => 'web_image');
     $user->deletepicture = $params['delete'];
     $user->imagefile = $params['draftitemid'];
     $success = core_user::update_picture($user, $filemanageroptions);
     $result = array('success' => $success, 'warnings' => array());
     if ($success) {
         $userpicture = new user_picture(core_user::get_user($user->id));
         $userpicture->size = 1;
         // Size f1.
         $result['profileimageurl'] = $userpicture->get_url($PAGE)->out(false);
     }
     return $result;
 }
开发者ID:janeklb,项目名称:moodle,代码行数:50,代码来源:externallib.php

示例3: print_error

 // Pass a true old $user here.
 if (!$authplugin->user_update($user, $usernew)) {
     // Auth update failed.
     print_error('cannotupdateprofile');
 }
 // Update user with new profile data.
 user_update_user($usernew, false, false);
 // Update preferences.
 useredit_update_user_preference($usernew);
 // Update interests.
 if (isset($usernew->interests)) {
     useredit_update_interests($usernew, $usernew->interests);
 }
 // Update user picture.
 if (empty($CFG->disableuserimages)) {
     core_user::update_picture($usernew, $filemanageroptions);
 }
 // Update mail bounces.
 useredit_update_bounces($user, $usernew);
 // Update forum track preference.
 useredit_update_trackforums($user, $usernew);
 // Save custom profile fields data.
 profile_save_data($usernew);
 // Trigger event.
 \core\event\user_updated::create_from_userid($user->id)->trigger();
 // If email was changed and confirmation is required, send confirmation email now to the new address.
 if ($emailchanged && $CFG->emailchangeconfirmation) {
     $tempuser = $DB->get_record('user', array('id' => $user->id), '*', MUST_EXIST);
     $tempuser->email = $usernew->preference_newemail;
     $a = new stdClass();
     $a->url = $CFG->wwwroot . '/user/emailupdate.php?key=' . $usernew->preference_newemailkey . '&id=' . $user->id;
开发者ID:gabrielrosset,项目名称:moodle,代码行数:31,代码来源:edit.php

示例4: update_users

 /**
  * Update users
  *
  * @param array $users
  * @return null
  * @since Moodle 2.2
  */
 public static function update_users($users)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . "/user/lib.php";
     require_once $CFG->dirroot . "/user/profile/lib.php";
     // Required for customfields related function.
     // Ensure the current user is allowed to run this function.
     $context = context_system::instance();
     require_capability('moodle/user:update', $context);
     self::validate_context($context);
     $params = self::validate_parameters(self::update_users_parameters(), array('users' => $users));
     $filemanageroptions = array('maxbytes' => $CFG->maxbytes, 'subdirs' => 0, 'maxfiles' => 1, 'accepted_types' => 'web_image');
     $transaction = $DB->start_delegated_transaction();
     foreach ($params['users'] as $user) {
         user_update_user($user, true, false);
         // Update user picture if it was specified for this user.
         if (empty($CFG->disableuserimages) && isset($user['userpicture'])) {
             $userobject = (object) $user;
             $userobject->deletepicture = null;
             if ($user['userpicture'] == 0) {
                 $userobject->deletepicture = true;
             } else {
                 $userobject->imagefile = $user['userpicture'];
             }
             core_user::update_picture($userobject, $filemanageroptions);
         }
         // Update user custom fields.
         if (!empty($user['customfields'])) {
             foreach ($user['customfields'] as $customfield) {
                 // Profile_save_data() saves profile file it's expecting a user with the correct id,
                 // and custom field to be named profile_field_"shortname".
                 $user["profile_field_" . $customfield['type']] = $customfield['value'];
             }
             profile_save_data((object) $user);
         }
         // Trigger event.
         \core\event\user_updated::create_from_userid($user['id'])->trigger();
         // Preferences.
         if (!empty($user['preferences'])) {
             foreach ($user['preferences'] as $preference) {
                 set_user_preference($preference['type'], $preference['value'], $user['id']);
             }
         }
     }
     $transaction->allow_commit();
     return null;
 }
开发者ID:jackdaniels79,项目名称:moodle,代码行数:54,代码来源:externallib.php


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