ナビゲーションブロックの項目に関して

ナビゲーションブロックの項目に関して

by ma mi -
Number of replies: 2

ナビゲーションブロックの項目をいくつか削除したいと思うのですが,そのようなことは可能なのでしょうか.また,解決方法があればご教示いただきたく,お願い申し上げます.

Moodle2.6.3+,Xampp1.7.7(Appache2.2.17,PHP5.3.5,MySQL5.5.8)を使用しています.

組み込んでいる言語は日本語です.

サイトページの「参加者,サイトブログ,サイトバッジ,ノート,タグ」やマイプロファイルの「フォーラム投稿,ブログ,メッセージ,マイバッジ,ノート」を削除したいと考えています.


Attachment キャプチャ.PNG
Average of ratings: -
In reply to ma mi

Re: ナビゲーションブロックの項目に関して

by Mitsuhiro Yoshida -
Picture of Developers Picture of Translators

ご参考までに下記投稿をご覧ください。

[Moodle in English: Remove items from navigation block?]
https://moodle.org/mod/forum/discuss.php?d=180982

また、今後のMoodleバージョンアップを考えますと、あまりお勧めできる方法ではありませんが、下記修正によりナビゲーションブロックの項目を削除することはできます。
----------------------------------------------------------------
修正対象プログラム:
lib/navigationlib.php

修正箇所:
2196行目

[ 修正前 ]
       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'))));
        }

[ 修正後 ]
       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'))));
        }

備考:
ナビゲーションブロックより「フォーラム投稿」メニューを削除します。
----------------------------------------------------------------

修正対象プログラム:
lib/navigationlib.php

修正箇所:
2213行目

[ 修正前 ]
        // 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 = $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']);
                    }
                }
            }
        }


[ 修正後 ]
        // 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 = $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']);
                    }
                }
            }
        }

備考:
ナビゲーションブロックより「ブログ」メニューを削除します。
----------------------------------------------------------------

修正対象プログラム:
lib/navigationlib.php

修正箇所:
2233行目

[ 修正前 ]
        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);
            $usernode->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
        }

        if ($iscurrentuser && has_capability('moodle/user:manageownfiles', context_user::instance($USER->id))) {
            $url = new moodle_url('/user/files.php');
            $usernode->add(get_string('myfiles'), $url, self::TYPE_SETTING);
        }

        if (!empty($CFG->enablebadges) && $iscurrentuser &&
                has_capability('moodle/badges:manageownbadges', context_user::instance($USER->id))) {
            $url = new moodle_url('/badges/mybadges.php');
            $usernode->add(get_string('mybadges', 'badges'), $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);
            }
            $usernode->add(get_string('notes', 'notes'), $url);
        }


[ 修正後 ]
        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);
//            $usernode->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
        }

        if ($iscurrentuser && has_capability('moodle/user:manageownfiles', context_user::instance($USER->id))) {
            $url = new moodle_url('/user/files.php');
            $usernode->add(get_string('myfiles'), $url, self::TYPE_SETTING);
        }

        if (!empty($CFG->enablebadges) && $iscurrentuser &&
                has_capability('moodle/badges:manageownbadges', context_user::instance($USER->id))) {
            $url = new moodle_url('/badges/mybadges.php');
//            $usernode->add(get_string('mybadges', 'badges'), $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);
            }
//            $usernode->add(get_string('notes', 'notes'), $url);
        }

備考:
ナビゲーションブロックより「メッセージ」「マイバッジ」「ノート」メニューを削除します。

In reply to Mitsuhiro Yoshida

Re: ナビゲーションブロックの項目に関して

by ma mi -

よしだ様

早速のご回答ありがとうございます.

Moodleの体験用として利用しますのでバージョンアップの予定はありません.今後バージョンアップすることがありましたら,その時は別の方法を考えたいと思います.

「フォーラム投稿」,「ブログ」,「メッセージ」,「マイバッジ」,「ノート」メニュー削除に成功しました.大変参考になりました.

よしだ様のご回答を参考に自分自身でも修正を加えたいと思います.

Moodle初心者ですので今後ともよろしくお願いいたします.