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


PHP wiki_user_can_view函数代码示例

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


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

示例1: print_error

    }
    // Checking wiki instance of that subwiki
    if (!($wiki = wiki_get_wiki($subwiki->wikiid))) {
        print_error('incorrectwikiid', 'wiki');
    }
}
// Checking course module instance
if (!($cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid))) {
    print_error('invalidcoursemodule');
}
// Checking course instance
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$context = context_module::instance($cm->id);
$PAGE->set_url('/mod/wiki/files.php', array('pageid' => $pageid));
require_login($course, true, $cm);
if (!wiki_user_can_view($subwiki, $wiki)) {
    print_error('cannotviewfiles', 'wiki');
}
$PAGE->set_title(get_string('wikifiles', 'wiki'));
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add(format_string(get_string('wikifiles', 'wiki')));
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($wiki->name));
echo $OUTPUT->box(format_module_intro('wiki', $wiki, $PAGE->cm->id), 'generalbox', 'intro');
$renderer = $PAGE->get_renderer('mod_wiki');
$tabitems = array('view' => 'view', 'edit' => 'edit', 'comments' => 'comments', 'history' => 'history', 'map' => 'map', 'files' => 'files', 'admin' => 'admin');
$options = array('activetab' => 'files');
echo $renderer->tabs($page, $tabitems, $options);
echo $OUTPUT->box_start('generalbox');
echo $renderer->wiki_print_subwiki_selector($PAGE->activityrecord, $subwiki, $page, 'files');
echo $renderer->wiki_files_tree($context, $subwiki);
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:files.php

示例2: wiki_print_recent_activity

/**
 * Given a course and a time, this module should find recent activity
 * that has occurred in wiki activities and print it out.
 * Return true if there was output, or false is there was none.
 *
 * @global $CFG
 * @global $DB
 * @uses CONTEXT_MODULE
 * @uses VISIBLEGROUPS
 * @param object $course
 * @param bool $viewfullnames capability
 * @param int $timestart
 * @return boolean
 **/
function wiki_print_recent_activity($course, $viewfullnames, $timestart)
{
    global $CFG, $DB, $OUTPUT;
    $sql = "SELECT p.id, p.timemodified, p.subwikiid, sw.wikiid, w.wikimode, sw.userid, sw.groupid\n            FROM {wiki_pages} p\n                JOIN {wiki_subwikis} sw ON sw.id = p.subwikiid\n                JOIN {wiki} w ON w.id = sw.wikiid\n            WHERE p.timemodified > ? AND w.course = ?\n            ORDER BY p.timemodified ASC";
    if (!($pages = $DB->get_records_sql($sql, array($timestart, $course->id)))) {
        return false;
    }
    require_once $CFG->dirroot . "/mod/wiki/locallib.php";
    $wikis = array();
    $modinfo = get_fast_modinfo($course);
    $subwikivisible = array();
    foreach ($pages as $page) {
        if (!isset($subwikivisible[$page->subwikiid])) {
            $subwiki = (object) array('id' => $page->subwikiid, 'wikiid' => $page->wikiid, 'groupid' => $page->groupid, 'userid' => $page->userid);
            $wiki = (object) array('id' => $page->wikiid, 'course' => $course->id, 'wikimode' => $page->wikimode);
            $subwikivisible[$page->subwikiid] = wiki_user_can_view($subwiki, $wiki);
        }
        if ($subwikivisible[$page->subwikiid]) {
            $wikis[] = $page;
        }
    }
    unset($subwikivisible);
    unset($pages);
    if (!$wikis) {
        return false;
    }
    echo $OUTPUT->heading(get_string("updatedwikipages", 'wiki') . ':', 3);
    foreach ($wikis as $wiki) {
        $cm = $modinfo->instances['wiki'][$wiki->wikiid];
        $link = $CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $wiki->id;
        print_recent_activity_note($wiki->timemodified, $wiki, $cm->name, $link, false, $viewfullnames);
    }
    return true;
    //  True if anything was printed, otherwise false
}
开发者ID:dg711,项目名称:moodle,代码行数:49,代码来源:lib.php

示例3: print_content

    function print_content() {
        global $PAGE, $CFG;

        if (wiki_user_can_view($this->subwiki)) {

            if (!empty($this->page)) {
                wiki_print_page_content($this->page, $this->modcontext, $this->subwiki->id);
                $wiki = $PAGE->activityrecord;
            } else {
                print_string('nocontent', 'wiki');
                // TODO: fix this part
                $swid = 0;
                if (!empty($this->subwiki)) {
                    $swid = $this->subwiki->id;
                }
            }
        } else {
            echo get_string('cannotviewpage', 'wiki');
        }
    }
开发者ID:Burick,项目名称:moodle,代码行数:20,代码来源:pagelib.php

示例4: mod_wiki_get_tagged_pages

/**
 * Returns wiki pages tagged with a specified tag.
 *
 * This is a callback used by the tag area mod_wiki/wiki_pages to search for wiki pages
 * tagged with a specific tag.
 *
 * @param core_tag_tag $tag
 * @param bool $exclusivemode if set to true it means that no other entities tagged with this tag
 *             are displayed on the page and the per-page limit may be bigger
 * @param int $fromctx context id where the link was displayed, may be used by callbacks
 *            to display items in the same context first
 * @param int $ctx context id where to search for records
 * @param bool $rec search in subcontexts as well
 * @param int $page 0-based number of page being displayed
 * @return \core_tag\output\tagindex
 */
function mod_wiki_get_tagged_pages($tag, $exclusivemode = false, $fromctx = 0, $ctx = 0, $rec = 1, $page = 0)
{
    global $OUTPUT;
    $perpage = $exclusivemode ? 20 : 5;
    // Build the SQL query.
    $ctxselect = context_helper::get_preload_record_columns_sql('ctx');
    $query = "SELECT wp.id, wp.title, ws.userid, ws.wikiid, ws.id AS subwikiid, ws.groupid, w.wikimode,\n                    cm.id AS cmid, c.id AS courseid, c.shortname, c.fullname, {$ctxselect}\n                FROM {wiki_pages} wp\n                JOIN {wiki_subwikis} ws ON wp.subwikiid = ws.id\n                JOIN {wiki} w ON w.id = ws.wikiid\n                JOIN {modules} m ON m.name='wiki'\n                JOIN {course_modules} cm ON cm.module = m.id AND cm.instance = w.id\n                JOIN {tag_instance} tt ON wp.id = tt.itemid\n                JOIN {course} c ON cm.course = c.id\n                JOIN {context} ctx ON ctx.instanceid = cm.id AND ctx.contextlevel = :coursemodulecontextlevel\n               WHERE tt.itemtype = :itemtype AND tt.tagid = :tagid AND tt.component = :component\n                 AND wp.id %ITEMFILTER% AND c.id %COURSEFILTER%";
    $params = array('itemtype' => 'wiki_pages', 'tagid' => $tag->id, 'component' => 'mod_wiki', 'coursemodulecontextlevel' => CONTEXT_MODULE);
    if ($ctx) {
        $context = $ctx ? context::instance_by_id($ctx) : context_system::instance();
        $query .= $rec ? ' AND (ctx.id = :contextid OR ctx.path LIKE :path)' : ' AND ctx.id = :contextid';
        $params['contextid'] = $context->id;
        $params['path'] = $context->path . '/%';
    }
    $query .= " ORDER BY ";
    if ($fromctx) {
        // In order-clause specify that modules from inside "fromctx" context should be returned first.
        $fromcontext = context::instance_by_id($fromctx);
        $query .= ' (CASE WHEN ctx.id = :fromcontextid OR ctx.path LIKE :frompath THEN 0 ELSE 1 END),';
        $params['fromcontextid'] = $fromcontext->id;
        $params['frompath'] = $fromcontext->path . '/%';
    }
    $query .= ' c.sortorder, cm.id, wp.id';
    $totalpages = $page + 1;
    // Use core_tag_index_builder to build and filter the list of items.
    $builder = new core_tag_index_builder('mod_wiki', 'wiki_pages', $query, $params, $page * $perpage, $perpage + 1);
    while ($item = $builder->has_item_that_needs_access_check()) {
        context_helper::preload_from_record($item);
        $courseid = $item->courseid;
        if (!$builder->can_access_course($courseid)) {
            $builder->set_accessible($item, false);
            continue;
        }
        $modinfo = get_fast_modinfo($builder->get_course($courseid));
        // Set accessibility of this item and all other items in the same course.
        $builder->walk(function ($taggeditem) use($courseid, $modinfo, $builder) {
            if ($taggeditem->courseid == $courseid) {
                $accessible = false;
                if (($cm = $modinfo->get_cm($taggeditem->cmid)) && $cm->uservisible) {
                    $subwiki = (object) array('id' => $taggeditem->subwikiid, 'groupid' => $taggeditem->groupid, 'userid' => $taggeditem->userid, 'wikiid' => $taggeditem->wikiid);
                    $wiki = (object) array('id' => $taggeditem->wikiid, 'wikimode' => $taggeditem->wikimode, 'course' => $cm->course);
                    $accessible = wiki_user_can_view($subwiki, $wiki);
                }
                $builder->set_accessible($taggeditem, $accessible);
            }
        });
    }
    $items = $builder->get_items();
    if (count($items) > $perpage) {
        $totalpages = $page + 2;
        // We don't need exact page count, just indicate that the next page exists.
        array_pop($items);
    }
    // Build the display contents.
    if ($items) {
        $tagfeed = new core_tag\output\tagfeed();
        foreach ($items as $item) {
            context_helper::preload_from_record($item);
            $modinfo = get_fast_modinfo($item->courseid);
            $cm = $modinfo->get_cm($item->cmid);
            $pageurl = new moodle_url('/mod/wiki/view.php', array('pageid' => $item->id));
            $pagename = format_string($item->title, true, array('context' => context_module::instance($item->cmid)));
            $pagename = html_writer::link($pageurl, $pagename);
            $courseurl = course_get_url($item->courseid, $cm->sectionnum);
            $cmname = html_writer::link($cm->url, $cm->get_formatted_name());
            $coursename = format_string($item->fullname, true, array('context' => context_course::instance($item->courseid)));
            $coursename = html_writer::link($courseurl, $coursename);
            $icon = html_writer::link($pageurl, html_writer::empty_tag('img', array('src' => $cm->get_icon_url())));
            $tagfeed->add($icon, $pagename, $cmname . '<br>' . $coursename);
        }
        $content = $OUTPUT->render_from_template('core_tag/tagfeed', $tagfeed->export_for_template($OUTPUT));
        return new core_tag\output\tagindex($tag, 'mod_wiki', 'wiki_pages', $content, $exclusivemode, $fromctx, $ctx, $rec, $page, $totalpages);
    }
}
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:90,代码来源:locallib.php

示例5: get_page_contents

 /**
  * Get a page contents.
  *
  * @param int $pageid The page ID.
  * @return array of warnings and page data.
  * @since Moodle 3.1
  */
 public static function get_page_contents($pageid)
 {
     $params = self::validate_parameters(self::get_page_contents_parameters(), array('pageid' => $pageid));
     $warnings = array();
     // Get wiki page.
     if (!($page = wiki_get_page($params['pageid']))) {
         throw new moodle_exception('incorrectpageid', 'wiki');
     }
     // Get wiki instance.
     if (!($wiki = wiki_get_wiki_from_pageid($params['pageid']))) {
         throw new moodle_exception('incorrectwikiid', 'wiki');
     }
     // Permission validation.
     $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     // Check if user can view this wiki.
     if (!($subwiki = wiki_get_subwiki($page->subwikiid))) {
         throw new moodle_exception('incorrectsubwikiid', 'wiki');
     }
     if (!wiki_user_can_view($subwiki, $wiki)) {
         throw new moodle_exception('cannotviewpage', 'wiki');
     }
     $returnedpage = array();
     $returnedpage['id'] = $page->id;
     $returnedpage['wikiid'] = $wiki->id;
     $returnedpage['subwikiid'] = $page->subwikiid;
     $returnedpage['groupid'] = $subwiki->groupid;
     $returnedpage['userid'] = $subwiki->userid;
     $returnedpage['title'] = $page->title;
     // Refresh page cached content if needed.
     if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
         if ($content = wiki_refresh_cachedcontent($page)) {
             $page = $content['page'];
         }
     }
     list($returnedpage['cachedcontent'], $returnedpage['contentformat']) = external_format_text($page->cachedcontent, FORMAT_HTML, $context->id, 'mod_wiki', 'attachments', $subwiki->id);
     $returnedpage['caneditpage'] = wiki_user_can_edit($subwiki);
     $result = array();
     $result['page'] = $returnedpage;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:jackdaniels79,项目名称:moodle,代码行数:50,代码来源:external.php

示例6: view_page

 /**
  * Trigger the page viewed event and update the module completion status.
  *
  * @param int $pageid The page ID.
  * @return array of warnings and status result.
  * @since Moodle 3.1
  * @throws moodle_exception if page is not valid.
  */
 public static function view_page($pageid)
 {
     $params = self::validate_parameters(self::view_page_parameters(), array('pageid' => $pageid));
     $warnings = array();
     // Get wiki page.
     if (!($page = wiki_get_page($params['pageid']))) {
         throw new moodle_exception('incorrectpageid', 'wiki');
     }
     // Get wiki instance.
     if (!($wiki = wiki_get_wiki_from_pageid($params['pageid']))) {
         throw new moodle_exception('incorrectwikiid', 'wiki');
     }
     // Permission validation.
     list($course, $cm) = get_course_and_cm_from_instance($wiki, 'wiki');
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     // Check if user can view this wiki.
     if (!($subwiki = wiki_get_subwiki($page->subwikiid))) {
         throw new moodle_exception('incorrectsubwikiid', 'wiki');
     }
     if (!wiki_user_can_view($subwiki, $wiki)) {
         throw new moodle_exception('cannotviewpage', 'wiki');
     }
     // Trigger page_viewed event and completion.
     wiki_page_view($wiki, $page, $course, $cm, $context);
     $result = array();
     $result['status'] = true;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:matiasma,项目名称:moodle,代码行数:38,代码来源:external.php

示例7: print_content

    function print_content() {
        global $PAGE, $CFG;

        $context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->id);
        if (wiki_user_can_view($this->subwiki)) {

            if (!empty($this->page)) {
                wiki_print_page_content($this->page, $context, $this->subwiki->id);
                $wiki = $PAGE->activityrecord;
            } else {
                print_string('nocontent', 'wiki');
                // TODO: fix this part
                $swid = 0;
                if (!empty($this->subwiki)) {
                    $swid = $this->subwiki->id;
                }
            }
        } else {
            // @TODO: Tranlate it
            echo "You can not view this page";
        }
    }
开发者ID:nuckey,项目名称:moodle,代码行数:22,代码来源:pagelib.php


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