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


PHP user_mygrades_url函数代码示例

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


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

示例1: user_convert_text_to_menu_items

/**
 * Converts a string into a flat array of menu items, where each menu items is a
 * stdClass with fields type, url, title, pix, and imgsrc.
 *
 * @param string $text the menu items definition
 * @param moodle_page $page the current page
 * @return array
 */
function user_convert_text_to_menu_items($text, $page)
{
    global $OUTPUT, $CFG;
    $lines = explode("\n", $text);
    $items = array();
    $lastchild = null;
    $lastdepth = null;
    $lastsort = 0;
    $children = array();
    foreach ($lines as $line) {
        $line = trim($line);
        $bits = explode('|', $line, 3);
        $itemtype = 'link';
        if (preg_match("/^#+\$/", $line)) {
            $itemtype = 'divider';
        } else {
            if (!array_key_exists(0, $bits) or empty($bits[0])) {
                // Every item must have a name to be valid.
                continue;
            } else {
                $bits[0] = ltrim($bits[0], '-');
            }
        }
        // Create the child.
        $child = new stdClass();
        $child->itemtype = $itemtype;
        if ($itemtype === 'divider') {
            // Add the divider to the list of children and skip link
            // processing.
            $children[] = $child;
            continue;
        }
        // Name processing.
        $namebits = explode(',', $bits[0], 2);
        if (count($namebits) == 2) {
            // Check the validity of the identifier part of the string.
            if (clean_param($namebits[0], PARAM_STRINGID) !== '') {
                // Treat this as a language string.
                $child->title = get_string($namebits[0], $namebits[1]);
            }
        }
        if (empty($child->title)) {
            // Use it as is, don't even clean it.
            $child->title = $bits[0];
        }
        // URL processing.
        if (!array_key_exists(1, $bits) or empty($bits[1])) {
            // Set the url to null, and set the itemtype to invalid.
            $bits[1] = null;
            $child->itemtype = "invalid";
        } else {
            // Nasty hack to replace the grades with the direct url.
            if (strpos($bits[1], '/grade/report/mygrades.php') !== false) {
                $bits[1] = user_mygrades_url();
            }
            // Make sure the url is a moodle url.
            $bits[1] = new moodle_url(trim($bits[1]));
        }
        $child->url = $bits[1];
        // PIX processing.
        $pixpath = "t/edit";
        if (!array_key_exists(2, $bits) or empty($bits[2])) {
            // Use the default.
            $child->pix = $pixpath;
        } else {
            // Check for the specified image existing.
            $pixpath = "t/" . $bits[2];
            if ($page->theme->resolve_image_location($pixpath, 'moodle', true)) {
                // Use the image.
                $child->pix = $pixpath;
            } else {
                // Treat it like a URL.
                $child->pix = null;
                $child->imgsrc = $bits[2];
            }
        }
        // Add this child to the list of children.
        $children[] = $child;
    }
    return $children;
}
开发者ID:educakanchay,项目名称:campus,代码行数:89,代码来源:lib.php

示例2: generate_user_settings


//.........这里部分代码省略.........
         }
         // Add the messages link.
         // It is context based so can appear in the user's profile and in course participants information.
         if (!empty($CFG->messaging)) {
             $messageargs = array('user1' => $USER->id);
             if ($USER->id != $user->id) {
                 $messageargs['user2'] = $user->id;
             }
             if ($course->id != $SITE->id) {
                 $messageargs['viewing'] = MESSAGE_VIEW_COURSE . $course->id;
             }
             $url = new moodle_url('/message/index.php', $messageargs);
             $dashboard->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
         }
         // Add the "My private files" link.
         // This link doesn't have a unique display for course context so only display it under the user's profile.
         if ($issitecourse && $iscurrentuser && has_capability('moodle/user:manageownfiles', $usercontext)) {
             $url = new moodle_url('/user/files.php');
             $dashboard->add(get_string('privatefiles'), $url, self::TYPE_SETTING);
         }
         // Add a node to view the users notes if permitted.
         if (!empty($CFG->enablenotes) && has_any_capability(array('moodle/notes:manage', 'moodle/notes:view'), $coursecontext)) {
             $url = new moodle_url('/notes/index.php', array('user' => $user->id));
             if ($coursecontext->instanceid != SITEID) {
                 $url->param('course', $coursecontext->instanceid);
             }
             $profilenode->add(get_string('notes', 'notes'), $url);
         }
         // Show the grades node.
         if ($issitecourse && $iscurrentuser || has_capability('moodle/user:viewdetails', $usercontext)) {
             require_once $CFG->dirroot . '/user/lib.php';
             // Set the grades node to link to the "Grades" page.
             if ($course->id == SITEID) {
                 $url = user_mygrades_url($user->id, $course->id);
             } else {
                 // Otherwise we are in a course and should redirect to the user grade report (Activity report version).
                 $url = new moodle_url('/course/user.php', array('mode' => 'grade', 'id' => $course->id, 'user' => $user->id));
             }
             $dashboard->add(get_string('grades', 'grades'), $url, self::TYPE_SETTING, null, 'mygrades');
         }
         // Let plugins hook into user navigation.
         $pluginsfunction = get_plugins_with_function('extend_navigation_user', 'lib.php');
         foreach ($pluginsfunction as $plugintype => $plugins) {
             if ($plugintype != 'report') {
                 foreach ($plugins as $pluginfunction) {
                     $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 {
开发者ID:evltuma,项目名称:moodle,代码行数:67,代码来源:navigationlib.php

示例3: require_login

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Redirects the user to the default grade report.
 *
 * @package   core_grades
 * @copyright 2015 Adrian Greeve <adrian@moodle.com>
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once '../../config.php';
require_once $CFG->dirroot . '/user/lib.php';
require_login(null, false);
if (isguestuser()) {
    throw new require_login_exception('Guests are not allowed here.');
}
// Get the url to redirect to.
$url = user_mygrades_url();
// Redirect to that page.
redirect($url);
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:mygrades.php

示例4: get_string

$event->trigger();
$stractivityreport = get_string("activityreport");
$PAGE->navigation->extend_for_user($user);
$PAGE->navigation->set_userid_for_parent_checks($user->id);
// see MDL-25805 for reasons and for full commit reference for reversal when fixed.
$PAGE->set_title("{$course->shortname}: {$stractivityreport} ({$mode})");
$PAGE->set_heading(fullname($user));
switch ($mode) {
    case "grade":
        // Change the navigation to point to the my grade node (If we are a student).
        if ($USER->id == $user->id) {
            require_once $CFG->dirroot . '/user/lib.php';
            // Make the dashboard active so that it shows up in the navbar correctly.
            $gradenode = $PAGE->settingsnav->find('dashboard', null)->make_active();
            // Get the correct 'Grades' url to point to.
            $activeurl = user_mygrades_url();
            $navbar = $PAGE->navbar->add(get_string('grades', 'grades'), $activeurl, navigation_node::TYPE_SETTING);
            $activenode = $navbar->add($course->shortname);
            $activenode->make_active();
            // Find the course node and collapse it.
            $coursenode = $PAGE->navigation->find($course->id, navigation_node::TYPE_COURSE);
            $coursenode->collapse = true;
            $coursenode->make_inactive();
            $url = new moodle_url('/course/user.php', array('id' => $id, 'user' => $user->id, 'mode' => $mode));
            $reportnode = $activenode->add(get_string('pluginname', 'gradereport_user'), $url);
        } else {
            if ($course->id == SITEID) {
                $activenode = $PAGE->navigation->find('user' . $user->id, null);
            } else {
                $currentcoursenode = $PAGE->navigation->find('currentcourse', null);
                $activenode = $currentcoursenode->find_active_node();
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:user.php

示例5: test_get_config

 /**
  * Test get_config
  */
 public function test_get_config()
 {
     global $CFG, $SITE;
     require_once $CFG->dirroot . '/course/format/lib.php';
     $this->resetAfterTest(true);
     $result = external::get_config();
     $result = external_api::clean_returnvalue(external::get_config_returns(), $result);
     // SITE summary is null in phpunit which gets transformed to an empty string by format_text.
     list($sitesummary, $unused) = external_format_text($SITE->summary, $SITE->summaryformat, context_system::instance()->id);
     // Test default values.
     $context = context_system::instance();
     $expected = array(array('name' => 'fullname', 'value' => $SITE->fullname), array('name' => 'shortname', 'value' => $SITE->shortname), array('name' => 'summary', 'value' => $sitesummary), array('name' => 'summaryformat', 'value' => FORMAT_HTML), array('name' => 'frontpage', 'value' => $CFG->frontpage), array('name' => 'frontpageloggedin', 'value' => $CFG->frontpageloggedin), array('name' => 'maxcategorydepth', 'value' => $CFG->maxcategorydepth), array('name' => 'frontpagecourselimit', 'value' => $CFG->frontpagecourselimit), array('name' => 'numsections', 'value' => course_get_format($SITE)->get_course()->numsections), array('name' => 'newsitems', 'value' => $SITE->newsitems), array('name' => 'commentsperpage', 'value' => $CFG->commentsperpage), array('name' => 'disableuserimages', 'value' => $CFG->disableuserimages), array('name' => 'mygradesurl', 'value' => user_mygrades_url()->out(false)));
     $this->assertCount(0, $result['warnings']);
     $this->assertEquals($expected, $result['settings']);
     // Change a value and retrieve filtering by section.
     set_config('commentsperpage', 1);
     $expected[10]['value'] = 1;
     unset($expected[11]);
     unset($expected[12]);
     $result = external::get_config('frontpagesettings');
     $result = external_api::clean_returnvalue(external::get_config_returns(), $result);
     $this->assertCount(0, $result['warnings']);
     $this->assertEquals($expected, $result['settings']);
 }
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:27,代码来源:externallib_test.php

示例6: get_config

 /**
  * Returns a list of site configurations, filtering by section.
  *
  * @param  string $section section name
  * @return stdClass object containing the settings
  */
 public static function get_config($section)
 {
     global $CFG, $SITE;
     $settings = new \stdClass();
     $context = context_system::instance();
     $isadmin = has_capability('moodle/site:config', $context);
     if (empty($section) or $section == 'frontpagesettings') {
         require_once $CFG->dirroot . '/course/format/lib.php';
         // First settings that anyone can deduce.
         $settings->fullname = $SITE->fullname;
         $settings->shortname = $SITE->shortname;
         $settings->summary = $SITE->summary;
         $settings->frontpage = $CFG->frontpage;
         $settings->frontpageloggedin = $CFG->frontpageloggedin;
         $settings->maxcategorydepth = $CFG->maxcategorydepth;
         $settings->frontpagecourselimit = $CFG->frontpagecourselimit;
         $settings->numsections = course_get_format($SITE)->get_course()->numsections;
         $settings->newsitems = $SITE->newsitems;
         $settings->commentsperpage = $CFG->commentsperpage;
         // Now, admin settings.
         if ($isadmin) {
             $settings->defaultfrontpageroleid = $CFG->defaultfrontpageroleid;
         }
     }
     if (empty($section) or $section == 'sitepolicies') {
         $settings->disableuserimages = $CFG->disableuserimages;
     }
     if (empty($section) or $section == 'gradessettings') {
         require_once $CFG->dirroot . '/user/lib.php';
         $settings->mygradesurl = user_mygrades_url()->out(false);
     }
     return $settings;
 }
开发者ID:dg711,项目名称:moodle,代码行数:39,代码来源:api.php

示例7: get_config

 /**
  * Returns a list of site configurations, filtering by section.
  *
  * @param  string $section section name
  * @return stdClass object containing the settings
  */
 public static function get_config($section)
 {
     global $CFG, $SITE;
     $settings = new \stdClass();
     $context = context_system::instance();
     $isadmin = has_capability('moodle/site:config', $context);
     if (empty($section) or $section == 'frontpagesettings') {
         require_once $CFG->dirroot . '/course/format/lib.php';
         // First settings that anyone can deduce.
         $settings->fullname = external_format_string($SITE->fullname, $context->id);
         $settings->shortname = external_format_string($SITE->shortname, $context->id);
         // Return to a var instead of directly to $settings object because of differences between
         // list() in php5 and php7. {@link http://php.net/manual/en/function.list.php}
         $formattedsummary = external_format_text($SITE->summary, $SITE->summaryformat, $context->id);
         $settings->summary = $formattedsummary[0];
         $settings->summaryformat = $formattedsummary[1];
         $settings->frontpage = $CFG->frontpage;
         $settings->frontpageloggedin = $CFG->frontpageloggedin;
         $settings->maxcategorydepth = $CFG->maxcategorydepth;
         $settings->frontpagecourselimit = $CFG->frontpagecourselimit;
         $settings->numsections = course_get_format($SITE)->get_course()->numsections;
         $settings->newsitems = $SITE->newsitems;
         $settings->commentsperpage = $CFG->commentsperpage;
         // Now, admin settings.
         if ($isadmin) {
             $settings->defaultfrontpageroleid = $CFG->defaultfrontpageroleid;
         }
     }
     if (empty($section) or $section == 'sitepolicies') {
         $settings->disableuserimages = $CFG->disableuserimages;
     }
     if (empty($section) or $section == 'gradessettings') {
         require_once $CFG->dirroot . '/user/lib.php';
         $settings->mygradesurl = user_mygrades_url()->out(false);
     }
     return $settings;
 }
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:43,代码来源:api.php


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