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


PHP blog_get_options_for_user函数代码示例

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


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

示例1: load_for_user


//.........这里部分代码省略.........
             // you don't have access.... in the interests of no leaking informatin
             // we simply quit...
             return false;
         }
         // Add a branch for the current user
         $canseefullname = has_capability('moodle/site:viewfullnames', $coursecontext);
         $usernode = $usersnode->add(fullname($user, $canseefullname), $userviewurl, self::TYPE_USER, null, $user->id);
         if ($this->page->context->contextlevel == CONTEXT_USER && $user->id == $this->page->context->instanceid) {
             $usernode->make_active();
         }
     }
     // If the user is the current user or has permission to view the details of the requested
     // user than add a view profile link.
     if ($iscurrentuser || has_capability('moodle/user:viewdetails', $coursecontext) || has_capability('moodle/user:viewdetails', $usercontext)) {
         if ($issitecourse || $iscurrentuser && !$forceforcontext) {
             $usernode->add(get_string('viewprofile'), new moodle_url('/user/profile.php', $baseargs));
         } else {
             $usernode->add(get_string('viewprofile'), new moodle_url('/user/view.php', $baseargs));
         }
     }
     if (!empty($CFG->navadduserpostslinks)) {
         // Add nodes for forum posts and discussions if the user can view either or both
         // There are no capability checks here as the content of the page is based
         // purely on the forums the current user has access too.
         $forumtab = $usernode->add(get_string('forumposts', 'forum'));
         $forumtab->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php', $baseargs));
         $forumtab->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php', array_merge($baseargs, array('mode' => 'discussions'))));
     }
     // Add blog nodes
     if (!empty($CFG->bloglevel)) {
         if (!$this->cache->cached('userblogoptions' . $user->id)) {
             require_once $CFG->dirroot . '/blog/lib.php';
             // Get all options for the user
             $options = blog_get_options_for_user($user);
             $this->cache->set('userblogoptions' . $user->id, $options);
         } else {
             $options = $this->cache->{'userblogoptions' . $user->id};
         }
         if (count($options) > 0) {
             $blogs = $usernode->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER);
             foreach ($options as $type => $option) {
                 if ($type == "rss") {
                     $blogs->add($option['string'], $option['link'], settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
                 } else {
                     $blogs->add($option['string'], $option['link']);
                 }
             }
         }
     }
     if (!empty($CFG->messaging)) {
         $messageargs = null;
         if ($USER->id != $user->id) {
             $messageargs = array('id' => $user->id);
         }
         $url = new moodle_url('/message/index.php', $messageargs);
         $usernode->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
     }
     $context = get_context_instance(CONTEXT_USER, $USER->id);
     if ($iscurrentuser && has_capability('moodle/user:manageownfiles', $context)) {
         $url = new moodle_url('/user/files.php');
         $usernode->add(get_string('myfiles'), $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) {
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:67,代码来源:navigationlib.php

示例2: blog_get_all_options

/**
 * This function gets all of the options available for the current user in respect
 * to blogs.
 *
 * It loads the following if applicable:
 * -  Module options {@see blog_get_options_for_module}
 * -  Course options {@see blog_get_options_for_course}
 * -  User specific options {@see blog_get_options_for_user}
 * -  General options (BLOG_LEVEL_GLOBAL)
 *
 * @param moodle_page $page The page to load for (normally $PAGE)
 * @param stdClass $userid Load for a specific user
 * @return array An array of options organised by type.
 */
function blog_get_all_options(moodle_page $page, stdClass $userid = null)
{
    global $CFG, $DB, $USER;
    $options = array();
    // If blogs are enabled and the user is logged in and not a guest
    if (blog_is_enabled_for_user()) {
        // If the context is the user then assume we want to load for the users context
        if (is_null($userid) && $page->context->contextlevel == CONTEXT_USER) {
            $userid = $page->context->instanceid;
        }
        // Check the userid var
        if (!is_null($userid) && $userid !== $USER->id) {
            // Load the user from the userid... it MUST EXIST throw a wobbly if it doesn't!
            $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
        } else {
            $user = null;
        }
        if ($CFG->useblogassociations && $page->cm !== null) {
            // Load for the module associated with the page
            $options[CONTEXT_MODULE] = blog_get_options_for_module($page->cm, $user);
        } else {
            if ($CFG->useblogassociations && $page->course->id != SITEID) {
                // Load the options for the course associated with the page
                $options[CONTEXT_COURSE] = blog_get_options_for_course($page->course, $user);
            }
        }
        // Get the options for the user
        if ($user !== null and !isguestuser($user)) {
            // Load for the requested user
            $options[CONTEXT_USER + 1] = blog_get_options_for_user($user);
        }
        // Load for the current user
        if (isloggedin() and !isguestuser()) {
            $options[CONTEXT_USER] = blog_get_options_for_user();
        }
    }
    // If blog level is global then display a link to view all site entries
    if (!empty($CFG->bloglevel) && $CFG->bloglevel >= BLOG_GLOBAL_LEVEL && has_capability('moodle/blog:view', get_context_instance(CONTEXT_SYSTEM))) {
        $options[CONTEXT_SYSTEM] = array('viewsite' => array('string' => get_string('viewsiteentries', 'blog'), 'link' => new moodle_url('/blog/index.php')));
    }
    // Return the options
    return $options;
}
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:57,代码来源:lib.php

示例3: generate_user_settings


//.........这里部分代码省略.........
     // Add a user setting branch.
     if ($gstitle == 'usercurrentsettings') {
         $dashboard = $this->add(get_string('myhome'), new moodle_url('/my/'), self::TYPE_CONTAINER, null, 'dashboard');
         // This should be set to false as we don't want to show this to the user. It's only for generating the correct
         // breadcrumb.
         $dashboard->display = false;
         if (get_home_page() == HOMEPAGE_MY) {
             $dashboard->mainnavonly = true;
         }
         $iscurrentuser = $user->id == $USER->id;
         $baseargs = array('id' => $user->id);
         if ($course->id != $SITE->id && !$iscurrentuser) {
             $baseargs['course'] = $course->id;
             $issitecourse = false;
         } else {
             // Load all categories and get the context for the system.
             $issitecourse = true;
         }
         // Add the user profile to the dashboard.
         $profilenode = $dashboard->add(get_string('profile'), new moodle_url('/user/profile.php', array('id' => $user->id)), self::TYPE_SETTING, null, 'myprofile');
         if (!empty($CFG->navadduserpostslinks)) {
             // Add nodes for forum posts and discussions if the user can view either or both
             // There are no capability checks here as the content of the page is based
             // purely on the forums the current user has access too.
             $forumtab = $profilenode->add(get_string('forumposts', 'forum'));
             $forumtab->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php', $baseargs), null, 'myposts');
             $forumtab->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php', array_merge($baseargs, array('mode' => 'discussions'))), null, 'mydiscussions');
         }
         // Add blog nodes.
         if (!empty($CFG->enableblogs)) {
             if (!$this->cache->cached('userblogoptions' . $user->id)) {
                 require_once $CFG->dirroot . '/blog/lib.php';
                 // Get all options for the user.
                 $options = blog_get_options_for_user($user);
                 $this->cache->set('userblogoptions' . $user->id, $options);
             } else {
                 $options = $this->cache->{'userblogoptions' . $user->id};
             }
             if (count($options) > 0) {
                 $blogs = $profilenode->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER);
                 foreach ($options as $type => $option) {
                     if ($type == "rss") {
                         $blogs->add($option['string'], $option['link'], self::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
                     } else {
                         $blogs->add($option['string'], $option['link'], self::TYPE_SETTING, null, 'blog' . $type);
                     }
                 }
             }
         }
         // 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');
开发者ID:evltuma,项目名称:moodle,代码行数:67,代码来源:navigationlib.php

示例4: load_for_user


//.........这里部分代码省略.........
                // you don't have access.... in the interests of no leaking informatin
                // we simply quit...
                return false;
            }
            // Add a branch for the current user
            $usernode = $usersnode->add(fullname($user, true), $userviewurl, self::TYPE_USER, null, $user->id);

            if ($this->page->context->contextlevel == CONTEXT_USER && $user->id == $this->page->context->instanceid) {
                $usernode->make_active();
            }
        }

        // If the user is the current user or has permission to view the details of the requested
        // user than add a view profile link.
        if ($iscurrentuser || has_capability('moodle/user:viewdetails', $coursecontext) || has_capability('moodle/user:viewdetails', $usercontext)) {
            if ($issitecourse || ($iscurrentuser && !$forceforcontext)) {
                $usernode->add(get_string('viewprofile'), new moodle_url('/user/profile.php',$baseargs));
            } else {
                $usernode->add(get_string('viewprofile'), new moodle_url('/user/view.php',$baseargs));
            }
        }

        // Add nodes for forum posts and discussions if the user can view either or both
        // There are no capability checks here as the content of the page is based
        // purely on the forums the current user has access too.
        $forumtab = $usernode->add(get_string('forumposts', 'forum'));
        $forumtab->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php', $baseargs));
        $forumtab->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php', array_merge($baseargs, array('mode'=>'discussions'))));

        // Add blog nodes
        if (!empty($CFG->bloglevel)) {
            require_once($CFG->dirroot.'/blog/lib.php');
            // Get all options for the user
            $options = blog_get_options_for_user($user);
            if (count($options) > 0) {
                $blogs = $usernode->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER);
                foreach ($options as $option) {
                    $blogs->add($option['string'], $option['link']);
                }
            }
        }

        if (!empty($CFG->messaging)) {
            $messageargs = null;
            if ($USER->id!=$user->id) {
                $messageargs = array('id'=>$user->id);
            }
            $url = new moodle_url('/message/index.php',$messageargs);
            $usernode->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
        }

        // TODO: Private file capability check
        if ($iscurrentuser) {
            $url = new moodle_url('/user/files.php');
            $usernode->add(get_string('myfiles'), $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) {
                $url->param('course', $coursecontext->instanceid);
            }
            $usernode->add(get_string('notes', 'notes'), $url);
        }
开发者ID:nikita777,项目名称:moodle,代码行数:66,代码来源:navigationlib.php


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