本文整理汇总了PHP中wiki_user_can_edit函数的典型用法代码示例。如果您正苦于以下问题:PHP wiki_user_can_edit函数的具体用法?PHP wiki_user_can_edit怎么用?PHP wiki_user_can_edit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wiki_user_can_edit函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wiki_extend_navigation
function wiki_extend_navigation(navigation_node $navref, $course, $module, $cm)
{
global $CFG, $PAGE, $USER;
require_once $CFG->dirroot . '/mod/wiki/locallib.php';
$context = context_module::instance($cm->id);
$url = $PAGE->url;
$userid = 0;
if ($module->wikimode == 'individual') {
$userid = $USER->id;
}
if (!($wiki = wiki_get_wiki($cm->instance))) {
return false;
}
if (!($gid = groups_get_activity_group($cm))) {
$gid = 0;
}
if (!($subwiki = wiki_get_subwiki_by_group($cm->instance, $gid, $userid))) {
return null;
} else {
$swid = $subwiki->id;
}
$pageid = $url->param('pageid');
$cmid = $url->param('id');
if (empty($pageid) && !empty($cmid)) {
// wiki main page
$page = wiki_get_page_by_title($swid, $wiki->firstpagetitle);
$pageid = $page->id;
}
if (wiki_can_create_pages($context)) {
$link = new moodle_url('/mod/wiki/create.php', array('action' => 'new', 'swid' => $swid));
$node = $navref->add(get_string('newpage', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (is_numeric($pageid)) {
if (has_capability('mod/wiki:viewpage', $context)) {
$link = new moodle_url('/mod/wiki/view.php', array('pageid' => $pageid));
$node = $navref->add(get_string('view', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (wiki_user_can_edit($subwiki)) {
$link = new moodle_url('/mod/wiki/edit.php', array('pageid' => $pageid));
$node = $navref->add(get_string('edit', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:viewcomment', $context)) {
$link = new moodle_url('/mod/wiki/comments.php', array('pageid' => $pageid));
$node = $navref->add(get_string('comments', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:viewpage', $context)) {
$link = new moodle_url('/mod/wiki/history.php', array('pageid' => $pageid));
$node = $navref->add(get_string('history', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:viewpage', $context)) {
$link = new moodle_url('/mod/wiki/map.php', array('pageid' => $pageid));
$node = $navref->add(get_string('map', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:viewpage', $context)) {
$link = new moodle_url('/mod/wiki/files.php', array('pageid' => $pageid));
$node = $navref->add(get_string('files', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:managewiki', $context)) {
$link = new moodle_url('/mod/wiki/admin.php', array('pageid' => $pageid));
$node = $navref->add(get_string('admin', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
}
}
开发者ID:dg711,项目名称:moodle,代码行数:63,代码来源:lib.php
示例2: print_content
function print_content()
{
global $CFG, $PAGE;
$version = wiki_get_version($this->version->id);
$wiki = $PAGE->activityrecord;
if (wiki_user_can_edit($this->subwiki, $wiki) && wiki_restore_page($this->page, $version, $this->modcontext)) {
redirect($CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $this->page->id, get_string('restoring', 'wiki', $version->version), 3);
} else {
print_error('restoreerror', 'wiki', $version->version);
}
}
开发者ID:jackdaniels79,项目名称:moodle,代码行数:11,代码来源:pagelib.php
示例3: print_content
function print_content() {
global $PAGE;
if (wiki_user_can_edit($this->subwiki)) {
$this->print_edit();
} else {
echo get_string('cannoteditpage', 'wiki');
}
}
开发者ID:Burick,项目名称:moodle,代码行数:9,代码来源:pagelib.php
示例4: print_content
function print_content()
{
global $PAGE;
if (wiki_user_can_edit($this->subwiki)) {
$this->print_edit();
} else {
// @TODO: Translate it
echo "You can not edit this page";
}
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:10,代码来源:pagelib.php
示例5: required_param
}
$pageid = required_param('pageid', PARAM_INT);
$section = optional_param('section', "", PARAM_TEXT);
if (!($page = wiki_get_page($pageid))) {
print_error('incorrectpageid', 'wiki');
}
if (!($subwiki = wiki_get_subwiki($page->subwikiid))) {
print_error('incorrectsubwikiid', 'wiki');
}
if (!($wiki = wiki_get_wiki($subwiki->wikiid))) {
print_error('incorrectwikiid', 'wiki');
}
if (!($cm = get_coursemodule_from_instance('wiki', $wiki->id))) {
print_error('invalidcoursemodule');
}
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
if (!empty($section) && !($sectioncontent = wiki_get_section_page($page, $section))) {
print_error('invalidsection', 'wiki');
}
require_login($course, false, $cm);
if (!wiki_user_can_edit($subwiki)) {
print_error('cannoteditpage', 'wiki');
}
$wikipage = new page_wiki_lock($wiki, $subwiki, $cm);
$wikipage->set_page($page);
if (!empty($section)) {
$wikipage->set_section($sectioncontent, $section);
}
$wikipage->print_header();
$wikipage->print_content();
$wikipage->print_footer();
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:lock.php
示例6: test_wiki_user_can_edit_with_groups_individual
/**
* Test wiki_user_can_edit using individual wikis with groups.
*
* @return void
*/
public function test_wiki_user_can_edit_with_groups_individual()
{
global $DB;
$this->resetAfterTest();
$this->setAdminUser();
// Setup test data.
$course = $this->getDataGenerator()->create_course();
$wikisepind = $this->getDataGenerator()->create_module('wiki', array('course' => $course->id, 'groupmode' => SEPARATEGROUPS, 'wikimode' => 'individual'));
$wikivisind = $this->getDataGenerator()->create_module('wiki', array('course' => $course->id, 'groupmode' => VISIBLEGROUPS, 'wikimode' => 'individual'));
// Create users.
$student = self::getDataGenerator()->create_user();
$student2 = self::getDataGenerator()->create_user();
$teacher = self::getDataGenerator()->create_user();
// Users enrolments.
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
$teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher'));
$this->getDataGenerator()->enrol_user($student->id, $course->id, $studentrole->id, 'manual');
$this->getDataGenerator()->enrol_user($student2->id, $course->id, $studentrole->id, 'manual');
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id, 'manual');
// Create groups.
$group1 = $this->getDataGenerator()->create_group(array('courseid' => $course->id));
$this->getDataGenerator()->create_group_member(array('userid' => $student->id, 'groupid' => $group1->id));
$this->getDataGenerator()->create_group_member(array('userid' => $student2->id, 'groupid' => $group1->id));
$group2 = $this->getDataGenerator()->create_group(array('courseid' => $course->id));
$this->getDataGenerator()->create_group_member(array('userid' => $student2->id, 'groupid' => $group2->id));
// Simulate all the possible subwikis.
// Subwikis in collaborative wikis: 1 subwiki per group + 1 subwiki for all participants.
$swsepindg1s1 = new stdClass();
$swsepindg1s1->id = -1;
$swsepindg1s1->wikiid = $wikisepind->id;
$swsepindg1s1->groupid = $group1->id;
$swsepindg1s1->userid = $student->id;
$swsepindg1s2 = clone $swsepindg1s1;
$swsepindg1s2->userid = $student2->id;
$swsepindg2s2 = clone $swsepindg1s2;
$swsepindg2s2->groupid = $group2->id;
$swsepindteacher = clone $swsepindg1s1;
$swsepindteacher->userid = $teacher->id;
$swsepindteacher->groupid = 0;
$swvisindg1s1 = clone $swsepindg1s1;
$swvisindg1s1->wikiid = $wikivisind->id;
$swvisindg1s2 = clone $swvisindg1s1;
$swvisindg1s2->userid = $student2->id;
$swvisindg2s2 = clone $swvisindg1s2;
$swvisindg2s2->groupid = $group2->id;
$swvisindteacher = clone $swvisindg1s1;
$swvisindteacher->userid = $teacher->id;
$swvisindteacher->groupid = 0;
$this->setUser($student);
// Check that the student can edit his subwiki both in separate and visible groups.
$this->assertTrue(wiki_user_can_edit($swsepindg1s1));
$this->assertTrue(wiki_user_can_edit($swvisindg1s1));
// Check that the student cannot edit subwikis from another user even if he belongs to his group.
$this->assertFalse(wiki_user_can_edit($swsepindg1s2));
$this->assertFalse(wiki_user_can_edit($swvisindg1s2));
// Now test as student 2.
$this->setUser($student2);
// Check that the student 2 can edit his subwikis from both groups both in separate and visible groups.
$this->assertTrue(wiki_user_can_edit($swsepindg1s2));
$this->assertTrue(wiki_user_can_edit($swvisindg1s2));
$this->assertTrue(wiki_user_can_edit($swsepindg2s2));
$this->assertTrue(wiki_user_can_edit($swvisindg2s2));
// Now test it as a teacher.
$this->setUser($teacher);
// Check that teacher can edit all subwikis.
$this->assertTrue(wiki_user_can_edit($swsepindg1s1));
$this->assertTrue(wiki_user_can_edit($swsepindg1s2));
$this->assertTrue(wiki_user_can_edit($swsepindg2s2));
$this->assertTrue(wiki_user_can_edit($swsepindteacher));
$this->assertTrue(wiki_user_can_edit($swvisindg1s1));
$this->assertTrue(wiki_user_can_edit($swvisindg1s2));
$this->assertTrue(wiki_user_can_edit($swvisindg2s2));
$this->assertTrue(wiki_user_can_edit($swvisindteacher));
}
开发者ID:evltuma,项目名称:moodle,代码行数:79,代码来源:lib_test.php
示例7: edit_page
/**
* Edit a page contents.
*
* @param int $pageid The page ID.
* @param string $content Page contents.
* @param int $section Section to be edited.
* @return array of warnings and page data.
* @since Moodle 3.1
*/
public static function edit_page($pageid, $content, $section = null)
{
global $USER;
$params = self::validate_parameters(self::edit_page_parameters(), array('pageid' => $pageid, 'content' => $content, 'section' => $section));
$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');
}
// Get subwiki instance.
if (!($subwiki = wiki_get_subwiki($page->subwikiid))) {
throw new moodle_exception('incorrectsubwikiid', 'wiki');
}
// Permission validation.
$cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
$context = context_module::instance($cm->id);
self::validate_context($context);
if (!wiki_user_can_edit($subwiki)) {
throw new moodle_exception('cannoteditpage', 'wiki');
}
if (wiki_is_page_section_locked($page->id, $USER->id, $params['section'])) {
throw new moodle_exception('pageislocked', 'wiki');
}
// Save content.
if (!is_null($params['section'])) {
$version = wiki_get_current_version($page->id);
$content = wiki_parser_proxy::get_section($version->content, $version->contentformat, $params['section'], false);
if (!$content) {
throw new moodle_exception('invalidsection', 'wiki');
}
$save = wiki_save_section($page, $params['section'], $params['content'], $USER->id);
} else {
$save = wiki_save_page($page, $params['content'], $USER->id);
}
wiki_delete_locks($page->id, $USER->id, $params['section']);
if (!$save) {
throw new moodle_exception('savingerror', 'wiki');
}
$result = array();
$result['pageid'] = $page->id;
$result['warnings'] = $warnings;
return $result;
}
开发者ID:jackdaniels79,项目名称:moodle,代码行数:56,代码来源:external.php
示例8: print_content
function print_content() {
global $PAGE;
$context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->id);
if (wiki_user_can_edit($this->subwiki)) {
$this->print_edit();
} else {
// @TODO: Translate it
echo "You can not edit this page";
}
}
开发者ID:nuckey,项目名称:moodle,代码行数:11,代码来源:pagelib.php
示例9: get_subwikis
/**
* Returns the list of subwikis the user can see in a specific wiki.
*
* @param int $wikiid The wiki instance ID.
* @return array Containing a list of warnings and a list of subwikis.
* @since Moodle 3.1
*/
public static function get_subwikis($wikiid)
{
global $USER;
$warnings = array();
$params = self::validate_parameters(self::get_subwikis_parameters(), array('wikiid' => $wikiid));
// Get wiki instance.
if (!($wiki = wiki_get_wiki($params['wikiid']))) {
throw new moodle_exception('incorrectwikiid', 'wiki');
}
// Validate context and capabilities.
list($course, $cm) = get_course_and_cm_from_instance($wiki, 'wiki');
$context = context_module::instance($cm->id);
self::validate_context($context);
require_capability('mod/wiki:viewpage', $context);
$returnedsubwikis = wiki_get_visible_subwikis($wiki, $cm, $context);
foreach ($returnedsubwikis as $subwiki) {
$subwiki->canedit = wiki_user_can_edit($subwiki);
}
$result = array();
$result['subwikis'] = $returnedsubwikis;
$result['warnings'] = $warnings;
return $result;
}
开发者ID:kevin-bruton,项目名称:moodle,代码行数:30,代码来源:external.php
示例10: 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:rushi963,项目名称:moodle,代码行数:50,代码来源:external.php
注:本文中的wiki_user_can_edit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论