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


PHP has_coursecontact_role函数代码示例

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


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

示例1: definition

 public function definition()
 {
     global $USER, $OUTPUT, $CFG;
     $mform = $this->_form;
     $instance = $this->_customdata;
     $this->instance = $instance;
     $plugin = enrol_get_plugin('boleto');
     $heading = $plugin->get_instance_name($instance);
     $mform->addElement('header', 'boletoheader', $heading);
     if ($instance->password) {
         // Change the id of boleto enrolment key input as there can be multiple boleto enrolment methods.
         $mform->addElement('passwordunmask', 'enrolpassword', get_string('password', 'enrol_boleto'), array('id' => 'enrolpassword_' . $instance->id));
         $context = context_course::instance($this->instance->courseid);
         $keyholders = get_users_by_capability($context, 'enrol/boleto:holdkey', user_picture::fields('u'));
         $keyholdercount = 0;
         foreach ($keyholders as $keyholder) {
             $keyholdercount++;
             if ($keyholdercount === 1) {
                 $mform->addElement('static', 'keyholder', '', get_string('keyholder', 'enrol_boleto'));
             }
             $keyholdercontext = context_user::instance($keyholder->id);
             if ($USER->id == $keyholder->id || has_capability('moodle/user:viewdetails', context_system::instance()) || has_coursecontact_role($keyholder->id)) {
                 $profilelink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $keyholder->id . '&amp;course=' . $this->instance->courseid . '">' . fullname($keyholder) . '</a>';
             } else {
                 $profilelink = fullname($keyholder);
             }
             $profilepic = $OUTPUT->user_picture($keyholder, array('size' => 35, 'courseid' => $this->instance->courseid));
             $mform->addElement('static', 'keyholder' . $keyholdercount, '', $profilepic . $profilelink);
         }
     }
     $boletourl = new moodle_url('/enrol/boleto/boleto.php', array('instanceid' => $this->instance->id));
     $mform->addElement('static', 'info', '', get_string('boletoprintandpayinfo', 'enrol_boleto'));
     // customint8 == avista.
     if ($this->instance->customint8) {
         $mform->addElement('static', 'info', '', get_string('boletoprintandpayinfodirectlinks', 'enrol_boleto', $boletourl->out(false)));
     } else {
         $mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink0', 'enrol_boleto', $boletourl->out(false)));
         $boletourl->param('parcela', 1);
         $mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink1', 'enrol_boleto', $boletourl->out(false)));
         $boletourl->param('parcela', 2);
         $mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink2', 'enrol_boleto', $boletourl->out(false)));
     }
     $this->add_action_buttons(false, get_string('enrolme', 'enrol_boleto'));
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->setDefault('id', $instance->courseid);
     $mform->addElement('hidden', 'instance');
     $mform->setType('instance', PARAM_INT);
     $mform->setDefault('instance', $instance->id);
 }
开发者ID:josenorberto,项目名称:moodle-enrol_boleto,代码行数:50,代码来源:locallib.php

示例2: print_row

            if ($shown >= 20) {
                $courselisting .= "...";
                break;
            }
        }
        print_row(get_string('courseprofiles') . ':', rtrim($courselisting, ', '));
    }
}
echo "</table></div></div>";
// Print messaging link if allowed
if (isloggedin() && has_capability('moodle/site:sendmessage', $usercontext) && !empty($CFG->messaging) && !isguestuser() && !isguestuser($user) && $USER->id != $user->id) {
    echo '<div class="messagebox">';
    echo '<a href="' . $CFG->wwwroot . '/message/index.php?id=' . $user->id . '">' . get_string('messageselectadd') . '</a>';
    echo '</div>';
}
if ($currentuser || has_capability('moodle/user:viewdetails', $usercontext) || has_coursecontact_role($id)) {
    echo '<div class="fullprofilelink">';
    echo html_writer::link($CFG->wwwroot . '/user/profile.php?id=' . $id, get_string('fullprofile'));
    echo '</div>';
}
/// TODO Add more useful overview info for teachers here, see below
/// Show links to notes made about this student (must click to display, for privacy)
/// Recent comments made in this course
/// Recent blogs associated with this course and items in it
echo '</div>';
// userprofile class
echo $OUTPUT->footer();
/// Functions ///////
function print_row($left, $right)
{
    echo "\n<tr><td class=\"label c0\">{$left}</td><td class=\"info c1\">{$right}</td></tr>\n";
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:view.php

示例3: tag_print_user_box

/**
 * Prints an individual user box
 *
 * @param user_object  $user  (contains the following fields: id, firstname, lastname and picture)
 * @param bool         $return if true return html string
 * @return string|null a HTML string or null if this function does the output
 */
function tag_print_user_box($user, $return = false)
{
    global $CFG, $OUTPUT;
    $usercontext = get_context_instance(CONTEXT_USER, $user->id);
    $profilelink = '';
    if ($usercontext and has_capability('moodle/user:viewdetails', $usercontext) || has_coursecontact_role($user->id)) {
        $profilelink = $CFG->wwwroot . '/user/view.php?id=' . $user->id;
    }
    $output = $OUTPUT->box_start('user-box', 'user' . $user->id);
    $fullname = fullname($user);
    $alt = '';
    if (!empty($profilelink)) {
        $output .= '<a href="' . $profilelink . '">';
        $alt = $fullname;
    }
    $output .= $OUTPUT->user_picture($user, array('size' => 100));
    $output .= '<br />';
    if (!empty($profilelink)) {
        $output .= '</a>';
    }
    //truncate name if it's too big
    if (textlib::strlen($fullname) > 26) {
        $fullname = textlib::substr($fullname, 0, 26) . '...';
    }
    $output .= '<strong>' . $fullname . '</strong>';
    $output .= $OUTPUT->box_end();
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:39,代码来源:locallib.php

示例4: file_pluginfile


//.........这里部分代码省略.........
                            } else {
                                if ($filearea === 'private' and $context->contextlevel == CONTEXT_USER) {
                                    require_login();
                                    if (isguestuser()) {
                                        send_file_not_found();
                                    }
                                    if ($USER->id !== $context->instanceid) {
                                        send_file_not_found();
                                    }
                                    $filename = array_pop($args);
                                    $filepath = $args ? '/' . implode('/', $args) . '/' : '/';
                                    if (!($file = $fs->get_file($context->id, $component, $filearea, 0, $filepath, $filename)) or $file->is_directory()) {
                                        send_file_not_found();
                                    }
                                    \core\session\manager::write_close();
                                    // Unlock session during file serving.
                                    send_stored_file($file, 0, 0, true, array('preview' => $preview));
                                    // must force download - security!
                                } else {
                                    if ($filearea === 'profile' and $context->contextlevel == CONTEXT_USER) {
                                        if ($CFG->forcelogin) {
                                            require_login();
                                        }
                                        $userid = $context->instanceid;
                                        if ($USER->id == $userid) {
                                            // always can access own
                                        } else {
                                            if (!empty($CFG->forceloginforprofiles)) {
                                                require_login();
                                                if (isguestuser()) {
                                                    send_file_not_found();
                                                }
                                                // we allow access to site profile of all course contacts (usually teachers)
                                                if (!has_coursecontact_role($userid) && !has_capability('moodle/user:viewdetails', $context)) {
                                                    send_file_not_found();
                                                }
                                                $canview = false;
                                                if (has_capability('moodle/user:viewdetails', $context)) {
                                                    $canview = true;
                                                } else {
                                                    $courses = enrol_get_my_courses();
                                                }
                                                while (!$canview && count($courses) > 0) {
                                                    $course = array_shift($courses);
                                                    if (has_capability('moodle/user:viewdetails', context_course::instance($course->id))) {
                                                        $canview = true;
                                                    }
                                                }
                                            }
                                        }
                                        $filename = array_pop($args);
                                        $filepath = $args ? '/' . implode('/', $args) . '/' : '/';
                                        if (!($file = $fs->get_file($context->id, $component, $filearea, 0, $filepath, $filename)) or $file->is_directory()) {
                                            send_file_not_found();
                                        }
                                        \core\session\manager::write_close();
                                        // Unlock session during file serving.
                                        send_stored_file($file, 0, 0, true, array('preview' => $preview));
                                        // must force download - security!
                                    } else {
                                        if ($filearea === 'profile' and $context->contextlevel == CONTEXT_COURSE) {
                                            $userid = (int) array_shift($args);
                                            $usercontext = context_user::instance($userid);
                                            if ($CFG->forcelogin) {
                                                require_login();
                                            }
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:67,代码来源:filelib.php

示例5: send_stored_file

     send_stored_file($file, 0, 0, true);
     // must force download - security!
 } else {
     if ($filearea === 'profile' and $context->contextlevel == CONTEXT_COURSE) {
         $userid = (int) array_shift($args);
         $usercontext = get_context_instance(CONTEXT_USER, $userid);
         if ($CFG->forcelogin) {
             require_login();
         }
         if (!empty($CFG->forceloginforprofiles)) {
             require_login();
             if (isguestuser()) {
                 print_error('noguest');
             }
             //TODO: review this logic of user profile access prevention
             if (!has_coursecontact_role($userid) and !has_capability('moodle/user:viewdetails', $usercontext)) {
                 print_error('usernotavailable');
             }
             if (!has_capability('moodle/user:viewdetails', $context) && !has_capability('moodle/user:viewdetails', $usercontext)) {
                 print_error('cannotviewprofile');
             }
             if (!is_enrolled($context, $userid)) {
                 print_error('notenrolledprofile');
             }
             if (groups_get_course_groupmode($course) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
                 print_error('groupnotamember');
             }
         }
         $filename = array_pop($args);
         $filepath = $args ? '/' . implode('/', $args) . '/' : '/';
         if (!($file = $fs->get_file($usercontext->id, 'user', 'profile', 0, $filepath, $filename)) or $file->is_directory()) {
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:pluginfile.php

示例6: create_session_and_responses

 function create_session_and_responses(&$question, &$state, $cmoptions, $attempt)
 {
     // Choose a random shortanswer question from the category:
     // We need to make sure that no question is used more than once in the
     // quiz. Therfore the following need to be excluded:
     // 1. All questions that are explicitly assigned to the quiz
     // 2. All random questions
     // 3. All questions that are already chosen by an other random question
     global $QTYPES, $OUTPUT, $USER;
     if (!isset($cmoptions->questionsinuse)) {
         $cmoptions->questionsinuse = $cmoptions->questions;
     }
     if ($question->options->subcats) {
         // recurse into subcategories
         $categorylist = question_categorylist($question->category);
     } else {
         $categorylist = $question->category;
     }
     $saquestions = $this->get_sa_candidates($categorylist, $cmoptions->questionsinuse);
     $count = count($saquestions);
     $wanted = $question->options->choose;
     $errorstr = '';
     if ($count < $wanted && has_coursecontact_role($USER->id)) {
         //TODO: this teacher test is far from optimal
         if ($count >= 2) {
             $errorstr = "Error: could not get enough Short-Answer questions!\n                 Got {$count} Short-Answer questions, but wanted {$wanted}.\n                 Reducing number to choose from to {$count}!";
             $wanted = $question->options->choose = $count;
         } else {
             $errorstr = "Error: could not get enough Short-Answer questions!\n                 This can happen if all available Short-Answer questions are already\n                 taken up by other Random questions or Random Short-Answer question.\n                 Another possible cause for this error is that Short-Answer\n                 questions were deleted after this Random Short-Answer question was\n                 created.";
         }
         echo $OUTPUT->notification($errorstr);
         $errorstr = '<span class="notifyproblem">' . $errorstr . '</span>';
     }
     if ($count < $wanted) {
         $question->questiontext = "{$errorstr}<br /><br />Insufficient selection options are\n             available for this question, therefore it is not available in  this\n             quiz. Please inform your teacher.";
         // Treat this as a description from this point on
         $question->qtype = DESCRIPTION;
         return true;
     }
     $saquestions = draw_rand_array($saquestions, $question->options->choose);
     // from bug 1889
     foreach ($saquestions as $key => $wrappedquestion) {
         if (!$QTYPES[$wrappedquestion->qtype]->get_question_options($wrappedquestion)) {
             return false;
         }
         // Now we overwrite the $question->options->answers field to only
         // *one* (the first) correct answer. This loop can be deleted to
         // take all answers into account (i.e. put them all into the
         // drop-down menu.
         $foundcorrect = false;
         foreach ($wrappedquestion->options->answers as $answer) {
             if ($foundcorrect || $answer->fraction != 1.0) {
                 unset($wrappedquestion->options->answers[$answer->id]);
             } else {
                 if (!$foundcorrect) {
                     $foundcorrect = true;
                 }
             }
         }
         if (!$QTYPES[$wrappedquestion->qtype]->create_session_and_responses($wrappedquestion, $state, $cmoptions, $attempt)) {
             return false;
         }
         $wrappedquestion->name_prefix = $question->name_prefix;
         $wrappedquestion->maxgrade = $question->maxgrade;
         $cmoptions->questionsinuse .= ",{$wrappedquestion->id}";
         $state->options->subquestions[$key] = clone $wrappedquestion;
     }
     // Shuffle the answers (Do this always because this is a random question type)
     $subquestionids = array_values(array_map(create_function('$val', 'return $val->id;'), $state->options->subquestions));
     $subquestionids = swapshuffle($subquestionids);
     // Create empty responses
     foreach ($subquestionids as $val) {
         $state->responses[$val] = '';
     }
     return true;
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:76,代码来源:questiontype.php

示例7: array

    if (!$user) {
        echo $OUTPUT->notification(get_string('invaliduser', 'error'));
    } else {
        echo $OUTPUT->notification(get_string('userdeleted'));
    }
    echo $OUTPUT->footer();
    die;
}

$currentuser = ($user->id == $USER->id);
$context = $usercontext = context_user::instance($userid, MUST_EXIST);

if (!$currentuser &&
    !empty($CFG->forceloginforprofiles) &&
    !has_capability('moodle/user:viewdetails', $context) &&
    !has_coursecontact_role($userid)) {

    // Course managers can be browsed at site level. If not forceloginforprofiles, allow access (bug #4366).
    $struser = get_string('user');
    $PAGE->set_context(context_system::instance());
    $PAGE->set_title("$SITE->shortname: $struser");  // Do not leak the name.
    $PAGE->set_heading($struser);
    $PAGE->set_url('/user/profile.php', array('id' => $userid));
    $PAGE->navbar->add($struser);
    echo $OUTPUT->header();
    echo $OUTPUT->notification(get_string('usernotavailable', 'error'));
    echo $OUTPUT->footer();
    exit;
}

// Get the profile page.  Should always return something unless the database is broken.
开发者ID:kmahesh541,项目名称:mitclone,代码行数:31,代码来源:profile.php

示例8: require_login

        require_login();
    }
}
$userid = $userid ? $userid : $USER->id;
// Owner of the page
$user = $DB->get_record('user', array('id' => $userid));
if ($user->deleted) {
    $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
    echo $OUTPUT->header();
    echo $OUTPUT->notification(get_string('userdeleted'));
    echo $OUTPUT->footer();
    die;
}
$currentuser = $user->id == $USER->id;
$context = $usercontext = get_context_instance(CONTEXT_USER, $userid, MUST_EXIST);
if (!$currentuser && !empty($CFG->forceloginforprofiles) && !has_capability('moodle/user:viewdetails', $context) && !has_coursecontact_role($userid)) {
    // Course managers can be browsed at site level. If not forceloginforprofiles, allow access (bug #4366)
    $struser = get_string('user');
    $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
    $PAGE->set_title("{$SITE->shortname}: {$struser}");
    // Do not leak the name
    $PAGE->set_heading("{$SITE->shortname}: {$struser}");
    $PAGE->set_url('/user/profile.php', array('id' => $userid));
    $PAGE->navbar->add($struser);
    echo $OUTPUT->header();
    echo $OUTPUT->notification(get_string('usernotavailable', 'error'));
    echo $OUTPUT->footer();
    exit;
}
// Get the profile page.  Should always return something unless the database is broken.
if (!($currentpage = my_get_page($userid, MY_PAGE_PUBLIC))) {
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:profile.php

示例9: forum_get_courses_user_posted_in

    $courses = forum_get_courses_user_posted_in($user, $discussionsonly);
}
// Get the posts by the requested user that the current user can access.
$result = forum_get_posts_by_user($user, $courses, $isspecificcourse, $discussionsonly, $page * $perpage, $perpage);
// Check whether there are not posts to display.
if (empty($result->posts)) {
    // Ok no posts to display means that either the user has not posted or there
    // are no posts made by the requested user that the current user is able to
    // see.
    // In either case we need to decide whether we can show personal information
    // about the requested user to the current user so we will execute some checks
    // First check the obvious, its the current user, a specific course has been
    // provided (require_login has been called), or they have a course contact role.
    // True to any of those and the current user can see the details of the
    // requested user.
    $canviewuser = $iscurrentuser || $isspecificcourse || empty($CFG->forceloginforprofiles) || has_coursecontact_role($userid);
    // Next we'll check the caps, if the current user has the view details and a
    // specific course has been requested, or if they have the view all details
    $canviewuser = $canviewuser || ($isspecificcourse && has_capability('moodle/user:viewdetails', $coursecontext) || has_capability('moodle/user:viewalldetails', $usercontext));
    // If none of the above was true the next step is to check a shared relation
    // through some course
    if (!$canviewuser) {
        // Get all of the courses that the users have in common
        $sharedcourses = enrol_get_shared_courses($USER->id, $user->id, true);
        foreach ($sharedcourses as $sharedcourse) {
            // Check the view cap within the course context
            if (has_capability('moodle/user:viewdetails', get_context_instance(CONTEXT_COURSE, $sharedcourse->id))) {
                $canviewuser = true;
                break;
            }
        }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:31,代码来源:user.php

示例10: core_myprofile_navigation

/**
 * Defines core nodes for my profile navigation tree.
 *
 * @param \core_user\output\myprofile\tree $tree Tree object
 * @param stdClass $user user object
 * @param bool $iscurrentuser is the user viewing profile, current user ?
 * @param stdClass $course course object
 *
 * @return bool
 */
function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course)
{
    global $CFG, $USER, $DB;
    $usercontext = context_user::instance($user->id, MUST_EXIST);
    $systemcontext = context_system::instance();
    $context = !empty($course) ? context_course::instance($course->id) : $systemcontext;
    $courseid = !empty($course) ? $course->id : SITEID;
    $contactcategory = new core_user\output\myprofile\category('contact', get_string('userdetails'));
    $coursedetailscategory = new core_user\output\myprofile\category('coursedetails', get_string('coursedetails'), 'contact');
    $miscategory = new core_user\output\myprofile\category('miscellaneous', get_string('miscellaneous'), 'coursedetails');
    $reportcategory = new core_user\output\myprofile\category('reports', get_string('reports'), 'miscellaneous');
    $admincategory = new core_user\output\myprofile\category('administration', get_string('administration'), 'reports');
    $loginactivitycategory = new core_user\output\myprofile\category('loginactivity', get_string('loginactivity'), 'administration');
    // Add categories.
    $tree->add_category($contactcategory);
    $tree->add_category($coursedetailscategory);
    $tree->add_category($miscategory);
    $tree->add_category($reportcategory);
    $tree->add_category($admincategory);
    $tree->add_category($loginactivitycategory);
    // Add core nodes.
    // Full profile node.
    if (!empty($course)) {
        if (empty($CFG->forceloginforprofiles) || $iscurrentuser || has_capability('moodle/user:viewdetails', context_user::instance($user->id)) || has_coursecontact_role($user->id)) {
            $url = new moodle_url('/user/profile.php', array('id' => $user->id));
            $node = new core_user\output\myprofile\node('miscellaneous', 'fullprofile', get_string('fullprofile'), null, $url);
            $tree->add_node($node);
        }
    }
    // Edit profile.
    if (isloggedin() && !isguestuser($user) && !is_mnet_remote_user($user)) {
        if (($iscurrentuser || is_siteadmin($USER) || !is_siteadmin($user)) && has_capability('moodle/user:update', $systemcontext)) {
            $url = new moodle_url('/user/editadvanced.php', array('id' => $user->id, 'course' => $courseid));
            $node = new core_user\output\myprofile\node('contact', 'editprofile', get_string('editmyprofile'), null, $url);
            $tree->add_node($node);
        } else {
            if (has_capability('moodle/user:editprofile', $usercontext) && !is_siteadmin($user) || $iscurrentuser && has_capability('moodle/user:editownprofile', $systemcontext)) {
                $userauthplugin = false;
                if (!empty($user->auth)) {
                    $userauthplugin = get_auth_plugin($user->auth);
                }
                if ($userauthplugin && $userauthplugin->can_edit_profile()) {
                    $url = $userauthplugin->edit_profile_url();
                    if (empty($url)) {
                        if (empty($course)) {
                            $url = new moodle_url('/user/edit.php', array('userid' => $user->id));
                        } else {
                            $url = new moodle_url('/user/edit.php', array('userid' => $user->id, 'course' => $course->id));
                        }
                    }
                    $node = new core_user\output\myprofile\node('contact', 'editprofile', get_string('editmyprofile'), null, $url);
                    $tree->add_node($node);
                }
            }
        }
    }
    // Preference page. Only visible by administrators.
    if (is_siteadmin()) {
        $url = new moodle_url('/user/preferences.php', array('userid' => $user->id));
        $title = $iscurrentuser ? get_string('mypreferences') : get_string('userspreferences', 'moodle', fullname($user));
        $node = new core_user\output\myprofile\node('administration', 'preferences', $title, null, $url);
        $tree->add_node($node);
    }
    // Login as ...
    if (!$user->deleted && !$iscurrentuser && !\core\session\manager::is_loggedinas() && has_capability('moodle/user:loginas', $context) && !is_siteadmin($user->id)) {
        $url = new moodle_url('/course/loginas.php', array('id' => $courseid, 'user' => $user->id, 'sesskey' => sesskey()));
        $node = new core_user\output\myprofile\node('administration', 'loginas', get_string('loginas'), null, $url);
        $tree->add_node($node);
    }
    // Contact details.
    if (has_capability('moodle/user:viewhiddendetails', $usercontext)) {
        $hiddenfields = array();
    } else {
        $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
    }
    if (has_capability('moodle/site:viewuseridentity', $context)) {
        $identityfields = array_flip(explode(',', $CFG->showuseridentity));
    } else {
        $identityfields = array();
    }
    if (is_mnet_remote_user($user)) {
        $sql = "SELECT h.id, h.name, h.wwwroot,\n                       a.name as application, a.display_name\n                  FROM {mnet_host} h, {mnet_application} a\n                 WHERE h.id = ? AND h.applicationid = a.id";
        $remotehost = $DB->get_record_sql($sql, array($user->mnethostid));
        $remoteuser = new stdclass();
        $remoteuser->remotetype = $remotehost->display_name;
        $hostinfo = new stdclass();
        $hostinfo->remotename = $remotehost->name;
        $hostinfo->remoteurl = $remotehost->wwwroot;
        $node = new core_user\output\myprofile\node('contact', 'mnet', get_string('remoteuser', 'mnet', $remoteuser), null, null, get_string('remoteuserinfo', 'mnet', $hostinfo), null, 'remoteuserinfo');
        $tree->add_node($node);
//.........这里部分代码省略.........
开发者ID:mike-grant,项目名称:moodle,代码行数:101,代码来源:myprofilelib.php

示例11: get_string

    } else {
        $ipstring = get_string("none");
    }
    echo html_writer::tag('dt', get_string('lastip'));
    echo html_writer::tag('dd', $ipstring);
}
echo html_writer::end_tag('dl');
echo "</div></div>";
// Closing desriptionbox and userprofilebox.
// Print messaging link if allowed.
if (isloggedin() && has_capability('moodle/site:sendmessage', $usercontext) && !empty($CFG->messaging) && !isguestuser() && !isguestuser($user) && $USER->id != $user->id) {
    echo '<div class="messagebox">';
    $sendmessageurl = new moodle_url('/message/index.php', array('id' => $user->id));
    if ($courseid) {
        $sendmessageurl->param('viewing', MESSAGE_VIEW_COURSE . $courseid);
    }
    echo html_writer::link($sendmessageurl, get_string('messageselectadd'));
    echo '</div>';
}
if (empty($CFG->forceloginforprofiles) || $currentuser || has_capability('moodle/user:viewdetails', $usercontext) || has_coursecontact_role($id)) {
    echo '<div class="fullprofilelink">';
    echo html_writer::link($CFG->wwwroot . '/user/profile.php?id=' . $id, get_string('fullprofile'));
    echo '</div>';
}
// TODO Add more useful overview info for teachers here, see below.
// Show links to notes made about this student (must click to display, for privacy).
// Recent comments made in this course.
// Recent blogs associated with this course and items in it.
echo '</div>';
// Userprofile class.
echo $OUTPUT->footer();
开发者ID:nikitskynikita,项目名称:moodle,代码行数:31,代码来源:view.php

示例12: moodle_url

echo html_writer::end_tag('dl');
echo "</div></div>"; // Closing desriptionbox and userprofilebox.
// Print messaging link if allowed.
if (isloggedin() && has_capability('moodle/site:sendmessage', $usercontext)
    && !empty($CFG->messaging) && !isguestuser() && !isguestuser($user) && ($USER->id != $user->id)) {
    echo '<div class="messagebox">';
    $sendmessageurl = new moodle_url('/message/index.php', array('id' => $user->id));
    if ($courseid) {
        $sendmessageurl->param('viewing', MESSAGE_VIEW_COURSE. $courseid);
    }
    echo html_writer::link($sendmessageurl, get_string('messageselectadd'));
    echo '</div>';
}

if (empty($CFG->forceloginforprofiles) || $currentuser || has_capability('moodle/user:viewdetails', $usercontext)
        || has_coursecontact_role($id)) {
    echo '<div class="fullprofilelink">';
    echo html_writer::link($CFG->wwwroot.'/user/profile.php?id='.$id, get_string('fullprofile'));
    echo '</div>';
}

// TODO Add more useful overview info for teachers here, see below.
// Show links to notes made about this student (must click to display, for privacy).
// Recent comments made in this course.
// Recent blogs associated with this course and items in it.



echo '</div>';  // Userprofile class.

echo $OUTPUT->footer();
开发者ID:educacionbe,项目名称:cursos,代码行数:31,代码来源:view.php

示例13: user_can_view_profile

/**
 * Check if a user has the permission to viewdetails in a shared course's context.
 *
 * @param object $user The other user's details.
 * @param object $course Use this course to see if we have permission to see this user's profile.
 * @param context $usercontext The user context if available.
 * @return bool true for ability to view this user, else false.
 */
function user_can_view_profile($user, $course = null, $usercontext = null)
{
    global $USER, $CFG;
    if ($user->deleted) {
        return false;
    }
    // If any of these four things, return true.
    // Number 1.
    if ($USER->id == $user->id) {
        return true;
    }
    // Number 2.
    if (empty($CFG->forceloginforprofiles)) {
        return true;
    }
    if (empty($usercontext)) {
        $usercontext = context_user::instance($user->id);
    }
    // Number 3.
    if (has_capability('moodle/user:viewdetails', $usercontext)) {
        return true;
    }
    // Number 4.
    if (has_coursecontact_role($user->id)) {
        return true;
    }
    if (isset($course)) {
        $sharedcourses = array($course);
    } else {
        $sharedcourses = enrol_get_shared_courses($USER->id, $user->id, true);
    }
    foreach ($sharedcourses as $sharedcourse) {
        $coursecontext = context_course::instance($sharedcourse->id);
        if (has_capability('moodle/user:viewdetails', $coursecontext)) {
            if (!groups_user_groups_visible($sharedcourse, $user->id)) {
                // Not a member of the same group.
                continue;
            }
            return true;
        }
    }
    return false;
}
开发者ID:rushi963,项目名称:moodle,代码行数:51,代码来源:lib.php

示例14: generate_user_settings

 /**
  * This function gets called by {@link settings_navigation::load_user_settings()} and actually works out
  * what can be shown/done
  *
  * @param int $courseid The current course' id
  * @param int $userid The user id to load for
  * @param string $gstitle The string to pass to get_string for the branch title
  * @return navigation_node|false
  */
 protected function generate_user_settings($courseid, $userid, $gstitle = 'usercurrentsettings')
 {
     global $DB, $CFG, $USER, $SITE;
     if ($courseid != $SITE->id) {
         if (!empty($this->page->course->id) && $this->page->course->id == $courseid) {
             $course = $this->page->course;
         } else {
             $select = context_helper::get_preload_record_columns_sql('ctx');
             $sql = "SELECT c.*, {$select}\n                          FROM {course} c\n                          JOIN {context} ctx ON c.id = ctx.instanceid\n                         WHERE c.id = :courseid AND ctx.contextlevel = :contextlevel";
             $params = array('courseid' => $courseid, 'contextlevel' => CONTEXT_COURSE);
             $course = $DB->get_record_sql($sql, $params, MUST_EXIST);
             context_helper::preload_from_record($course);
         }
     } else {
         $course = $SITE;
     }
     $coursecontext = context_course::instance($course->id);
     // Course context
     $systemcontext = context_system::instance();
     $currentuser = $USER->id == $userid;
     if ($currentuser) {
         $user = $USER;
         $usercontext = context_user::instance($user->id);
         // User context
     } else {
         $select = context_helper::get_preload_record_columns_sql('ctx');
         $sql = "SELECT u.*, {$select}\n                      FROM {user} u\n                      JOIN {context} ctx ON u.id = ctx.instanceid\n                     WHERE u.id = :userid AND ctx.contextlevel = :contextlevel";
         $params = array('userid' => $userid, 'contextlevel' => CONTEXT_USER);
         $user = $DB->get_record_sql($sql, $params, IGNORE_MISSING);
         if (!$user) {
             return false;
         }
         context_helper::preload_from_record($user);
         // Check that the user can view the profile
         $usercontext = context_user::instance($user->id);
         // User context
         $canviewuser = has_capability('moodle/user:viewdetails', $usercontext);
         if ($course->id == $SITE->id) {
             if ($CFG->forceloginforprofiles && !has_coursecontact_role($user->id) && !$canviewuser) {
                 // Reduce possibility of "browsing" userbase at site level
                 // Teachers can browse and be browsed at site level. If not forceloginforprofiles, allow access (bug #4366)
                 return false;
             }
         } else {
             $canviewusercourse = has_capability('moodle/user:viewdetails', $coursecontext);
             $userisenrolled = is_enrolled($coursecontext, $user->id);
             if (!$canviewusercourse && !$canviewuser || !$userisenrolled) {
                 return false;
             }
             $canaccessallgroups = has_capability('moodle/site:accessallgroups', $coursecontext);
             if (!$canaccessallgroups && groups_get_course_groupmode($course) == SEPARATEGROUPS && !$canviewuser) {
                 // If groups are in use, make sure we can see that group (MDL-45874). That does not apply to parents.
                 if ($courseid == $this->page->course->id) {
                     $mygroups = get_fast_modinfo($this->page->course)->groups;
                 } else {
                     $mygroups = groups_get_user_groups($courseid);
                 }
                 $usergroups = groups_get_user_groups($courseid, $userid);
                 if (!array_intersect_key($mygroups[0], $usergroups[0])) {
                     return false;
                 }
             }
         }
     }
     $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $this->page->context));
     $key = $gstitle;
     if ($gstitle != 'usercurrentsettings') {
         $key .= $userid;
     }
     // Add a user setting branch
     $usersetting = $this->add(get_string($gstitle, 'moodle', $fullname), null, self::TYPE_CONTAINER, null, $key);
     $usersetting->id = 'usersettings';
     if ($this->page->context->contextlevel == CONTEXT_USER && $this->page->context->instanceid == $user->id) {
         // Automatically start by making it active
         $usersetting->make_active();
     }
     // 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;
//.........这里部分代码省略.........
开发者ID:adonm,项目名称:learning,代码行数:101,代码来源:navigationlib.php

示例15: user_get_user_details_courses

/**
 * Tries to obtain user details, either recurring directly to the user's system profile
 * or through one of the user's course enrollments (course profile).
 *
 * @param object $user The user.
 * @return array if unsuccessful or the allowed user details.
 */
function user_get_user_details_courses($user)
{
    global $USER;
    $userdetails = null;
    //  Get the courses that the user is enrolled in (only active).
    $courses = enrol_get_users_courses($user->id, true);
    $systemprofile = false;
    if (can_view_user_details_cap($user) || $user->id == $USER->id || has_coursecontact_role($user->id)) {
        $systemprofile = true;
    }
    // Try using system profile.
    if ($systemprofile) {
        $userdetails = user_get_user_details($user, null);
    } else {
        // Try through course profile.
        foreach ($courses as $course) {
            if (can_view_user_details_cap($user, $course) || $user->id == $USER->id || has_coursecontact_role($user->id)) {
                $userdetails = user_get_user_details($user, $course);
            }
        }
    }
    return $userdetails;
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:30,代码来源:lib.php


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