本文整理汇总了PHP中user_picture类的典型用法代码示例。如果您正苦于以下问题:PHP user_picture类的具体用法?PHP user_picture怎么用?PHP user_picture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了user_picture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_other_values
protected function get_other_values(renderer_base $output)
{
global $PAGE, $CFG;
// Add user picture.
$userpicture = new \user_picture($this->data);
$userpicture->size = 1;
// Size f1.
$profileimageurl = $userpicture->get_url($PAGE)->out(false);
$userpicture->size = 0;
// Size f2.
$profileimageurlsmall = $userpicture->get_url($PAGE)->out(false);
$profileurl = (new moodle_url('/user/profile.php', array('id' => $this->data->id)))->out(false);
$identityfields = array_flip(explode(',', $CFG->showuseridentity));
$data = $this->data;
foreach ($identityfields as $field => $index) {
if (!empty($data->{$field})) {
$identityfields[$field] = $data->{$field};
} else {
unset($identityfields[$field]);
}
}
$identity = implode(', ', $identityfields);
return array('fullname' => fullname($this->data), 'profileimageurl' => $profileimageurl, 'profileimageurlsmall' => $profileimageurlsmall, 'profileurl' => $profileurl, 'identity' => $identity);
}
示例2: block_ranking_get_students_by_date
/**
* Get the students points based on a time interval
*
* @param int
* @param int
* @param int
* @return mixed
*/
function block_ranking_get_students_by_date($limit = null, $datestart, $dateend)
{
global $COURSE, $DB, $PAGE;
// Get block ranking configuration.
$cfgranking = get_config('block_ranking');
// Get limit from default configuration or instance configuration.
if (!$limit) {
if (isset($cfgranking->rankingsize) && trim($cfgranking->rankingsize) != '') {
$limit = $cfgranking->rankingsize;
} else {
$limit = 10;
}
}
$context = $PAGE->context;
$userfields = user_picture::fields('u', array('username'));
$sql = "SELECT\n DISTINCT {$userfields},\n sum(rl.points) as points\n FROM\n {user} u\n INNER JOIN {role_assignments} a ON a.userid = u.id\n INNER JOIN {ranking_points} r ON r.userid = u.id AND r.courseid = :r_courseid\n INNER JOIN {ranking_logs} rl ON rl.rankingid = r.id\n INNER JOIN {context} c ON c.id = a.contextid\n WHERE a.contextid = :contextid\n AND a.userid = u.id\n AND a.roleid = :roleid\n AND c.instanceid = :courseid\n AND r.courseid = :crsid\n AND rl.timecreated BETWEEN :weekstart AND :weekend\n GROUP BY u.id\n ORDER BY points DESC, u.firstname ASC\n LIMIT " . $limit;
$params['contextid'] = $context->id;
$params['roleid'] = 5;
$params['courseid'] = $COURSE->id;
$params['r_courseid'] = $COURSE->id;
$params['crsid'] = $COURSE->id;
$params['weekstart'] = $datestart;
$params['weekend'] = $dateend;
$users = array_values($DB->get_records_sql($sql, $params));
return $users;
}
示例3: test_update_user_profile_image
/**
* Test the update user profile image function.
*/
public function test_update_user_profile_image()
{
global $DB, $CFG;
// Set the profile image.
\enrol_lti\helper::update_user_profile_image($this->user1->id, $this->getExternalTestFileUrl('/test.jpg'));
// Get the new user record.
$this->user1 = $DB->get_record('user', array('id' => $this->user1->id));
// Set the page details.
$page = new moodle_page();
$page->set_url('/user/profile.php');
$page->set_context(context_system::instance());
$renderer = $page->get_renderer('core');
$usercontext = context_user::instance($this->user1->id);
// Get the user's profile picture and make sure it is correct.
$userpicture = new user_picture($this->user1);
$this->assertSame($CFG->wwwroot . '/pluginfile.php/' . $usercontext->id . '/user/icon/clean/f2?rev=' . $this->user1->picture, $userpicture->get_url($page, $renderer)->out(false));
}
示例4: get_user_picture
function get_user_picture($userid)
{
global $DB;
$extrafields[] = 'lastaccess';
$ufields = user_picture::fields('u', $extrafields);
$sql = "SELECT DISTINCT {$ufields} FROM {user} u where u.id={$userid}";
$user = $DB->get_record_sql($sql);
return new user_picture($user);
}
示例5: scheduler_get_attendants
/**
* get list of attendants for slot form
* @param int $cmid the course module
* @param mixed $groupid id number of the group to select from, 0 or '' if all groups
* @return array of moodle user records
*/
function scheduler_get_attendants($cmid, $groupid = '')
{
$context = context_module::instance($cmid);
if (!$groupid) {
$groupkeys = '';
} else {
$groupkeys = array($groupid);
}
$attendants = get_users_by_capability($context, 'mod/scheduler:attend', user_picture::fields('u'), 'u.lastname, u.firstname', '', '', $groupkeys, '', false, false, false);
return $attendants;
}
示例6: get_content
function get_content()
{
global $USER, $CFG, $DB, $OUTPUT;
if (!$CFG->messaging) {
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
if ($this->page->user_is_editing()) {
$this->content->text = get_string('disabled', 'message');
}
return $this->content;
}
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
if (empty($this->instance) or !isloggedin() or isguestuser() or empty($CFG->messaging)) {
return $this->content;
}
$link = '/message/index.php';
$action = null;
//this was using popup_action() but popping up a fullsize window seems wrong
$this->content->footer = $OUTPUT->action_link($link, get_string('messages', 'message'), $action);
$ufields = user_picture::fields('u', array('lastaccess'));
$users = $DB->get_records_sql("SELECT {$ufields}, COUNT(m.useridfrom) AS count\n FROM {user} u, {message} m\n WHERE m.useridto = ? AND u.id = m.useridfrom AND m.notification = 0\n GROUP BY {$ufields}", array($USER->id));
//Now, we have in users, the list of users to show
//Because they are online
if (!empty($users)) {
$this->content->text .= '<ul class="list">';
foreach ($users as $user) {
$timeago = format_time(time() - $user->lastaccess);
$this->content->text .= '<li class="listentry"><div class="user"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . SITEID . '" title="' . $timeago . '">';
$this->content->text .= $OUTPUT->user_picture($user, array('courseid' => SITEID));
//TODO: user might not have capability to view frontpage profile :-(
$this->content->text .= fullname($user) . '</a></div>';
$link = '/message/index.php?usergroup=unread&id=' . $user->id;
$anchortagcontents = '<img class="iconsmall" src="' . $OUTPUT->pix_url('t/message') . '" alt="" /> ' . $user->count;
$action = null;
// popup is gone now
$anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action);
$this->content->text .= '<div class="message">' . $anchortag . '</div></li>';
}
$this->content->text .= '</ul>';
} else {
$this->content->text .= '<div class="info">';
$this->content->text .= get_string('nomessages', 'message');
$this->content->text .= '</div>';
}
return $this->content;
}
示例7: definition
public function definition()
{
global $USER, $OUTPUT, $CFG;
$mform = $this->_form;
$instance = $this->_customdata;
$this->instance = $instance;
$plugin = enrol_get_plugin('boleto');
$heading = $plugin->get_instance_name($instance);
$mform->addElement('header', 'boletoheader', $heading);
if ($instance->password) {
// Change the id of boleto enrolment key input as there can be multiple boleto enrolment methods.
$mform->addElement('passwordunmask', 'enrolpassword', get_string('password', 'enrol_boleto'), array('id' => 'enrolpassword_' . $instance->id));
$context = context_course::instance($this->instance->courseid);
$keyholders = get_users_by_capability($context, 'enrol/boleto:holdkey', user_picture::fields('u'));
$keyholdercount = 0;
foreach ($keyholders as $keyholder) {
$keyholdercount++;
if ($keyholdercount === 1) {
$mform->addElement('static', 'keyholder', '', get_string('keyholder', 'enrol_boleto'));
}
$keyholdercontext = context_user::instance($keyholder->id);
if ($USER->id == $keyholder->id || has_capability('moodle/user:viewdetails', context_system::instance()) || has_coursecontact_role($keyholder->id)) {
$profilelink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $keyholder->id . '&course=' . $this->instance->courseid . '">' . fullname($keyholder) . '</a>';
} else {
$profilelink = fullname($keyholder);
}
$profilepic = $OUTPUT->user_picture($keyholder, array('size' => 35, 'courseid' => $this->instance->courseid));
$mform->addElement('static', 'keyholder' . $keyholdercount, '', $profilepic . $profilelink);
}
}
$boletourl = new moodle_url('/enrol/boleto/boleto.php', array('instanceid' => $this->instance->id));
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfo', 'enrol_boleto'));
// customint8 == avista.
if ($this->instance->customint8) {
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfodirectlinks', 'enrol_boleto', $boletourl->out(false)));
} else {
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink0', 'enrol_boleto', $boletourl->out(false)));
$boletourl->param('parcela', 1);
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink1', 'enrol_boleto', $boletourl->out(false)));
$boletourl->param('parcela', 2);
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink2', 'enrol_boleto', $boletourl->out(false)));
}
$this->add_action_buttons(false, get_string('enrolme', 'enrol_boleto'));
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->setDefault('id', $instance->courseid);
$mform->addElement('hidden', 'instance');
$mform->setType('instance', PARAM_INT);
$mform->setDefault('instance', $instance->id);
}
示例8: col_fullname
/**
* @param stdClass $data row data
* @return string HTML for the fullname column
*/
public function col_fullname($data)
{
if (is_null($data->realuserid)) {
// User is in the git history but does not have an account in this Moodle site.
$user = new stdClass();
$user->firstname = $data->firstname;
$user->lastname = $data->lastname;
// Additional fields so fullname() doesn't display a developer debug message.
$user->firstnamephonetic = null;
$user->lastnamephonetic = null;
$user->middlename = null;
$user->alternatename = null;
} else {
$user = user_picture::unalias($data, null, "realuserid", "realuser");
}
return fullname($user);
}
示例9: getUserList
function getUserList($currentgroup = '', $courseId, $contextlevel, $context, $limitUsers = 15)
{
global $USER, $CFG, $DB, $OUTPUT;
$groupmembers = "";
$groupselect = "";
$params = array();
//Add this to the SQL to show only group users
if ($currentgroup !== NULL) {
$groupmembers = ", {groups_members} gm";
$groupselect = "AND u.id = gm.userid AND gm.groupid = :currentgroup";
$params['currentgroup'] = $currentgroup;
}
$userfields = user_picture::fields('u', array('username'));
if ($courseId == SITEID or $contextlevel < CONTEXT_COURSE) {
// Site-level
//Only show if is admin
if (!checkIfUserIsAdmin()) {
return '';
}
$sql = "SELECT {$userfields}, ul.lastip, MAX(ul.timemodified) AS lastaccess\n FROM {user} u {$groupmembers} ,{sessions} ul\n WHERE u.id = ul.userid AND u.deleted = 0\n {$groupselect}\n GROUP BY {$userfields}\n ORDER BY ul.timemodified DESC ";
} else {
// Course level - show only enrolled users for now
//Only show if is teacher or admin
if (!checkIfUserIsTeacher($courseId)) {
return '';
}
list($esqljoin, $eparams) = get_enrolled_sql($context);
$params = array_merge($params, $eparams);
$sql = "SELECT {$userfields}, ul.lastip, MAX(ul.timemodified) AS lastaccess\n FROM {sessions} ul {$groupmembers}, {user} u\n JOIN ({$esqljoin}) euj ON euj.id = u.id\n WHERE u.id = ul.userid\n AND u.deleted = 0\n {$groupselect}\n GROUP BY {$userfields}\n ORDER BY lastaccess DESC";
$params['courseid'] = $courseId;
}
if ($users = $DB->get_records_sql($sql, $params, 0, $limitUsers)) {
// We'll just take the most recent 50 maximum
foreach ($users as $user) {
$users[$user->id]->fullname = fullname($user);
}
} else {
$users = array();
}
return $users;
}
示例10: __construct
/**
* Constructor.
*
* @param string $uniqueid Unique ID.
*/
public function __construct($uniqueid, $courseid)
{
global $PAGE;
parent::__construct($uniqueid);
// Block XP stuff.
$this->xpmanager = block_xp_manager::get($courseid);
$this->xpoutput = $PAGE->get_renderer('block_xp');
// Define columns.
$this->define_columns(array('rank', 'userpic', 'fullname', 'lvl', 'xp', 'progress'));
$this->define_headers(array(get_string('rank', 'block_xp'), '', get_string('fullname'), get_string('level', 'block_xp'), get_string('xp', 'block_xp'), get_string('progress', 'block_xp')));
// Define SQL.
$this->sql = new stdClass();
$this->sql->fields = 'x.*, ' . user_picture::fields('u');
$this->sql->from = '{block_xp} x LEFT JOIN {user} u ON x.userid = u.id';
$this->sql->where = 'courseid = :courseid';
$this->sql->params = array('courseid' => $courseid);
// Define various table settings.
$this->sortable(false);
$this->no_sorting('userpic');
$this->no_sorting('progress');
$this->collapsible(false);
}
示例11: get_authors
protected function get_authors() {
global $DB;
$rslt = $this->workshop->get_submissions_grouped();
//now we have to do some magic to turn these back into "authors"
$ret = array();
$users = array();
//loop 1: get user ids
foreach ($rslt as $r) {
$users[] = $r->authorid;
}
$fields = user_picture::fields();
$users = $DB->get_records_list('user','id',$users,'',$fields);
//loop 2: apply users to submissions
$ret[0] = array();
foreach ($rslt as $r){
$ret[$r->group->id] = array( $r->authorid => $users[$r->authorid] );
$ret[0][$r->authorid] = $users[$r->authorid];
}
return $ret;
}
示例12: set_sql
/**
* Store the SQL queries & params for listing online users
*
* @param int $currentgroup The group (if any) to filter on
* @param int $now Time now
* @param int $timetoshowusers Number of seconds to show online users
* @param context $context Context object used to generate the sql for users enrolled in a specific course
* @param bool $sitelevel Whether to check online users at site level.
* @param int $courseid The course id to check
*/
protected function set_sql($currentgroup, $now, $timetoshowusers, $context, $sitelevel, $courseid)
{
$timefrom = 100 * floor(($now - $timetoshowusers) / 100);
// Round to nearest 100 seconds for better query cache.
$groupmembers = "";
$groupselect = "";
$groupby = "";
$lastaccess = ", lastaccess";
$timeaccess = ", ul.timeaccess AS lastaccess";
$params = array();
$userfields = \user_picture::fields('u', array('username'));
// Add this to the SQL to show only group users.
if ($currentgroup !== null) {
$groupmembers = ", {groups_members} gm";
$groupselect = "AND u.id = gm.userid AND gm.groupid = :currentgroup";
$groupby = "GROUP BY {$userfields}";
$lastaccess = ", MAX(u.lastaccess) AS lastaccess";
$timeaccess = ", MAX(ul.timeaccess) AS lastaccess";
$params['currentgroup'] = $currentgroup;
}
$params['now'] = $now;
$params['timefrom'] = $timefrom;
if ($sitelevel) {
$sql = "SELECT {$userfields} {$lastaccess}\n FROM {user} u {$groupmembers}\n WHERE u.lastaccess > :timefrom\n AND u.lastaccess <= :now\n AND u.deleted = 0\n {$groupselect} {$groupby}\n ORDER BY lastaccess DESC ";
$csql = "SELECT COUNT(u.id)\n FROM {user} u {$groupmembers}\n WHERE u.lastaccess > :timefrom\n AND u.lastaccess <= :now\n AND u.deleted = 0\n {$groupselect}";
} else {
// Course level - show only enrolled users for now.
// TODO: add a new capability for viewing of all users (guests+enrolled+viewing).
list($esqljoin, $eparams) = get_enrolled_sql($context);
$params = array_merge($params, $eparams);
$sql = "SELECT {$userfields} {$timeaccess}\n FROM {user_lastaccess} ul {$groupmembers}, {user} u\n JOIN ({$esqljoin}) euj ON euj.id = u.id\n WHERE ul.timeaccess > :timefrom\n AND u.id = ul.userid\n AND ul.courseid = :courseid\n AND ul.timeaccess <= :now\n AND u.deleted = 0\n {$groupselect} {$groupby}\n ORDER BY lastaccess DESC";
$csql = "SELECT COUNT(u.id)\n FROM {user_lastaccess} ul {$groupmembers}, {user} u\n JOIN ({$esqljoin}) euj ON euj.id = u.id\n WHERE ul.timeaccess > :timefrom\n AND u.id = ul.userid\n AND ul.courseid = :courseid\n AND ul.timeaccess <= :now\n AND u.deleted = 0\n {$groupselect}";
$params['courseid'] = $courseid;
}
$this->sql = $sql;
$this->csql = $csql;
$this->params = $params;
}
示例13: __construct
/**
* Constructor.
*
* @param string $uniqueid Unique ID.
*/
public function __construct($uniqueid, $courseid)
{
global $DB, $PAGE;
parent::__construct($uniqueid);
// Block XP stuff.
$this->xpmanager = block_xp_manager::get($courseid);
$this->xpoutput = $PAGE->get_renderer('block_xp');
$context = context_course::instance($courseid);
// Define columns.
$this->define_columns(array('userpic', 'fullname', 'lvl', 'xp', 'progress', 'actions'));
$this->define_headers(array('', get_string('fullname'), get_string('level', 'block_xp'), get_string('xp', 'block_xp'), get_string('progress', 'block_xp'), ''));
// Get the relevant user IDs, users enrolled or users with XP.
// This might be a performance issue at some point.
$ids = array();
$users = get_enrolled_users($context, 'block/xp:earnxp');
foreach ($users as $user) {
$ids[$user->id] = $user->id;
}
unset($users);
$entries = $DB->get_recordset_sql('SELECT userid FROM {block_xp} WHERE courseid = :courseid', array('courseid' => $courseid));
foreach ($entries as $entry) {
$ids[$entry->userid] = $entry->userid;
}
$entries->close();
list($insql, $inparams) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED, 'param', true, null);
// Define SQL.
$this->sql = new stdClass();
$this->sql->fields = user_picture::fields('u') . ', x.lvl, x.xp';
$this->sql->from = "{user} u LEFT JOIN {block_xp} x ON (x.userid = u.id AND x.courseid = :courseid)";
$this->sql->where = "u.id {$insql}";
$this->sql->params = array_merge($inparams, array('courseid' => $courseid));
// Define various table settings.
$this->sortable(true, 'lvl', SORT_DESC);
$this->no_sorting('userpic');
$this->no_sorting('progress');
$this->collapsible(false);
}
示例14: col_userpic
/**
* Formats the column userpic.
*
* @param stdClass $row Table row.
* @return string Output produced.
*/
protected function col_userpic($row)
{
global $CFG, $OUTPUT;
if ($this->identitymode == block_xp_manager::IDENTITY_OFF && $this->userid != $row->userid) {
static $guestuser = null;
if ($guestuser === null) {
$guestuser = guest_user();
}
return $OUTPUT->user_picture($guestuser, array('link' => false, 'alttext' => false));
}
return $OUTPUT->user_picture(user_picture::unalias($row, null, 'userid'));
}
示例15: test_username_load_fields_from_object
/**
* Test function username_load_fields_from_object().
*/
public function test_username_load_fields_from_object()
{
$this->resetAfterTest();
// This object represents the information returned from an sql query.
$userinfo = new stdClass();
$userinfo->userid = 1;
$userinfo->username = 'loosebruce';
$userinfo->firstname = 'Bruce';
$userinfo->lastname = 'Campbell';
$userinfo->firstnamephonetic = 'ブルース';
$userinfo->lastnamephonetic = 'カンベッル';
$userinfo->middlename = '';
$userinfo->alternatename = '';
$userinfo->email = '';
$userinfo->picture = 23;
$userinfo->imagealt = 'Michael Jordan draining another basket.';
$userinfo->idnumber = 3982;
// Just user name fields.
$user = new stdClass();
$user = username_load_fields_from_object($user, $userinfo);
$expectedarray = new stdClass();
$expectedarray->firstname = 'Bruce';
$expectedarray->lastname = 'Campbell';
$expectedarray->firstnamephonetic = 'ブルース';
$expectedarray->lastnamephonetic = 'カンベッル';
$expectedarray->middlename = '';
$expectedarray->alternatename = '';
$this->assertEquals($user, $expectedarray);
// User information for showing a picture.
$user = new stdClass();
$additionalfields = explode(',', user_picture::fields());
$user = username_load_fields_from_object($user, $userinfo, null, $additionalfields);
$user->id = $userinfo->userid;
$expectedarray = new stdClass();
$expectedarray->id = 1;
$expectedarray->firstname = 'Bruce';
$expectedarray->lastname = 'Campbell';
$expectedarray->firstnamephonetic = 'ブルース';
$expectedarray->lastnamephonetic = 'カンベッル';
$expectedarray->middlename = '';
$expectedarray->alternatename = '';
$expectedarray->email = '';
$expectedarray->picture = 23;
$expectedarray->imagealt = 'Michael Jordan draining another basket.';
$this->assertEquals($user, $expectedarray);
// Alter the userinfo object to have a prefix.
$userinfo->authorfirstname = 'Bruce';
$userinfo->authorlastname = 'Campbell';
$userinfo->authorfirstnamephonetic = 'ブルース';
$userinfo->authorlastnamephonetic = 'カンベッル';
$userinfo->authormiddlename = '';
$userinfo->authorpicture = 23;
$userinfo->authorimagealt = 'Michael Jordan draining another basket.';
$userinfo->authoremail = 'test@testing.net';
// Return an object with user picture information.
$user = new stdClass();
$additionalfields = explode(',', user_picture::fields());
$user = username_load_fields_from_object($user, $userinfo, 'author', $additionalfields);
$user->id = $userinfo->userid;
$expectedarray = new stdClass();
$expectedarray->id = 1;
$expectedarray->firstname = 'Bruce';
$expectedarray->lastname = 'Campbell';
$expectedarray->firstnamephonetic = 'ブルース';
$expectedarray->lastnamephonetic = 'カンベッル';
$expectedarray->middlename = '';
$expectedarray->alternatename = '';
$expectedarray->email = 'test@testing.net';
$expectedarray->picture = 23;
$expectedarray->imagealt = 'Michael Jordan draining another basket.';
$this->assertEquals($user, $expectedarray);
}