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


PHP session_is_loggedinas函数代码示例

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


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

示例1: checkAuthorization

 protected function checkAuthorization()
 {
     global $CFG;
     $CFG->current_app->requireMoodle();
     if ($CFG->current_app->isHome()) {
         $CFG->current_app->requireLogin();
         if ($CFG->current_app->hasPrivilege('GCHomeAdmin') && !session_is_loggedinas()) {
             return true;
         }
     }
     $CFG->current_app->gcError('Unprivileged attempted access to admin module!', 'gcpageaccessdenied');
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:12,代码来源:actions.class.php

示例2: check_capability

    /**
     * Checks if user has a capability to view the current repository.
     *
     * @return bool true when the user can, otherwise throws an exception.
     * @throws repository_exception when the user does not meet the requirements.
     */
    public final function check_capability() {
        global $USER;

        // The context we are on.
        $currentcontext = $this->context;

        // Ensure that the user can view the repository in the current context.
        $can = has_capability('repository/'.$this->type.':view', $currentcontext);

        // Context in which the repository has been created.
        $repocontext = context::instance_by_id($this->instance->contextid);

        // Prevent access to private repositories when logged in as.
        if (session_is_loggedinas()) {
            $allowed = array('coursefiles', 'equella', 'filesystem', 'flickr_public', 'local', 'merlot', 'recent',
                's3', 'upload', 'url', 'user', 'webdav', 'wikimedia', 'youtube');
            // Are only accessible the repositories which do not contain private data (any data
            // that is not part of Moodle, "Private files" is not considered "Pivate"). And if they
            // do not contain private data, then it should not be a user instance, which is private by definition.
            if (!in_array($this->type, $allowed) || $repocontext->contextlevel == CONTEXT_USER) {
                $can = false;
            }
        }

        // We are going to ensure that the current context was legit, and reliable to check
        // the capability against. (No need to do that if we already cannot).
        if ($can) {
            if ($repocontext->contextlevel == CONTEXT_USER) {
                // The repository is a user instance, ensure we're the right user to access it!
                if ($repocontext->instanceid != $USER->id) {
                    $can = false;
                }
            } else if ($repocontext->contextlevel == CONTEXT_COURSE) {
                // The repository is a course one. Let's check that we are on the right course.
                if (in_array($currentcontext->contextlevel, array(CONTEXT_COURSE, CONTEXT_MODULE, CONTEXT_BLOCK))) {
                    $coursecontext = $currentcontext->get_course_context();
                    if ($coursecontext->instanceid != $repocontext->instanceid) {
                        $can = false;
                    }
                } else {
                    // We are on a parent context, therefore it's legit to check the permissions
                    // in the current context.
                }
            } else {
                // Nothing to check here, system instances can have different permissions on different
                // levels. We do not want to prevent URL hack here, because it does not make sense to
                // prevent a user to access a repository in a context if it's accessible in another one.
            }
        }

        if ($can) {
            return true;
        }

        throw new repository_exception('nopermissiontoaccess', 'repository');
    }
开发者ID:ncsu-delta,项目名称:moodle,代码行数:62,代码来源:lib.php

示例3: login_info

 /**
  * Return the standard string that says whether you are logged in (and switched
  * roles/logged in as another user).
  * @param bool $withlinks if false, then don't include any links in the HTML produced.
  * If not set, the default is the nologinlinks option from the theme config.php file,
  * and if that is not set, then links are included.
  * @return string HTML fragment.
  */
 public function login_info($withlinks = null)
 {
     global $USER, $CFG, $DB, $SESSION;
     if (right_to_left()) {
         $direction = array('left-side' => 'right', 'right-side' => 'left');
         $dir = 'right';
     } else {
         $direction = array('left-side' => 'left', 'right-side' => 'right');
         $dir = '';
     }
     // Check Page layout options for links
     // Obscure, but whatever...
     if (is_null($withlinks)) {
         $withlinks = empty($this->page->layout_options['nologinlinks']);
     }
     // Setup a check for if we're on the login page
     $loginurl = get_login_url();
     $loginpage = (string) $this->page->url === $loginurl;
     $logouturl = $CFG->wwwroot . '/login/logout.php';
     // This should be overridden with sesskey() info
     $logouturl = $CFG->wwwroot . '/login/logout.php?sesskey=' . sesskey();
     $course = $this->page->course;
     if (during_initial_install() || empty($course->id)) {
         // $course->id is not defined during installation
         // Logins don't exist yet...
         return '';
     }
     // Assume they're not logged in
     $loggedinas = '';
     // Build some general output components
     // Divider
     $divider = html_writer::empty_tag('li', array('class' => 'divider ' . $dir));
     // Start li
     $startli = html_writer::start_tag('li', array('class' => $dir));
     $startdropdownli = html_writer::start_tag('li', array('class' => 'has-dropdown ' . $dir));
     // End li
     $endli = html_writer::end_tag('li');
     // Login button
     $loginbutton = $divider;
     $loginbutton .= html_writer::start_tag('li', array('class' => 'has-form'));
     $loginbutton .= html_writer::tag('a', get_string('login'), array('href' => $loginurl, 'class' => 'button'));
     $loginbutton .= html_writer::end_tag('li');
     // Logout button
     $logoutbutton = html_writer::empty_tag('li', array('class' => 'divider'));
     $logoutbutton .= html_writer::start_tag('li', array('class' => 'has-form'));
     $logoutbutton .= html_writer::tag('a', get_string('logout'), array('href' => $logouturl, 'class' => 'button'));
     $logoutbutton .= html_writer::end_tag('li');
     if (!$loginpage) {
         // Don't show any login info on the login page
         if (isloggedin()) {
             // Logged in users (MNET, guest, switched role, loggedinas, normal)
             $fullname = fullname($USER, true);
             $mnetuser = is_mnet_remote_user($USER) && ($idprovider = $DB->get_record('mnet_host', array('id' => $USER->mnethostid)));
             $mnetuserpanel = '';
             $roleswitched = is_role_switched($course->id);
             $roleswitchedpanel = '';
             $loggedinasuser = session_is_loggedinas();
             $loggedinasuserpanel = '';
             if ($mnetuser) {
                 $providerurl = $idprovider->wwwroot;
                 $providername = $idprovider->name;
                 $providerlink = html_writer::tag('a', $providername, array('href' => $providerurl));
                 $roleswitched || $loggedinasuser ? $mnetuserpanel .= $divider : null;
                 if ($withlinks) {
                     $mnetuserpanel .= $startli;
                     $mnetuserpanel .= html_writer::tag('label', get_string('yourhost', 'mnet') . ':');
                     $mnetuserpanel .= html_writer::tag('li', $providerlink);
                     $mnetuserpanel .= $endli;
                 } else {
                     $mnetuserpanel .= $startli;
                     $mnetuserpanel .= html_writer::tag('label', $providername);
                     $mnetuserpanel .= $endli;
                 }
             }
             if ($roleswitched) {
                 $rolename = '';
                 $context = context_course::instance($course->id);
                 if ($role = $DB->get_record('role', array('id' => $USER->access['rsw'][$context->path]))) {
                     $rolename = format_string($role->name);
                 }
                 if (empty($rolename)) {
                     // Specially for Admins - they have no original role Title...
                     $rolename = get_string('admin');
                 }
                 $returnrolelinkparams = array('id' => $course->id, 'sesskey' => sesskey(), 'switchrole' => 0, 'returnurl' => $this->page->url->out_as_local_url(false));
                 $returnrolelink = new moodle_url('/course/switchrole.php', $returnrolelinkparams);
                 $returnrolelink = html_writer::tag('a', $rolename, array('href' => $returnrolelink));
                 // Add a divider if the user is also role switched or MNET
                 $mnetuser || $loggedinasuser ? $roleswitchedpanel .= $divider : null;
                 if ($withlinks) {
                     $roleswitchedpanel .= $startli;
                     $roleswitchedpanel .= html_writer::tag('label', get_string('switchrolereturn'));
//.........这里部分代码省略.........
开发者ID:HaakonME,项目名称:foundation4-for-moodle2,代码行数:101,代码来源:outputrenderers.php

示例4: clean_filename

            }
        }
    }
}
// Apache log integration. In apache conf file one can use ${MOODULEUSER}n in
// LogFormat to get the current logged in username in moodle.
if ($USER && function_exists('apache_note') && !empty($CFG->apacheloguser) && isset($USER->username)) {
    $apachelog_userid = $USER->id;
    $apachelog_username = clean_filename($USER->username);
    $apachelog_name = '';
    if (isset($USER->firstname)) {
        // We can assume both will be set
        // - even if to empty.
        $apachelog_name = clean_filename($USER->firstname . " " . $USER->lastname);
    }
    if (session_is_loggedinas()) {
        $realuser = session_get_realuser();
        $apachelog_username = clean_filename($realuser->username . " as " . $apachelog_username);
        $apachelog_name = clean_filename($realuser->firstname . " " . $realuser->lastname . " as " . $apachelog_name);
        $apachelog_userid = clean_filename($realuser->id . " as " . $apachelog_userid);
    }
    switch ($CFG->apacheloguser) {
        case 3:
            $logname = $apachelog_username;
            break;
        case 2:
            $logname = $apachelog_name;
            break;
        case 1:
        default:
            $logname = $apachelog_userid;
开发者ID:hatone,项目名称:moodle,代码行数:31,代码来源:setup.php

示例5: user_accesstime_log

/**
 * Store user last access times - called when use enters a course or site
 *
 * @global object
 * @global object
 * @global object
 * @uses LASTACCESS_UPDATE_SECS
 * @uses SITEID
 * @param int $courseid, empty means site
 * @return void
 */
function user_accesstime_log($courseid = 0)
{
    global $USER, $CFG, $DB;
    if (!isloggedin() or session_is_loggedinas()) {
        // no access tracking
        return;
    }
    if (empty($courseid)) {
        $courseid = SITEID;
    }
    $timenow = time();
    /// Store site lastaccess time for the current user
    if ($timenow - $USER->lastaccess > LASTACCESS_UPDATE_SECS) {
        /// Update $USER->lastaccess for next checks
        $USER->lastaccess = $timenow;
        $last = new stdClass();
        $last->id = $USER->id;
        $last->lastip = getremoteaddr();
        $last->lastaccess = $timenow;
        $DB->update_record_raw('user', $last);
    }
    if ($courseid == SITEID) {
        ///  no user_lastaccess for frontpage
        return;
    }
    /// Store course lastaccess times for the current user
    if (empty($USER->currentcourseaccess[$courseid]) or $timenow - $USER->currentcourseaccess[$courseid] > LASTACCESS_UPDATE_SECS) {
        $lastaccess = $DB->get_field('user_lastaccess', 'timeaccess', array('userid' => $USER->id, 'courseid' => $courseid));
        if ($lastaccess === false) {
            // Update course lastaccess for next checks
            $USER->currentcourseaccess[$courseid] = $timenow;
            $last = new stdClass();
            $last->userid = $USER->id;
            $last->courseid = $courseid;
            $last->timeaccess = $timenow;
            $DB->insert_record_raw('user_lastaccess', $last, false);
        } else {
            if ($timenow - $lastaccess < LASTACCESS_UPDATE_SECS) {
                // no need to update now, it was updated recently in concurrent login ;-)
            } else {
                // Update course lastaccess for next checks
                $USER->currentcourseaccess[$courseid] = $timenow;
                $DB->set_field('user_lastaccess', 'timeaccess', $timenow, array('userid' => $USER->id, 'courseid' => $courseid));
            }
        }
    }
}
开发者ID:rosenclever,项目名称:moodle,代码行数:58,代码来源:datalib.php

示例6: session_loginas

/**
 * Login as another user - no security checks here.
 * @param int $userid
 * @param stdClass $context
 * @return void
 */
function session_loginas($userid, $context)
{
    if (session_is_loggedinas()) {
        return;
    }
    // switch to fresh new $SESSION
    $_SESSION['REALSESSION'] = $_SESSION['SESSION'];
    $_SESSION['SESSION'] = new stdClass();
    /// Create the new $USER object with all details and reload needed capabilities
    $_SESSION['REALUSER'] = $_SESSION['USER'];
    $user = get_complete_user_data('id', $userid);
    $user->realuser = $_SESSION['REALUSER']->id;
    $user->loginascontext = $context;
    // let enrol plugins deal with new enrolments if necessary
    enrol_check_plugins($user);
    // set up global $USER
    session_set_user($user);
}
开发者ID:neogic,项目名称:moodle,代码行数:24,代码来源:sessionlib.php

示例7: array

                    $links = array();

                    if ($CFG->bloglevel > 0) {
                        $links[] = html_writer::link(new moodle_url('/blog/index.php?userid='.$user->id), get_string('blogs','blog'));
                    }

                    if (!empty($CFG->enablenotes) and (has_capability('moodle/notes:manage', $context) || has_capability('moodle/notes:view', $context))) {
                        $links[] = html_writer::link(new moodle_url('/notes/index.php?course=' . $course->id. '&user='.$user->id), get_string('notes','notes'));
                    }

                    if (has_capability('moodle/site:viewreports', $context) or has_capability('moodle/user:viewuseractivitiesreport', $usercontext)) {
                        $links[] = html_writer::link(new moodle_url('/course/user.php?id='. $course->id .'&user='. $user->id), get_string('activity'));
                    }

                    if ($USER->id != $user->id && !session_is_loggedinas() && has_capability('moodle/user:loginas', $context) && !is_siteadmin($user->id)) {
                        $links[] = html_writer::link(new moodle_url('/course/loginas.php?id='. $course->id .'&user='. $user->id .'&sesskey='. sesskey()), get_string('loginas'));
                    }

                    $links[] = html_writer::link(new moodle_url('/user/view.php?id='. $user->id .'&course='. $course->id), get_string('fullprofile') . '...');

                    $row->cells[2]->text .= implode('', $links);

                    if (!empty($messageselect)) {
                        $row->cells[2]->text .= '<br /><input type="checkbox" name="user'.$user->id.'" /> ';
                    }
                    $table->data = array($row);
                    echo html_writer::table($table);
                }

            } else {
开发者ID:rolandovanegas,项目名称:moodle,代码行数:30,代码来源:index.php

示例8: header

    /**
     * Renders the header for the page
     *
     * @return string
     */
    public function header() {
        global $USER, $CFG;

        if (session_is_loggedinas()) {
            $this->page->add_body_class('userloggedinas');
        }

        $this->page->set_state(moodle_page::STATE_PRINTING_HEADER);

        // Find the appropriate page layout file, based on $this->page->pagelayout.
        $layoutfile = $this->page->theme->layout_file($this->page->pagelayout);
        // Render the layout using the layout file.
        $rendered = $this->render_page_layout($layoutfile);

        // Slice the rendered output into header and footer.
        $cutpos = strpos($rendered, $this->unique_main_content_token);
        if ($cutpos === false) {
            $cutpos = strpos($rendered, self::MAIN_CONTENT_TOKEN);
            $token = self::MAIN_CONTENT_TOKEN;
        } else {
            $token = $this->unique_main_content_token;
        }

        if ($cutpos === false) {
            // TODO: Search for a better solution to this... check this is even needed?
            //       The following code will lead to header containing nothing, and
            //       footer containing all of the content for the template.
            // turned off error by john for ajax load of blocks without main content.
            // throw new coding_exception('page layout file ' . $layoutfile .
            //        ' does not contain the string "' . self::MAIN_CONTENT_TOKEN . '".');
        }
        $header = substr($rendered, 0, $cutpos);
        $footer = substr($rendered, $cutpos + strlen($token));

        if (empty($this->contenttype)) {
            debugging('The page layout file did not call $OUTPUT->doctype()');
            $header = $this->doctype() . $header;
        }

        send_headers($this->contenttype, $this->page->cacheable);

        $this->opencontainers->push('header/footer', $footer);
        $this->page->set_state(moodle_page::STATE_IN_BODY);

        return $header . $this->skip_link_target('maincontent');
    }
开发者ID:nigeli,项目名称:moodle,代码行数:51,代码来源:renderers.php

示例9: header

 /**
  * Start output by sending the HTTP headers, and printing the HTML <head>
  * and the start of the <body>.
  *
  * To control what is printed, you should set properties on $PAGE. If you
  * are familiar with the old {@link print_header()} function from Moodle 1.9
  * you will find that there are properties on $PAGE that correspond to most
  * of the old parameters to could be passed to print_header.
  *
  * Not that, in due course, the remaining $navigation, $menu parameters here
  * will be replaced by more properties of $PAGE, but that is still to do.
  *
  * @return string HTML that you must output this, preferably immediately.
  */
 public function header()
 {
     global $USER, $CFG;
     if (session_is_loggedinas()) {
         $this->page->add_body_class('userloggedinas');
     }
     // Give themes a chance to init/alter the page object.
     $this->page->theme->init_page($this->page);
     $this->page->set_state(moodle_page::STATE_PRINTING_HEADER);
     // Find the appropriate page layout file, based on $this->page->pagelayout.
     $layoutfile = $this->page->theme->layout_file($this->page->pagelayout);
     // Render the layout using the layout file.
     $rendered = $this->render_page_layout($layoutfile);
     // Slice the rendered output into header and footer.
     $cutpos = strpos($rendered, $this->unique_main_content_token);
     if ($cutpos === false) {
         $cutpos = strpos($rendered, self::MAIN_CONTENT_TOKEN);
         $token = self::MAIN_CONTENT_TOKEN;
     } else {
         $token = $this->unique_main_content_token;
     }
     if ($cutpos === false) {
         throw new coding_exception('page layout file ' . $layoutfile . ' does not contain the main content placeholder, please include "<?php echo $OUTPUT->main_content() ?>" in theme layout file.');
     }
     $header = substr($rendered, 0, $cutpos);
     $footer = substr($rendered, $cutpos + strlen($token));
     if (empty($this->contenttype)) {
         debugging('The page layout file did not call $OUTPUT->doctype()');
         $header = $this->doctype() . $header;
     }
     // If this theme version is below 2.4 release and this is a course view page
     if ((!isset($this->page->theme->settings->version) || $this->page->theme->settings->version < 2012101500) && $this->page->pagelayout === 'course' && $this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
         // check if course content header/footer have not been output during render of theme layout
         $coursecontentheader = $this->course_content_header(true);
         $coursecontentfooter = $this->course_content_footer(true);
         if (!empty($coursecontentheader)) {
             // display debug message and add header and footer right above and below main content
             // Please note that course header and footer (to be displayed above and below the whole page)
             // are not displayed in this case at all.
             // Besides the content header and footer are not displayed on any other course page
             debugging('The current theme is not optimised for 2.4, the course-specific header and footer defined in course format will not be output', DEBUG_DEVELOPER);
             $header .= $coursecontentheader;
             $footer = $coursecontentfooter . $footer;
         }
     }
     send_headers($this->contenttype, $this->page->cacheable);
     $this->opencontainers->push('header/footer', $footer);
     $this->page->set_state(moodle_page::STATE_IN_BODY);
     return $header . $this->skip_link_target('maincontent');
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:64,代码来源:outputrenderers.php

示例10: get_content

 function get_content()
 {
     global $CFG, $USER, $DB, $OUTPUT;
     // shortcut -  only for logged in users!
     if (!isloggedin() || isguestuser()) {
         return false;
     }
     if (session_is_loggedinas()) {
         $this->content = new stdClass();
         $this->content->footer = html_writer::tag('span', get_string('notpermittedtojumpas', 'mnet'));
         return $this->content;
     }
     // 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', context_system::instance(), 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') . '" />&nbsp;';
             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;
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:65,代码来源:block_mnet_hosts.php

示例11: require_capability

                    require_capability(ATTENDANCEREGISTER_CAPABILITY_ADD_OWN_OFFLINE_SESSIONS, $context);
                } else {
                    require_capability(ATTENDANCEREGISTER_CAPABILITY_ADD_OTHER_OFFLINE_SESSIONS, $context);
                }
                // Do save Offline Session
                $doSaveOfflineSession = true;
            }
        }
    }
}
/// Check capabilities to delete self cert
// (in the meanwhile retrieve the record to delete)
$doDeleteOfflineSession = false;
if ($sessionToDelete) {
    // Check if logged-in-as Session Delete
    if (session_is_loggedinas() && !ATTENDANCEREGISTER_ACTION_SAVE_OFFLINE_SESSION) {
        print_error('onlyrealusercandeleteofflinesessions', 'attendanceregister');
    } else {
        if (attendanceregister__isCurrentUser($userId)) {
            require_capability(ATTENDANCEREGISTER_CAPABILITY_DELETE_OWN_OFFLINE_SESSIONS, $context);
            $doDeleteOfflineSession = true;
        } else {
            require_capability(ATTENDANCEREGISTER_CAPABILITY_DELETE_OTHER_OFFLINE_SESSIONS, $context);
            $doDeleteOfflineSession = true;
        }
    }
}
// ===========================
// Retrieve data to be shown
// ===========================
// Retrieve Course Completion info object
开发者ID:ULCC-QMUL,项目名称:moodle-mod_attendanceregister,代码行数:31,代码来源:view.php

示例12: check_capability

    /**
     * Checks if user has a capability to view the current repository.
     *
     * @return bool true when the user can, otherwise throws an exception.
     * @throws repository_exception when the user does not meet the requirements.
     */
    public final function check_capability() {
        global $USER;

        // The context we are on.
        $currentcontext = $this->context;

        // Ensure that the user can view the repository in the current context.
        $can = has_capability('repository/'.$this->get_typename().':view', $currentcontext);

        // Context in which the repository has been created.
        $repocontext = context::instance_by_id($this->instance->contextid);

        // Prevent access to private repositories when logged in as.
        if ($can && session_is_loggedinas()) {
            if ($this->contains_private_data() || $repocontext->contextlevel == CONTEXT_USER) {
                $can = false;
            }
        }

        // We are going to ensure that the current context was legit, and reliable to check
        // the capability against. (No need to do that if we already cannot).
        if ($can) {
            if ($repocontext->contextlevel == CONTEXT_USER) {
                // The repository is a user instance, ensure we're the right user to access it!
                if ($repocontext->instanceid != $USER->id) {
                    $can = false;
                }
            } else if ($repocontext->contextlevel == CONTEXT_COURSE) {
                // The repository is a course one. Let's check that we are on the right course.
                if (in_array($currentcontext->contextlevel, array(CONTEXT_COURSE, CONTEXT_MODULE, CONTEXT_BLOCK))) {
                    $coursecontext = $currentcontext->get_course_context();
                    if ($coursecontext->instanceid != $repocontext->instanceid) {
                        $can = false;
                    }
                } else {
                    // We are on a parent context, therefore it's legit to check the permissions
                    // in the current context.
                }
            } else {
                // Nothing to check here, system instances can have different permissions on different
                // levels. We do not want to prevent URL hack here, because it does not make sense to
                // prevent a user to access a repository in a context if it's accessible in another one.
            }
        }

        if ($can) {
            return true;
        }

        throw new repository_exception('nopermissiontoaccess', 'repository');
    }
开发者ID:verbazend,项目名称:AWFA,代码行数:57,代码来源:lib.php

示例13:

     <table id="header-table">
         <tr>
             <td id="headertop_left">
                 <h1 id="site-logo">
                     <div id="banner"></div>
                 </h1>
             </td>
             <td id="headertop_center">
                 <?php 
 print $CFG->current_app->getConfigVar('gc_eschool_message');
 ?>
             </td>
             <td id="headertop_right">
                 <?php 
 if ($CFG->current_app->isLoggedIn()) {
     if ($gc_admin || session_is_loggedinas()) {
         ?>
                         <div class="headermenu">
                             <?php 
         echo $OUTPUT->login_info();
         if (!empty($PAGE->layout_options['langmenu'])) {
             echo $OUTPUT->lang_menu();
         }
         echo $PAGE->headingmenu;
         ?>
                         </div>
                     <?php 
     } else {
         if ($is_guest) {
             ?>
                         <div class="headermenu">
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:report.php

示例14: user_login_string

/**
 * Returns text to be displayed to the user which reflects their login status
 *
 * @global object
 * @global object
 * @global object
 * @global object
 * @uses CONTEXT_COURSE
 * @param course $course {@link $COURSE} object containing course information
 * @param user $user {@link $USER} object containing user information
 * @return string HTML
 */
function user_login_string($course = NULL, $user = NULL)
{
    global $USER, $CFG, $SITE, $DB;
    if (during_initial_install()) {
        return '';
    }
    if (empty($user) and !empty($USER->id)) {
        $user = $USER;
    }
    if (empty($course)) {
        $course = $SITE;
    }
    if (session_is_loggedinas()) {
        $realuser = session_get_realuser();
        $fullname = fullname($realuser, true);
        $realuserinfo = " [<a {$CFG->frametarget}\n        href=\"{$CFG->wwwroot}/course/loginas.php?id={$course->id}&amp;return=1&amp;sesskey=" . sesskey() . "\">{$fullname}</a>] ";
    } else {
        $realuserinfo = '';
    }
    $loginurl = get_login_url();
    if (empty($course->id)) {
        // $course->id is not defined during installation
        return '';
    } else {
        if (!empty($user->id)) {
            $context = get_context_instance(CONTEXT_COURSE, $course->id);
            $fullname = fullname($user, true);
            $username = "<a {$CFG->frametarget} href=\"{$CFG->wwwroot}/user/view.php?id={$user->id}&amp;course={$course->id}\">{$fullname}</a>";
            if (is_mnet_remote_user($user) and $idprovider = $DB->get_record('mnet_host', array('id' => $user->mnethostid))) {
                $username .= " from <a {$CFG->frametarget} href=\"{$idprovider->wwwroot}\">{$idprovider->name}</a>";
            }
            if (isset($user->username) && $user->username == 'guest') {
                $loggedinas = $realuserinfo . get_string('loggedinasguest') . " (<a {$CFG->frametarget} href=\"{$loginurl}\">" . get_string('login') . '</a>)';
            } else {
                if (!empty($user->access['rsw'][$context->path])) {
                    $rolename = '';
                    if ($role = $DB->get_record('role', array('id' => $user->access['rsw'][$context->path]))) {
                        $rolename = ': ' . format_string($role->name);
                    }
                    $loggedinas = get_string('loggedinas', 'moodle', $username) . $rolename . " (<a {$CFG->frametarget}\n                      href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}&amp;switchrole=0&amp;sesskey=" . sesskey() . "\">" . get_string('switchrolereturn') . '</a>)';
                } else {
                    $loggedinas = $realuserinfo . get_string('loggedinas', 'moodle', $username) . ' ' . " (<a {$CFG->frametarget} href=\"{$CFG->wwwroot}/login/logout.php?sesskey=" . sesskey() . "\">" . get_string('logout') . '</a>)';
                }
            }
        } else {
            $loggedinas = get_string('loggedinnot', 'moodle') . " (<a {$CFG->frametarget} href=\"{$loginurl}\">" . get_string('login') . '</a>)';
        }
    }
    $loggedinas = '<div class="logininfo">' . $loggedinas . '</div>';
    if (isset($SESSION->justloggedin)) {
        unset($SESSION->justloggedin);
        if (!empty($CFG->displayloginfailures)) {
            if (!empty($USER->username) and $USER->username != 'guest') {
                if ($count = count_login_failures($CFG->displayloginfailures, $USER->username, $USER->lastlogin)) {
                    $loggedinas .= '&nbsp;<div class="loginfailures">';
                    if (empty($count->accounts)) {
                        $loggedinas .= get_string('failedloginattempts', '', $count);
                    } else {
                        $loggedinas .= get_string('failedloginattemptsall', '', $count);
                    }
                    if (has_capability('coursereport/log:view', get_context_instance(CONTEXT_SYSTEM))) {
                        $loggedinas .= ' (<a href="' . $CFG->wwwroot . '/course/report/log/index.php' . '?chooselog=1&amp;id=1&amp;modid=site_errors">' . get_string('logs') . '</a>)';
                    }
                    $loggedinas .= '</div>';
                }
            }
        }
    }
    return $loggedinas;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:82,代码来源:weblib.php

示例15: authorizeHomeAdmin

 protected function authorizeHomeAdmin()
 {
     return $this->current_user->getRoleManager()->hasPrivilege('GCHomeAdmin') && !session_is_loggedinas();
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:4,代码来源:actions.class.php


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