本文整理汇总了PHP中isguestuser函数的典型用法代码示例。如果您正苦于以下问题:PHP isguestuser函数的具体用法?PHP isguestuser怎么用?PHP isguestuser使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isguestuser函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content
function get_content()
{
global $CFG, $USER, $DB, $OUTPUT;
// shortcut - only for logged in users!
if (!isloggedin() || isguestuser()) {
return false;
}
// according to start_jump_session,
// remote users can't on-jump
// so don't show this block to them
if (is_mnet_remote_user($USER)) {
if (debugging() and !empty($CFG->debugdisplay)) {
$this->content = new stdClass();
$this->content->footer = html_writer::tag('span', get_string('error_localusersonly', 'block_mnet_hosts'), array('class' => 'error'));
return $this->content;
} else {
return '';
}
}
if (!is_enabled_auth('mnet')) {
if (debugging() and !empty($CFG->debugdisplay)) {
$this->content = new stdClass();
$this->content->footer = html_writer::tag('span', get_string('error_authmnetneeded', 'block_mnet_hosts'), array('class' => 'error'));
return $this->content;
} else {
return '';
}
}
if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
if (debugging() and !empty($CFG->debugdisplay)) {
$this->content = new stdClass();
$this->content->footer = html_writer::tag('span', get_string('error_roamcapabilityneeded', 'block_mnet_hosts'), array('class' => 'error'));
return $this->content;
} else {
return '';
}
}
if ($this->content !== NULL) {
return $this->content;
}
// TODO: Test this query - it's appropriate? It works?
// get the hosts and whether we are doing SSO with them
$sql = "\n SELECT DISTINCT\n h.id,\n h.name,\n h.wwwroot,\n a.name as application,\n a.display_name\n FROM\n {mnet_host} h,\n {mnet_application} a,\n {mnet_host2service} h2s_IDP,\n {mnet_service} s_IDP,\n {mnet_host2service} h2s_SP,\n {mnet_service} s_SP\n WHERE\n h.id <> ? AND\n h.id <> ? AND\n h.id = h2s_IDP.hostid AND\n h.deleted = 0 AND\n h.applicationid = a.id AND\n h2s_IDP.serviceid = s_IDP.id AND\n s_IDP.name = 'sso_idp' AND\n h2s_IDP.publish = '1' AND\n h.id = h2s_SP.hostid AND\n h2s_SP.serviceid = s_SP.id AND\n s_SP.name = 'sso_idp' AND\n h2s_SP.publish = '1'\n ORDER BY\n a.display_name,\n h.name";
$hosts = $DB->get_records_sql($sql, array($CFG->mnet_localhost_id, $CFG->mnet_all_hosts_id));
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if ($hosts) {
foreach ($hosts as $host) {
$icon = '<img src="' . $OUTPUT->pix_url('i/' . $host->application . '_host') . '"' . ' class="icon" alt="' . get_string('server', 'block_mnet_hosts') . '" /> ';
if ($host->id == $USER->mnethostid) {
$this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$host->wwwroot}\">" . $icon . s($host->name) . "</a>";
} else {
$this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . $icon . s($host->name) . "</a>";
}
}
}
return $this->content;
}
示例2: __construct
/**
* Constructor.
*
* @param array $authsequence The enabled sequence of authentication plugins.
* @param string $username The username to display.
*/
public function __construct(array $authsequence, $username = '')
{
global $CFG, $SESSION;
$this->username = $username;
$this->canloginasguest = $CFG->guestloginbutton and !isguestuser();
$this->canloginbyemail = !empty($CFG->authloginviaemail);
$this->cansignup = $CFG->registerauth == 'email' || !empty($CFG->registerauth);
$this->cookieshelpicon = new help_icon('cookiesenabled', 'core');
$this->autofocusform = !empty($CFG->loginpageautofocus);
$this->passwordautocomplete = !empty($CFG->loginpasswordautocomplete);
$this->rememberusername = isset($CFG->rememberusername) and $CFG->rememberusername == 2;
$this->forgotpasswordurl = new moodle_url($CFG->httpswwwroot . '/login/forgot_password.php');
$this->loginurl = new moodle_url($CFG->httpswwwroot . '/login/index.php');
$this->signupurl = new moodle_url('/login/signup.php');
// Authentication instructions.
$this->instructions = $CFG->auth_instructions;
if (is_enabled_auth('none')) {
$this->instructions = get_string('loginstepsnone');
} else {
if ($CFG->registerauth == 'email' && empty($this->instructions)) {
$this->instructions = get_string('loginsteps', 'core', 'signup.php');
}
}
// Identity providers.
$identityproviders = [];
foreach ($authsequence as $authname) {
$authplugin = get_auth_plugin($authname);
$identityproviders = array_merge($identityproviders, $authplugin->loginpage_idp_list($SESSION->wantsurl));
}
$this->identityproviders = $identityproviders;
}
示例3: observer
/**
* Observe the events, and dispatch them if necessary.
*
* @param \core\event\base $event The event.
* @return void
*/
public static function observer(\core\event\base $event)
{
if ($event->component === 'block_xp') {
// Skip own events.
} else {
if (!$event->userid || isguestuser($event->userid) || is_siteadmin($event->userid)) {
// Skip non-logged in users and guests.
} else {
if ($event->contextlevel !== CONTEXT_COURSE && $event->contextlevel !== CONTEXT_MODULE) {
// Ignore events outside a course.
} else {
if ($event->edulevel !== \core\event\base::LEVEL_PARTICIPATING) {
// Ignore events that are not participating.
} else {
if (!has_capability('block/xp:earnxp', $event->get_context(), $event->userid)) {
// Skip the events if the user does not have the capability to earn XP, or if it is the admin.
} else {
// Keep the event, and proceed.
$manager = block_xp_manager::get($event->courseid);
$manager->capture_event($event);
}
}
}
}
}
}
示例4: create_instance
public function create_instance($record = null, array $options = null)
{
global $CFG, $USER;
require_once $CFG->dirroot . '/mod/scorm/lib.php';
require_once $CFG->dirroot . '/mod/scorm/locallib.php';
$cfgscorm = get_config('scorm');
// Add default values for scorm.
$record = (array) $record + array('scormtype' => SCORM_TYPE_LOCAL, 'packagefile' => '', 'packagefilepath' => $CFG->dirroot . '/mod/scorm/tests/packages/singlescobasic.zip', 'packageurl' => '', 'updatefreq' => SCORM_UPDATE_NEVER, 'popup' => 0, 'width' => $cfgscorm->framewidth, 'height' => $cfgscorm->frameheight, 'skipview' => $cfgscorm->skipview, 'hidebrowse' => $cfgscorm->hidebrowse, 'displaycoursestructure' => $cfgscorm->displaycoursestructure, 'hidetoc' => $cfgscorm->hidetoc, 'nav' => $cfgscorm->nav, 'navpositionleft' => $cfgscorm->navpositionleft, 'navpositiontop' => $cfgscorm->navpositiontop, 'displayattemptstatus' => $cfgscorm->displayattemptstatus, 'timeopen' => 0, 'timeclose' => 0, 'grademethod' => GRADESCOES, 'maxgrade' => $cfgscorm->maxgrade, 'maxattempt' => $cfgscorm->maxattempt, 'whatgrade' => $cfgscorm->whatgrade, 'forcenewattempt' => $cfgscorm->forcenewattempt, 'lastattemptlock' => $cfgscorm->lastattemptlock, 'forcecompleted' => $cfgscorm->forcecompleted, 'auto' => $cfgscorm->auto);
// The 'packagefile' value corresponds to the draft file area ID. If not specified, create from packagefilepath.
if (empty($record['packagefile']) && $record['scormtype'] === SCORM_TYPE_LOCAL) {
if (!isloggedin() || isguestuser()) {
throw new coding_exception('Scorm generator requires a current user');
}
if (!file_exists($record['packagefilepath'])) {
throw new coding_exception("File {$record['packagefilepath']} does not exist");
}
$usercontext = context_user::instance($USER->id);
// Pick a random context id for specified user.
$record['packagefile'] = file_get_unused_draft_itemid();
// Add actual file there.
$filerecord = array('component' => 'user', 'filearea' => 'draft', 'contextid' => $usercontext->id, 'itemid' => $record['packagefile'], 'filename' => basename($record['packagefilepath']), 'filepath' => '/');
$fs = get_file_storage();
$fs->create_file_from_pathname($filerecord, $record['packagefilepath']);
}
return parent::create_instance($record, (array) $options);
}
示例5: navbuttons_activity_showbuttons
/**
* Check if an activity is configured to only show navbuttons when
* complete and then check if the activity is complete
* @param cm_info $cm the course module for the activity
* @return boolean true if the navbuttons should be shown
*/
function navbuttons_activity_showbuttons($cm)
{
$modname = $cm->modname;
$show = get_config('block_navbuttons', 'activity' . $modname);
if ($show === false || $show == NAVBUTTONS_ACTIVITY_ALWAYS) {
return true;
// No config or 'always show'
}
if ($show == NAVBUTTONS_ACTIVITY_NEVER) {
return false;
}
if ($show == NAVBUTTONS_ACTIVITY_COMPLETE) {
$completion = new completion_info($cm->get_course());
if (!$completion->is_enabled($cm)) {
return true;
// No completion tracking - show the buttons
}
$cmcompletion = $completion->get_data($cm);
if ($cmcompletion->completionstate == COMPLETION_INCOMPLETE) {
return false;
}
return true;
}
if (!isloggedin() || isguestuser()) {
return true;
// Always show the buttons if not logged in
}
// NAVBUTTONS_ACTIVITY_CUSTOM
$funcname = 'navbuttons_mod_' . $modname . '_showbuttons';
if (!function_exists($funcname)) {
return true;
// Shouldn't have got to here, but allow the buttons anyway
}
return $funcname($cm);
}
示例6: local_obu_apps_extend_navigation
/**
* OBU Apps - Provide left hand navigation links
*
* @package obu_apps
* @category local
* @copyright 2015, Oxford Brookes University {@link http://www.brookes.ac.uk/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function local_obu_apps_extend_navigation($navigation)
{
global $CFG;
if (!isloggedin() || isguestuser()) {
return;
}
// Find the 'apps' node
$nodeApps = $navigation->find(get_string('apps', 'local_obu_apps'), navigation_node::TYPE_SYSTEM);
// If necessary, add the 'apps' node to 'home'
if (!$nodeApps) {
$nodeHome = $navigation->children->get('1')->parent;
if ($nodeHome) {
$nodeApps = $nodeHome->add(get_string('apps', 'local_obu_apps'), null, navigation_node::TYPE_SYSTEM);
}
}
if ($nodeApps) {
// BRISC
if (get_config('local_obu_apps', 'showbrisc') == '1' && has_capability('moodle/blog:create', context_system::instance())) {
$nodeApps->add('BRISC', '/local/obu_apps/brisc.php');
// BRISC web app
}
// QuAK
if (get_config('local_obu_apps', 'showquak') == '1' && !empty($CFG->navadduserpostslinks)) {
$nodeApps->add('QuAK', '/local/obu_apps/quak.php');
// QuAK web app
}
// Polls
if (get_config('local_obu_apps', 'showpolls') == '1') {
$nodeApps->add('polls.brookes', '/local/obu_apps/polls.php');
// Polls web app
}
}
}
示例7: get_content
function get_content()
{
global $USER, $CFG, $SESSION;
$wwwroot = '';
$signup = '';
if ($this->content !== NULL) {
return $this->content;
}
if (empty($CFG->loginhttps)) {
$wwwroot = $CFG->wwwroot;
} else {
// This actually is not so secure ;-), 'cause we're
// in unencrypted connection...
$wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
}
if (!empty($CFG->registerauth)) {
$authplugin = get_auth_plugin($CFG->registerauth);
if ($authplugin->can_signup()) {
$signup = $wwwroot . '/login/signup.php';
}
}
// TODO: now that we have multiauth it is hard to find out if there is a way to change password
$forgot = $wwwroot . '/login/forgot_password.php';
if (!empty($CFG->loginpasswordautocomplete)) {
$autocomplete = 'autocomplete="off"';
} else {
$autocomplete = '';
}
$username = get_moodle_cookie();
$this->content = new stdClass();
$this->content->footer = '';
$this->content->text = '';
if (!isloggedin() or isguestuser()) {
// Show the block
if (empty($CFG->authloginviaemail)) {
$strusername = get_string('username');
} else {
$strusername = get_string('usernameemail');
}
$this->content->text .= "\n" . '<form class="loginform" id="login" method="post" action="' . get_login_url() . '" ' . $autocomplete . '>';
$this->content->text .= '<div class="c1 fld username"><label for="login_username">' . $strusername . '</label>';
$this->content->text .= '<input type="text" name="username" id="login_username" value="' . s($username) . '" /></div>';
$this->content->text .= '<div class="c1 fld password"><label for="login_password">' . get_string('password') . '</label>';
$this->content->text .= '<input type="password" name="password" id="login_password" value="" ' . $autocomplete . ' /></div>';
if (isset($CFG->rememberusername) and $CFG->rememberusername == 2) {
$checked = $username ? 'checked="checked"' : '';
$this->content->text .= '<div class="c1 rememberusername"><input type="checkbox" name="rememberusername" id="rememberusername" value="1" ' . $checked . '/>';
$this->content->text .= ' <label for="rememberusername">' . get_string('rememberusername', 'admin') . '</label></div>';
}
$this->content->text .= '<div class="c1 btn"><input type="submit" value="' . get_string('login') . '" /></div>';
$this->content->text .= "</form>\n";
if (!empty($signup)) {
$this->content->footer .= '<div><a href="' . $signup . '">' . get_string('startsignup') . '</a></div>';
}
if (!empty($forgot)) {
$this->content->footer .= '<div><a href="' . $forgot . '">' . get_string('forgotaccount') . '</a></div>';
}
}
return $this->content;
}
示例8: section_activity_summary
/**
* Taken from /format/renderer.php
* Generate a summary of the activites in a section
*
* @param stdClass $section The course_section entry from DB
* @param stdClass $course the course record from DB
* @param array $mods (argument not used)
* @return string HTML to output.
*/
public static function section_activity_summary($section, $course, $mods)
{
global $CFG;
require_once $CFG->libdir . '/completionlib.php';
$modinfo = get_fast_modinfo($course);
if (empty($modinfo->sections[$section->section])) {
return '';
}
// Generate array with count of activities in this section.
$sectionmods = array();
$total = 0;
$complete = 0;
$cancomplete = isloggedin() && !isguestuser();
$completioninfo = new completion_info($course);
foreach ($modinfo->sections[$section->section] as $cmid) {
$thismod = $modinfo->cms[$cmid];
if ($thismod->uservisible) {
if (isset($sectionmods[$thismod->modname])) {
$sectionmods[$thismod->modname]['name'] = $thismod->modplural;
$sectionmods[$thismod->modname]['count']++;
} else {
$sectionmods[$thismod->modname]['name'] = $thismod->modfullname;
$sectionmods[$thismod->modname]['count'] = 1;
}
if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
$total++;
$completiondata = $completioninfo->get_data($thismod, true);
if ($completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
$complete++;
}
}
}
}
if (empty($sectionmods)) {
// No sections.
return '';
}
// Output section activities summary.
$o = '';
$o .= "<div class='section-summary-activities mdl-right'>";
foreach ($sectionmods as $mod) {
$o .= "<span class='activity-count'>";
$o .= $mod['name'] . ': ' . $mod['count'];
$o .= "</span>";
}
$o .= "</div>";
$a = false;
// Output section completion data.
if ($total > 0) {
$a = new stdClass();
$a->complete = $complete;
$a->total = $total;
$a->percentage = $complete / $total * 100;
$o .= "<div class='section-summary-activities mdl-right'>";
$o .= "<span class='activity-count'>" . get_string('progresstotal', 'completion', $a) . "</span>";
$o .= "</div>";
}
$retobj = (object) array('output' => $o, 'progress' => $a, 'complete' => $complete, 'total' => $total);
return $retobj;
}
示例9: get_content
function get_content()
{
global $CFG;
if ($this->content !== NULL) {
return $this->content;
}
if (!isloggedin()) {
return $this->content;
}
//if(is_siteadmin()){
// return $this->content;
//}
//if(has_capability('local_collegestructure:manage', context_system::instance())){
// return $this->content;
//}
// Prep the content
$this->content = new stdClass();
if (!isloggedin() || isguestuser()) {
$this->content = '';
} else {
require_once 'exams.php';
$string = get_exams();
$this->content->text = $string;
return $this->content;
// Prepare the footer for this block
// No footer to display
$this->content->footer = '';
// Return the content object
return $this->content;
}
}
示例10: can_annotate
/**
* Figure out whether annotation is permitted here
*/
function can_annotate($url)
{
global $USER;
if (isguestuser() or !isloggedin()) {
return false;
}
$handler = annotation_summary_query::handler_for_url($url);
if (!$handler) {
return false;
}
$handler->fetch_metadata();
if ($handler->modulename && $handler->courseid) {
$cm = get_coursemodule_from_instance($handler->modulename, $handler->modinstanceid, $handler->courseid);
if ($cm) {
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!$handler->capannotate) {
return false;
} else {
return has_capability($handler->capannotate, $modcontext);
}
} else {
return false;
}
} else {
return false;
}
}
示例11: can_annotate
/**
* Figure out whether annotation is permitted here
*/
function can_annotate($url)
{
global $USER, $miagloberror;
$miagloberror = "none";
if (isguestuser() or !isloggedin()) {
$miagloberror = "not logged in";
return false;
}
$handler = annotation_summary_query::handler_for_url($url);
if (!$handler) {
$miagloberror = "not on this page " . $url;
return false;
}
$handler->fetch_metadata();
if ($handler->modulename && $handler->courseid) {
$cm = get_coursemodule_from_instance($handler->modulename, $handler->modinstanceid, $handler->courseid);
if ($cm) {
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!$handler->capannotate) {
$miagloberror = "never on this resource";
return false;
// annotation of this resource is never permitted
} else {
return has_capability($handler->capannotate, $modcontext);
}
} else {
$miagloberror = "no cm";
return false;
}
} else {
$miagloberror = "no handler";
return false;
}
}
示例12: render_custom_menu
protected function render_custom_menu(custom_menu $menu)
{
global $CFG;
require_once $CFG->dirroot . '/course/lib.php';
//navigation mycourses is no supported since 2.4
if (isloggedin() && !isguestuser() && ($mycourses = enrol_get_my_courses(NULL, 'visible DESC, fullname ASC'))) {
$branchlabel = get_string('mycourses');
$branchurl = new moodle_url('/course/index.php');
$branchtitle = $branchlabel;
$branchsort = 8000;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
foreach ($mycourses as $mycourse) {
$branch->add($mycourse->shortname, new moodle_url('/course/view.php', array('id' => $mycourse->id)), $mycourse->fullname);
}
}
$course_id = $this->page->course->id;
if (isloggedin() && $course_id > 1) {
$branchlabel = get_string('grades');
$branchurl = new moodle_url('/grade/report/index.php?id=' . $this->page->course->id);
$branchtitle = $branchlabel;
$branchsort = 10000;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
}
return parent::render_custom_menu($menu);
}
示例13: atto_managefiles_params_for_js
/**
* Sends the parameters to JS module.
*
* @return array
*/
function atto_managefiles_params_for_js($elementid, $options, $fpoptions)
{
global $CFG, $USER;
require_once $CFG->dirroot . '/repository/lib.php';
// Load constants.
// Disabled if:
// - Not logged in or guest.
// - Files are not allowed.
// - Only URL are supported.
$disabled = !isloggedin() || isguestuser() || (!isset($options['maxfiles']) || $options['maxfiles'] == 0) || isset($options['return_types']) && !($options['return_types'] & ~FILE_EXTERNAL);
$params = array('disabled' => $disabled, 'area' => array(), 'usercontext' => null);
if (!$disabled) {
$params['usercontext'] = context_user::instance($USER->id)->id;
foreach (array('itemid', 'context', 'areamaxbytes', 'maxbytes', 'subdirs', 'return_types') as $key) {
if (isset($options[$key])) {
if ($key === 'context' && is_object($options[$key])) {
// Just context id is enough.
$params['area'][$key] = $options[$key]->id;
} else {
$params['area'][$key] = $options[$key];
}
}
}
}
return $params;
}
示例14: get_content
function get_content()
{
global $CFG, $USER, $PAGE, $OUTPUT;
if ($this->content !== NULL) {
return $this->content;
}
if (empty($this->instance)) {
return null;
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
if (isloggedin() && !isguestuser()) {
// Show the block
$this->content = new stdClass();
//TODO: add capability check here!
$renderer = $this->page->get_renderer('block_private_files');
$this->content->text = $renderer->private_files_tree();
if (has_capability('moodle/user:manageownfiles', $this->context)) {
$this->content->text .= $OUTPUT->single_button(new moodle_url('/user/files.php', array('returnurl' => $PAGE->url->out())), get_string('myfilesmanage'), 'get');
}
$this->content->footer = '';
}
return $this->content;
}
示例15: badge
/**
* Render the badge element (message count)
*
* @param null $userid
* @return string
*/
public function badge($userid = null)
{
global $USER, $DB, $COURSE, $PAGE;
// Only for logged in folks and when we are enabled.
if (!isset($USER->message_badge_disabled)) {
if (mr_off('badge', 'message') or !isloggedin() or isguestuser()) {
$USER->message_badge_disabled = true;
} else {
$USER->message_badge_disabled = $DB->record_exists('message_processors', array('name' => 'badge', 'enabled' => 0));
}
}
if ($USER->message_badge_disabled) {
return '';
}
if ($this->is_mobile()) {
return $this->mobile($userid);
}
$repo = new message_output_badge_repository_message();
$forwardurl = new moodle_url('/message/output/badge/view.php', array('action' => 'forward', 'courseid' => $COURSE->id));
$total = $repo->count_user_unread_messages($userid);
$PAGE->requires->js_init_call('M.snap_message_badge.init_badge', array($forwardurl->out(false), $COURSE->id), false, $this->get_js_module());
if (!empty($total)) {
$countdiv = html_writer::tag('span', $total, array('id' => html_writer::random_id(), 'class' => 'message_badge_count'));
} else {
$countdiv = '';
}
return $countdiv;
}