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


PHP is_mnet_remote_user函数代码示例

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


在下文中一共展示了is_mnet_remote_user函数的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') . '" />&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:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:60,代码来源:block_mnet_hosts.php

示例2: __sendPassword

 public function __sendPassword($email)
 {
     global $CFG, $DB;
     $systemcontext = context_system::instance();
     $response = new CliniqueServiceResponce();
     if (!empty($email) || !$email) {
         $select = $DB->sql_like('email', ':email', false, true, false, '|') . " AND mnethostid = :mnethostid AND deleted=0 AND suspended=0";
         $params = array('email' => $DB->sql_like_escape($email, '|'), 'mnethostid' => $CFG->mnet_localhost_id);
         $user = $DB->get_record_select('user', $select, $params, '*', IGNORE_MULTIPLE);
         if ($user and ($user->auth === 'nologin' or !is_enabled_auth($user->auth))) {
             // bad luck - user is not able to login, do not let them reset password
             $user = false;
             $response->response(true, 'fp_nologin');
             die;
         }
         if (!empty($user)) {
             if (is_mnet_remote_user($user)) {
                 add_to_log(-1, 'custom_webservice', 'mnet_user', null, 'Forgot password - mnet user trying to access.', 0, $user->id);
                 $response->response(true, 'cp_mnet_user');
                 die;
             }
             if (isguestuser($user)) {
                 add_to_log(-1, 'custom_webservice', 'guest_user', null, 'Forgot password - guest user credential supplied.', 0, $user->id);
                 $response->response(true, 'fp_guest');
                 die;
             }
             // make sure user is allowed to change password
             require_capability('moodle/user:changeownpassword', $systemcontext, $user->id);
             if (!ForgotPassword::__app_reset_password_and_mail($user)) {
                 add_to_log(-1, 'custom_webservice', 'trigger_mail', null, 'Forgot password - email triggering failure.', 0, $user->id);
                 $response->response(true, 'fp_email_failure');
             } else {
                 set_user_preference('auth_forcepasswordchange', true, $user->id);
                 $response->response(true, 'fp_email_success');
             }
         } else {
             $response->response(false, 'fp_no_record');
         }
     } else {
         add_to_log(-1, 'custom_webservice', 'input_parameters', null, 'Forgot password - input parameters missing.', 0, $user->id);
     }
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:42,代码来源:clinique_forgot_password.php

示例3: __getPassword

 public function __getPassword($username, $email, $old_password, $new_password)
 {
     global $CFG, $DB;
     $systemcontext = context_system::instance();
     $response = new CliniqueServiceResponce();
     if (!empty($username) && !empty($old_password) && !empty($new_password)) {
         $user = $DB->get_record('user', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id, 'deleted' => 0, 'suspended' => 0));
         if (!empty($user)) {
             if (is_mnet_remote_user($user)) {
                 add_to_log(-1, 'custom_webservice', 'mnet_user', null, 'Change password - mnet user trying to access.', 0, $user->id);
                 $response->response(true, 'cp_mnet_user');
                 die;
             }
             if (isguestuser($user)) {
                 add_to_log(-1, 'custom_webservice', 'mnet_user', null, 'Change password - guest user credential supplied.', 0, $user->id);
                 $response->response(true, 'cp_guest');
                 die;
             }
             // make sure user is allowed to change password
             require_capability('moodle/user:changeownpassword', $systemcontext, $user->id);
             // $generatePasswordResult = generatePassword::app_validate_internal_user_password($user, $old_password);
             if (!ChangePassword::__app_validate_internal_user_password($user, $old_password)) {
                 $response->response(true, 'cp_wrong_oldpwd');
             } else {
                 $userauth = get_auth_plugin($user->auth);
                 if ($userauth->user_update_password($user, $new_password)) {
                     unset_user_preference('auth_forcepasswordchange', $user);
                     unset_user_preference('create_password', $user);
                     $response->response(false, 'cp_success');
                 } else {
                     add_to_log(-1, 'custom_webservice', 'trigger_mail', null, 'Change password - password change updation failure.', 0, $user->id);
                     $response->response(true, 'cp_failure');
                 }
             }
         } else {
             $response->response(false, 'cp_no_mail_record');
         }
     } else {
         add_to_log(-1, 'custom_webservice', 'input_parameters', null, 'Change password - input parameters missing.', 0, $user->id);
     }
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:41,代码来源:clinique_change_password.php

示例4: embeddedreports_generate_link

/**
 * Create a link that allows for displaying embedded Jasper reports
 * on an HTML page
 *
 * @param   $uri        The resource id of the necessary report
 * @param   $parameters Additional parameters to be passed to the report
 * @param   $print      If true, prints iframe on page
 * @return              The HTML of the iframe containing the report
 *
 */
function embeddedreports_generate_link($uri, $parameters = array(), $print = true)
{
    global $USER;
    $parameters['elisembedded'] = 'true';
    if (!is_enabled_auth('mnet')) {
        error('mnet is disabled');
    }
    // check remote login permissions
    if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM)) or is_mnet_remote_user($USER) or $USER->username == 'guest' or empty($USER->id)) {
        print_error('notpermittedtojump', 'mnet');
    }
    $mnet_auth = get_auth_plugin('mnet');
    // check for SSO publish permission first
    if ($mnet_auth->has_service(jasper_mnet_hostid(), 'sso_sp') == false) {
        print_error('hostnotconfiguredforsso', 'mnet');
    }
    $mnet_link = jasper_mnet_link(jasper_report_link($uri, $parameters));
    $result = '<iframe id="reportframe" name="reportframe" src="' . $mnet_link . '"></iframe>';
    if ($print) {
        echo $result;
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:33,代码来源:lib.php

示例5: print_error

}
// The user profile we are editing.
if (!($user = $DB->get_record('user', array('id' => $userid)))) {
    print_error('invaliduserid');
}
// Guest can not be edited.
if (isguestuser($user)) {
    print_error('guestnoeditprofile');
}
// User interests separated by commas.
$user->interests = core_tag_tag::get_item_tags_array('core', 'user', $user->id);
// Remote users cannot be edited. We have to perform the strict
// user_not_fully_set_up() check, otherwise the remote user could end up in
// endless loop between user/view.php and herein. Note that required custom
// fields are not supported in MNet environment anyway.
if (is_mnet_remote_user($user)) {
    if (user_not_fully_set_up($user, true)) {
        $hostwwwroot = $DB->get_field('mnet_host', 'wwwroot', array('id' => $user->mnethostid));
        print_error('usernotfullysetup', 'mnet', '', $hostwwwroot);
    }
    redirect($CFG->wwwroot . "/user/view.php?course={$course->id}");
}
// Load the appropriate auth plugin.
$userauth = get_auth_plugin($user->auth);
if (!$userauth->can_edit_profile()) {
    print_error('noprofileedit', 'auth');
}
if ($editurl = $userauth->edit_profile_url()) {
    // This internal script not used.
    redirect($editurl);
}
开发者ID:ket-ed,项目名称:ketmoodle-core-changes,代码行数:31,代码来源:edit.php

示例6: generate_user_settings


//.........这里部分代码省略.........
                     $pluginfunction($profilenode, $user, $usercontext, $course, $coursecontext);
                 }
             }
         }
         $usersetting = navigation_node::create(get_string('preferences', 'moodle'), $prefurl, self::TYPE_CONTAINER, null, $key);
         $dashboard->add_node($usersetting);
     } else {
         $usersetting = $this->add(get_string('preferences', 'moodle'), $prefurl, self::TYPE_CONTAINER, null, $key);
         $usersetting->display = false;
     }
     $usersetting->id = 'usersettings';
     // Check if the user has been deleted.
     if ($user->deleted) {
         if (!has_capability('moodle/user:update', $coursecontext)) {
             // We can't edit the user so just show the user deleted message.
             $usersetting->add(get_string('userdeleted'), null, self::TYPE_SETTING);
         } else {
             // We can edit the user so show the user deleted message and link it to the profile.
             if ($course->id == $SITE->id) {
                 $profileurl = new moodle_url('/user/profile.php', array('id' => $user->id));
             } else {
                 $profileurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
             }
             $usersetting->add(get_string('userdeleted'), $profileurl, self::TYPE_SETTING);
         }
         return true;
     }
     $userauthplugin = false;
     if (!empty($user->auth)) {
         $userauthplugin = get_auth_plugin($user->auth);
     }
     $useraccount = $usersetting->add(get_string('useraccount'), null, self::TYPE_CONTAINER, null, 'useraccount');
     // Add the profile edit link.
     if (isloggedin() && !isguestuser($user) && !is_mnet_remote_user($user)) {
         if (($currentuser || is_siteadmin($USER) || !is_siteadmin($user)) && has_capability('moodle/user:update', $systemcontext)) {
             $url = new moodle_url('/user/editadvanced.php', array('id' => $user->id, 'course' => $course->id));
             $useraccount->add(get_string('editmyprofile'), $url, self::TYPE_SETTING);
         } else {
             if (has_capability('moodle/user:editprofile', $usercontext) && !is_siteadmin($user) || $currentuser && has_capability('moodle/user:editownprofile', $systemcontext)) {
                 if ($userauthplugin && $userauthplugin->can_edit_profile()) {
                     $url = $userauthplugin->edit_profile_url();
                     if (empty($url)) {
                         $url = new moodle_url('/user/edit.php', array('id' => $user->id, 'course' => $course->id));
                     }
                     $useraccount->add(get_string('editmyprofile'), $url, self::TYPE_SETTING);
                 }
             }
         }
     }
     // Change password link.
     if ($userauthplugin && $currentuser && !\core\session\manager::is_loggedinas() && !isguestuser() && has_capability('moodle/user:changeownpassword', $systemcontext) && $userauthplugin->can_change_password()) {
         $passwordchangeurl = $userauthplugin->change_password_url();
         if (empty($passwordchangeurl)) {
             $passwordchangeurl = new moodle_url('/login/change_password.php', array('id' => $course->id));
         }
         $useraccount->add(get_string("changepassword"), $passwordchangeurl, self::TYPE_SETTING, null, 'changepassword');
     }
     if (isloggedin() && !isguestuser($user) && !is_mnet_remote_user($user)) {
         if ($currentuser && has_capability('moodle/user:editownprofile', $systemcontext) || has_capability('moodle/user:editprofile', $usercontext)) {
             $url = new moodle_url('/user/language.php', array('id' => $user->id, 'course' => $course->id));
             $useraccount->add(get_string('preferredlanguage'), $url, self::TYPE_SETTING, null, 'preferredlanguage');
         }
     }
     $pluginmanager = core_plugin_manager::instance();
     $enabled = $pluginmanager->get_enabled_plugins('mod');
     if (isset($enabled['forum']) && isloggedin() && !isguestuser($user) && !is_mnet_remote_user($user)) {
开发者ID:evltuma,项目名称:moodle,代码行数:67,代码来源:navigationlib.php

示例7: require_capability

} else {
    // Editing existing user.
    require_capability('moodle/user:update', $systemcontext);
    $user = $DB->get_record('user', array('id' => $id), '*', MUST_EXIST);
    $PAGE->set_context(context_user::instance($user->id));
    $PAGE->navbar->includesettingsbase = true;
    if ($user->id != $USER->id) {
        $PAGE->navigation->extend_for_user($user);
    } else {
        if ($node = $PAGE->navigation->find('myprofile', navigation_node::TYPE_ROOTNODE)) {
            $node->force_open();
        }
    }
}
// Remote users cannot be edited.
if ($user->id != -1 and is_mnet_remote_user($user)) {
    redirect($CFG->wwwroot . "/user/view.php?id={$id}&course={$course->id}");
}
if ($user->id != $USER->id and is_siteadmin($user) and !is_siteadmin($USER)) {
    // Only admins may edit other admins.
    print_error('useradmineditadmin');
}
if (isguestuser($user->id)) {
    // The real guest user can not be edited.
    print_error('guestnoeditprofileother');
}
if ($user->deleted) {
    echo $OUTPUT->header();
    echo $OUTPUT->heading(get_string('userdeleted'));
    echo $OUTPUT->footer();
    die;
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:editadvanced.php

示例8: login_info

 /**
  * Return the standard string that says whether you are logged in (and switched
  * roles/logged in as another user).
  *
  * @return string HTML fragment.
  */
 public function login_info()
 {
     global $USER, $CFG, $DB, $SESSION;
     if (during_initial_install()) {
         return '';
     }
     $loginpage = (string) $this->page->url === get_login_url();
     $course = $this->page->course;
     if (session_is_loggedinas()) {
         $realuser = session_get_realuser();
         $fullname = fullname($realuser, true);
         $realuserinfo = " [<a href=\"{$CFG->wwwroot}/course/loginas.php?id={$course->id}&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 (isloggedin()) {
             $context = get_context_instance(CONTEXT_COURSE, $course->id);
             $fullname = fullname($USER, true);
             // Since Moodle 2.0 this link always goes to the public profile page (not the course profile page)
             $username = "<a href=\"{$CFG->wwwroot}/user/profile.php?id={$USER->id}\">{$fullname}</a>";
             if (is_mnet_remote_user($USER) and $idprovider = $DB->get_record('mnet_host', array('id' => $USER->mnethostid))) {
                 $username .= " from <a href=\"{$idprovider->wwwroot}\">{$idprovider->name}</a>";
             }
             if (isguestuser()) {
                 $loggedinas = $realuserinfo . get_string('loggedinasguest');
                 if (!$loginpage) {
                     $loggedinas .= " (<a href=\"{$loginurl}\">" . get_string('login') . '</a>)';
                 }
             } else {
                 if (is_role_switched($course->id)) {
                     // Has switched roles
                     $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 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 href=\"{$CFG->wwwroot}/login/logout.php?sesskey=" . sesskey() . "\">" . get_string('logout') . '</a>)';
                 }
             }
         } else {
             $loggedinas = get_string('loggedinnot', 'moodle');
             if (!$loginpage) {
                 $loggedinas .= " (<a href=\"{$loginurl}\">" . get_string('login') . '</a>)';
             }
         }
     }
     $loggedinas = '<div class="logininfo">' . $loggedinas . '</div>';
     if (isset($SESSION->justloggedin)) {
         unset($SESSION->justloggedin);
         if (!empty($CFG->displayloginfailures)) {
             if (!isguestuser()) {
                 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 (file_exists("{$CFG->dirroot}/report/log/index.php") and has_capability('report/log:view', get_context_instance(CONTEXT_SYSTEM))) {
                         $loggedinas .= ' (<a href="' . $CFG->wwwroot . '/report/log/index.php' . '?chooselog=1&amp;id=1&amp;modid=site_errors">' . get_string('logs') . '</a>)';
                     }
                     $loggedinas .= '</div>';
                 }
             }
         }
     }
     return $loggedinas;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:80,代码来源:outputrenderers.php

示例9: email_to_user

/**
 * Send an email to a specified user
 *
 * @param stdClass $user  A {@link $USER} object
 * @param stdClass $from A {@link $USER} object
 * @param string $subject plain text subject line of the email
 * @param string $messagetext plain text version of the message
 * @param string $messagehtml complete html version of the message (optional)
 * @param string $attachment a file on the filesystem, either relative to $CFG->dataroot or a full path to a file in $CFG->tempdir
 * @param string $attachname the name of the file (extension indicates MIME)
 * @param bool $usetrueaddress determines whether $from email address should
 *          be sent out. Will be overruled by user profile setting for maildisplay
 * @param string $replyto Email address to reply to
 * @param string $replytoname Name of reply to recipient
 * @param int $wordwrapwidth custom word wrap width, default 79
 * @return bool Returns true if mail was sent OK and false if there was an error.
 */
function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '', $attachment = '', $attachname = '', $usetrueaddress = true, $replyto = '', $replytoname = '', $wordwrapwidth = 79)
{
    global $CFG;
    if (empty($user) or empty($user->id)) {
        debugging('Can not send email to null user', DEBUG_DEVELOPER);
        return false;
    }
    if (empty($user->email)) {
        debugging('Can not send email to user without email: ' . $user->id, DEBUG_DEVELOPER);
        return false;
    }
    if (!empty($user->deleted)) {
        debugging('Can not send email to deleted user: ' . $user->id, DEBUG_DEVELOPER);
        return false;
    }
    if (defined('BEHAT_SITE_RUNNING')) {
        // Fake email sending in behat.
        return true;
    }
    if (!empty($CFG->noemailever)) {
        // Hidden setting for development sites, set in config.php if needed.
        debugging('Not sending email due to $CFG->noemailever config setting', DEBUG_NORMAL);
        return true;
    }
    if (!empty($CFG->divertallemailsto)) {
        $subject = "[DIVERTED {$user->email}] {$subject}";
        $user = clone $user;
        $user->email = $CFG->divertallemailsto;
    }
    // Skip mail to suspended users.
    if (isset($user->auth) && $user->auth == 'nologin' or isset($user->suspended) && $user->suspended) {
        return true;
    }
    if (!validate_email($user->email)) {
        // We can not send emails to invalid addresses - it might create security issue or confuse the mailer.
        debugging("email_to_user: User {$user->id} (" . fullname($user) . ") email ({$user->email}) is invalid! Not sending.");
        return false;
    }
    if (over_bounce_threshold($user)) {
        debugging("email_to_user: User {$user->id} (" . fullname($user) . ") is over bounce threshold! Not sending.");
        return false;
    }
    // TLD .invalid  is specifically reserved for invalid domain names.
    // For More information, see {@link http://tools.ietf.org/html/rfc2606#section-2}.
    if (substr($user->email, -8) == '.invalid') {
        debugging("email_to_user: User {$user->id} (" . fullname($user) . ") email domain ({$user->email}) is invalid! Not sending.");
        return true;
        // This is not an error.
    }
    // If the user is a remote mnet user, parse the email text for URL to the
    // wwwroot and modify the url to direct the user's browser to login at their
    // home site (identity provider - idp) before hitting the link itself.
    if (is_mnet_remote_user($user)) {
        require_once $CFG->dirroot . '/mnet/lib.php';
        $jumpurl = mnet_get_idp_jump_url($user);
        $callback = partial('mnet_sso_apply_indirection', $jumpurl);
        $messagetext = preg_replace_callback("%({$CFG->wwwroot}[^[:space:]]*)%", $callback, $messagetext);
        $messagehtml = preg_replace_callback("%href=[\"'`]({$CFG->wwwroot}[\\w_:\\?=#&@/;.~-]*)[\"'`]%", $callback, $messagehtml);
    }
    $mail = get_mailer();
    if (!empty($mail->SMTPDebug)) {
        echo '<pre>' . "\n";
    }
    $temprecipients = array();
    $tempreplyto = array();
    $supportuser = core_user::get_support_user();
    // Make up an email address for handling bounces.
    if (!empty($CFG->handlebounces)) {
        $modargs = 'B' . base64_encode(pack('V', $user->id)) . substr(md5($user->email), 0, 16);
        $mail->Sender = generate_email_processing_address(0, $modargs);
    } else {
        $mail->Sender = $supportuser->email;
    }
    if (!empty($CFG->emailonlyfromnoreplyaddress)) {
        $usetrueaddress = false;
        if (empty($replyto) && $from->maildisplay) {
            $replyto = $from->email;
            $replytoname = fullname($from);
        }
    }
    if (is_string($from)) {
        // So we can pass whatever we want if there is need.
        $mail->From = $CFG->noreplyaddress;
//.........这里部分代码省略.........
开发者ID:riawarra,项目名称:moodle,代码行数:101,代码来源:moodlelib.php

示例10: sesskey

         if (!empty($user->suspended)) {
             $suspendbutton = "<a href=\"editusers.php?unsuspend={$user->id}&amp;sesskey=" . sesskey() . "\">{$strunsuspend}</a>";
         } else {
             $suspendbutton = "<a href=\"editusers.php?suspend={$user->id}&amp;sesskey=" . sesskey() . "\">{$strsuspend}</a>";
         }
     } else {
         $deletebutton = "";
         $suspendbutton = "";
     }
 }
 if ((iomad::has_capability('block/iomad_company_admin:editusers', $systemcontext) or iomad::has_capability('block/iomad_company_admin:editallusers', $systemcontext)) and ($user->id == $USER->id or $user->id != $mainadmin->id) and !is_mnet_remote_user($user)) {
     $editbutton = "<a href=\"{$securewwwroot}/blocks/iomad_company_admin/editadvanced.php?id={$user->id}\">{$stredit}</a>";
 } else {
     $editbutton = "";
 }
 if ((iomad::has_capability('block/iomad_company_admin:company_course_users', $systemcontext) or iomad::has_capability('block/iomad_company_admin:editallusers', $systemcontext)) and ($user->id == $USER->id or $user->id != $mainadmin->id) and !is_mnet_remote_user($user)) {
     $enrolmentbutton = "<a href=\"company_users_course_form.php?userid={$user->id}\">{$strenrolment}</a>";
 } else {
     $enrolmentbutton = "";
 }
 if ($user->lastaccess) {
     $strlastaccess = format_time(time() - $user->lastaccess);
 } else {
     $strlastaccess = get_string('never');
 }
 $fullname = fullname($user, true);
 // Is this a suspended user?
 if (!empty($user->suspended)) {
     $fullname .= " (S)";
 }
 // Get the users department.
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:editusers.php

示例11: definition_after_data

 /**
  * Extend the form definition after data has been parsed.
  */
 public function definition_after_data()
 {
     global $USER, $CFG, $DB, $OUTPUT;
     $mform = $this->_form;
     // Trim required name fields.
     foreach (useredit_get_required_name_fields() as $field) {
         $mform->applyFilter($field, 'trim');
     }
     if ($userid = $mform->getElementValue('id')) {
         $user = $DB->get_record('user', array('id' => $userid));
     } else {
         $user = false;
     }
     // User can not change own auth method.
     if ($userid == $USER->id) {
         $mform->hardFreeze('auth');
         $mform->hardFreeze('preference_auth_forcepasswordchange');
     }
     // Admin must choose some password and supply correct email.
     if (!empty($USER->newadminuser)) {
         $mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
         if ($mform->elementExists('suspended')) {
             $mform->removeElement('suspended');
         }
     }
     // Require password for new users.
     if ($userid > 0) {
         if ($mform->elementExists('createpassword')) {
             $mform->removeElement('createpassword');
         }
     }
     if ($user and is_mnet_remote_user($user)) {
         // Only local accounts can be suspended.
         if ($mform->elementExists('suspended')) {
             $mform->removeElement('suspended');
         }
     }
     if ($user and ($user->id == $USER->id or is_siteadmin($user))) {
         // Prevent self and admin mess ups.
         if ($mform->elementExists('suspended')) {
             $mform->hardFreeze('suspended');
         }
     }
     // Print picture.
     if (empty($USER->newadminuser)) {
         if ($user) {
             $context = context_user::instance($user->id, MUST_EXIST);
             $fs = get_file_storage();
             $hasuploadedpicture = $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.jpg');
             if (!empty($user->picture) && $hasuploadedpicture) {
                 $imagevalue = $OUTPUT->user_picture($user, array('courseid' => SITEID, 'size' => 64));
             } else {
                 $imagevalue = get_string('none');
             }
         } else {
             $imagevalue = get_string('none');
         }
         $imageelement = $mform->getElement('currentpicture');
         $imageelement->setValue($imagevalue);
         if ($user && $mform->elementExists('deletepicture') && !$hasuploadedpicture) {
             $mform->removeElement('deletepicture');
         }
     }
     // Next the customisable profile fields.
     profile_definition_after_data($mform, $userid);
 }
开发者ID:rushi963,项目名称:moodle,代码行数:69,代码来源:editadvanced_form.php

示例12: render_subscribe_info

 /**
  * Show current user forum subscription info
  * Show link to change profile email preferences (if allowed to change profile)
  * @param $context context_module
  * @return string output html
  */
 public function render_subscribe_info($context)
 {
     global $USER;
     $output = '';
     $link = '';
     $course = $context->get_course_context(true)->instanceid;
     $userauthplugin = false;
     if (!empty($USER->auth)) {
         $userauthplugin = get_auth_plugin($USER->auth);
     }
     // Add the profile edit link (partial copy from navigationlib).
     if (isloggedin() && !isguestuser($USER) && !is_mnet_remote_user($USER)) {
         if (has_capability('moodle/user:editownprofile', $context)) {
             if ($userauthplugin && $userauthplugin->can_edit_profile()) {
                 $url = $userauthplugin->edit_profile_url();
                 if (empty($url)) {
                     $url = new moodle_url('/user/edit.php', array('id' => $USER->id, 'course' => $course));
                 }
                 $link = ' (' . html_writer::link($url, get_string('subscribestate_info_link', 'forumng')) . ')';
             }
         }
     }
     $output = get_string('subscribestate_info', 'forumng', $link);
     $info = ' ';
     switch ($USER->maildigest) {
         case 0:
             $info .= get_string('emaildigestoff');
             break;
         case 1:
             $info .= get_string('emaildigestcomplete');
             break;
         case 2:
             $info .= get_string('emaildigestsubjects');
             break;
     }
     $info .= ', ';
     switch ($USER->mailformat) {
         case 0:
             $info .= get_string('textformat');
             break;
         case 1:
             $info .= get_string('htmlformat');
             break;
     }
     $infodiv = html_writer::span($info, 'forumng_subinfo_mail');
     return html_writer::div($output . $infodiv, 'forumng_subinfo');
 }
开发者ID:nadavkav,项目名称:moodle-mod_forumng,代码行数:53,代码来源:renderer.php

示例13: start_jump_session

 /**
  * Starts an RPC jump session and returns the jump redirect URL.
  */
 function start_jump_session($mnethostid, $wantsurl)
 {
     global $CFG;
     global $USER;
     global $MNET;
     require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
     // check remote login permissions
     if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM)) or is_mnet_remote_user($USER) or $USER->username == 'guest' or empty($USER->id)) {
         print_error('notpermittedtojump', 'mnet');
     }
     // check for SSO publish permission first
     if ($this->has_service($mnethostid, 'sso_sp') == false) {
         print_error('hostnotconfiguredforsso', 'mnet');
     }
     // set RPC timeout to 30 seconds if not configured
     // TODO: Is this needed/useful/problematic?
     if (empty($this->config->rpc_negotiation_timeout)) {
         set_config('rpc_negotiation_timeout', '30', 'auth/mnet');
     }
     // get the host info
     $mnet_peer = new mnet_peer();
     $mnet_peer->set_id($mnethostid);
     // set up the session
     $mnet_session = get_record('mnet_session', 'userid', $USER->id, 'mnethostid', $mnethostid, 'useragent', sha1($_SERVER['HTTP_USER_AGENT']));
     if ($mnet_session == false) {
         $mnet_session = new object();
         $mnet_session->mnethostid = $mnethostid;
         $mnet_session->userid = $USER->id;
         $mnet_session->username = $USER->username;
         $mnet_session->useragent = sha1($_SERVER['HTTP_USER_AGENT']);
         $mnet_session->token = $this->generate_token();
         $mnet_session->confirm_timeout = time() + $this->config->rpc_negotiation_timeout;
         $mnet_session->expires = time() + (int) ini_get('session.gc_maxlifetime');
         $mnet_session->session_id = session_id();
         if (!($mnet_session->id = insert_record('mnet_session', addslashes_recursive($mnet_session)))) {
             print_error('databaseerror', 'mnet');
         }
     } else {
         $mnet_session->useragent = sha1($_SERVER['HTTP_USER_AGENT']);
         $mnet_session->token = $this->generate_token();
         $mnet_session->confirm_timeout = time() + $this->config->rpc_negotiation_timeout;
         $mnet_session->expires = time() + (int) ini_get('session.gc_maxlifetime');
         $mnet_session->session_id = session_id();
         if (false == update_record('mnet_session', addslashes_recursive($mnet_session))) {
             print_error('databaseerror', 'mnet');
         }
     }
     // construct the redirection URL
     //$transport = mnet_get_protocol($mnet_peer->transport);
     $wantsurl = urlencode($wantsurl);
     $url = "{$mnet_peer->wwwroot}{$mnet_peer->application->sso_land_url}?token={$mnet_session->token}&idp={$MNET->wwwroot}&wantsurl={$wantsurl}";
     return $url;
 }
开发者ID:kai707,项目名称:ITSA-backup,代码行数:56,代码来源:auth.php

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

示例15: login_info

    public function login_info($withlinks = null) {
        global $USER, $CFG, $DB, $SESSION,$OUTPUT;

        if (during_initial_install()) {
            return '';
        }

        if (is_null($withlinks)) {
            $withlinks = empty($this->page->layout_options['nologinlinks']);
        }

        $loginpage = ((string)$this->page->url === get_login_url());
        $course = $this->page->course;
        if (\core\session\manager::is_loggedinas()) {
            $realuser = session_get_realuser();
            $fullname = fullname($realuser, true);
            if ($withlinks) {
                $loginastitle = get_string('loginas');
                $realuserinfo = " <a href=\"$CFG->wwwroot/course/loginas.php?id=$course->id&amp;sesskey=".sesskey()."\"";
                $realuserinfo .= "title =\"".$loginastitle."\">$fullname</a>";
            } else {
                $realuserinfo = "$fullname";
            }
        } else {
            $realuserinfo = '';
        }

        $loginurl = get_login_url();

        if (empty($course->id)) {
            // $course->id is not defined during installation
            return '';
        } else if (isloggedin()) {
            $context = context_course::instance($course->id);

            $fullname = fullname($USER, true);
            // Since Moodle 2.0 this link always goes to the public profile page (not the course profile page)
            if ($withlinks) {
                $linktitle = get_string('viewprofile');
                $username = "<a href=\"$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id\" title=\"$linktitle\">$fullname</a>";
            } else {
                $username = $fullname;
            }
            if (is_mnet_remote_user($USER) and $idprovider = $DB->get_record('mnet_host', array('id'=>$USER->mnethostid))) {
                if ($withlinks) {
                    $username .= " from <a href=\"{$idprovider->wwwroot}\">{$idprovider->name}</a>";
                } else {
                    $username .= " from {$idprovider->name}";
                }
            }
            if (isguestuser()) {
                $loggedinas = get_string('loggedinasguest','theme_colms');
                $loggout = "<a href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\" id='logout'>".get_string('logout').'</a>';
                if (!$loginpage && $withlinks) {
                    $loggedinas .= " (<a href=\"$loginurl\" style=\"vertical-align:middle;margin:0;\">".get_string('login').'</a>)';
                }
            } else if (is_role_switched($course->id)) { // Has switched roles
                $rolename = '';
                if ($role = $DB->get_record('role', array('id'=>$USER->access['rsw'][$context->path]))) {
                    // $rolename = ': '.role_get_name($role, $context);
					$rolename = '';
                }
                $loggedinas = get_string('loggedinas', 'theme_colms', $username).$rolename;
                if ($withlinks) {
                    $url = new moodle_url('/course/switchrole.php', array('id'=>$course->id,'sesskey'=>sesskey(), 'switchrole'=>0, 'returnurl'=>$this->page->url->out_as_local_url(false)));
                    // $loggedinas .= '('.html_writer::tag('a', get_string('switchrolereturn'), array('href'=>$url)).')';
                }
            } else {
                $loggedinas = $realuserinfo.get_string('loggedinas', 'theme_colms', $username);
                if ($withlinks) {
                    $loggout = "<a href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\" id='logout'>".get_string('logout').'</a>';
                }
            }
        } else {
            $loggedinas = get_string('loggedinnot', 'theme_colms');
            if (!$loginpage && $withlinks) {
                $loggedinas = "<a href='javascript:void(0)' id='login_button'>".get_string('login').'</a>';
            }
        }
        // if(isloggedin() || isguestuser()){
        // $loggedinas = '<div class="logininfo"><div id="logoutlink">'. $loggedinas .'<a href="javascript:void(0)" id="pop_logout"><img src=' . $OUTPUT->pix_url("down_arrow","theme") .'  /></a></div>', array("class"=>"userimg")) . ''.$loggout.'</div>';
        // }
		if(isloggedin() || isguestuser()){
		$loggout = "<a href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\" class='box_log'>".get_string('logout').'</a>';
        $loggedinas = '<div class="logininfo"><div class="logoutlink">'. $loggedinas .'</div><div class="box_log">'.$loggout.'</div></div>';
        }
        if (isset($SESSION->justloggedin)) {
            unset($SESSION->justloggedin);
            if (!empty($CFG->displayloginfailures)) {
                if (!isguestuser()) {
                    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 (file_exists("$CFG->dirroot/report/log/index.php") and has_capability('report/log:view', context_system::instance())) {
                            $loggedinas .= ' (<a href="'.$CFG->wwwroot.'/report/log/index.php'.
                                                 '?chooselog=1&amp;id=1&amp;modid=site_errors">'.get_string('logs').'</a>)';
//.........这里部分代码省略.........
开发者ID:anilch,项目名称:Personel,代码行数:101,代码来源:renderers.php


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