本文整理汇总了PHP中wiki_set_lock函数的典型用法代码示例。如果您正苦于以下问题:PHP wiki_set_lock函数的具体用法?PHP wiki_set_lock怎么用?PHP wiki_set_lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wiki_set_lock函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: print_content
public function print_content() {
global $USER, $PAGE;
require_capability('mod/wiki:editpage', $this->modcontext, NULL, true, 'noeditpermission', 'wiki');
wiki_set_lock($this->page->id, $USER->id, $this->section);
}
开发者ID:Burick,项目名称:moodle,代码行数:7,代码来源:pagelib.php
示例2: test_edit_page
/**
* Test edit_page. We won't test all the possible cases because that's already
* done in the tests for wiki_save_section / wiki_save_page.
*/
public function test_edit_page()
{
$this->create_individual_wikis_with_groups();
// Test user with full capabilities.
$this->setUser($this->student);
$newpage = $this->getDataGenerator()->get_plugin_generator('mod_wiki')->create_page($this->wikisepind, array('group' => $this->group1->id, 'content' => 'Test'));
// Test edit whole page.
$sectioncontent = '<h1>Title1</h1>Text inside section';
$newpagecontent = $sectioncontent . '<h1>Title2</h1>Text inside section';
$result = mod_wiki_external::edit_page($newpage->id, $newpagecontent);
$result = external_api::clean_returnvalue(mod_wiki_external::edit_page_returns(), $result);
$this->assertInternalType('int', $result['pageid']);
$version = wiki_get_current_version($result['pageid']);
$this->assertEquals($newpagecontent, $version->content);
// Test edit section.
$newsectioncontent = '<h1>Title2</h1>New test2';
$section = 'Title2';
$result = mod_wiki_external::edit_page($newpage->id, $newsectioncontent, $section);
$result = external_api::clean_returnvalue(mod_wiki_external::edit_page_returns(), $result);
$this->assertInternalType('int', $result['pageid']);
$expected = $sectioncontent . $newsectioncontent;
$version = wiki_get_current_version($result['pageid']);
$this->assertEquals($expected, $version->content);
// Test locked section.
$newsectioncontent = '<h1>Title2</h1>New test2';
$section = 'Title2';
try {
// Using user 1 to avoid other users to edit.
wiki_set_lock($newpage->id, 1, $section, true);
mod_wiki_external::edit_page($newpage->id, $newsectioncontent, $section);
$this->fail('Exception expected due to locked section');
} catch (moodle_exception $e) {
$this->assertEquals('pageislocked', $e->errorcode);
}
// Test edit non existing section.
$newsectioncontent = '<h1>Title3</h1>New test3';
$section = 'Title3';
try {
mod_wiki_external::edit_page($newpage->id, $newsectioncontent, $section);
$this->fail('Exception expected due to non existing section in the page.');
} catch (moodle_exception $e) {
$this->assertEquals('invalidsection', $e->errorcode);
}
}
开发者ID:jackdaniels79,项目名称:moodle,代码行数:48,代码来源:externallib_test.php
示例3: wiki_action_content
function wiki_action_content(&$WS)
{
if ($WS->wikibookinfo) {
echo $WS->wikibookinfo->navibar;
}
$section = optional_param('section', '', PARAM_TEXT);
$sectionnum = optional_param('sectionnum', 0, PARAM_INTEGER);
$sectionhash = optional_param('sectionhash', '', PARAM_TEXT);
$preview = optional_param('dfformpreview', '', PARAM_TEXT);
$action = optional_param('dfformaction', '', PARAM_TEXT);
$sectionstring = '';
if ($section == '' && $sectionnum == 0) {
// main page
$section = '';
} else {
if ($action == 'edit' && $preview == '' && !wiki_is_uploading_modified()) {
$section = '';
} else {
$section = urldecode($section);
$sectionstring = strtolower(get_string('section', ''));
if ($preview != '' || wiki_is_uploading_modified()) {
$sectionstring = ' (' . $sectionstring . ' ' . $section . ')';
} else {
$sectionstring = ' (' . $sectionstring . ' ' . stripslashes($section) . ')';
}
}
}
//this is used for giving an appropiate format to the pagename when a simple id is given
if (is_numeric($WS->page)) {
echo '<h1>' . wiki_get_pagename_from_id($WS) . $sectionstring . '</h1>';
} else {
if (substr($WS->page, 0, strlen('discussion:')) == 'discussion:') {
echo '<h1>';
print_string('discussionabout', 'wiki');
$pagename = substr($WS->page, strlen('discussion:'), strlen($WS->page));
echo ': <i>' . format_text($pagename, FORMAT_PLAIN) . '</i></h1>';
} else {
if ($WS->pageaction == 'admin') {
echo '<h1>' . get_string("admin", "wiki") . ": " . format_text($WS->page, FORMAT_PLAIN) . $sectionstring . '</h1>';
} else {
if ($WS->wikibookinfo) {
echo '<h1>' . format_text($WS->wikibookinfo->title, FORMAT_PLAIN) . $sectionstring . '</h1>';
} else {
if ($WS->pageaction == 'info') {
echo '<h1>' . format_text($WS->page, FORMAT_PLAIN) . '</h1>' . '<h3>' . get_string('created_on', 'wiki') . ' ' . strftime('%A, %d %B %Y, %H:%M', $WS->pagedata->created);
if (wiki_grade_got_permission($WS)) {
// don't show the grade if the user hasn't permission
$grade = wiki_grade_get_wikigrade($WS);
echo '<br/>' . get_string('grade') . ': ' . $grade . '</h3>';
}
} else {
if ($section == '') {
echo '<h1>' . format_text($WS->page, FORMAT_PLAIN) . '</h1>';
} else {
if ($sectionhash != '') {
$stringhash = '&sectionhash=' . $sectionhash;
} else {
$stringhash = '';
}
$WS->pagedata->editor = 'htmleditor';
// force htmleditor - wysiwyg (nadavkav)
echo '<h1><a href="view.php?id=' . $WS->linkid . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '&page=view/' . urlencode($WS->page) . '&editor=' . $WS->pagedata->editor . $stringhash . '">' . format_text($WS->page, FORMAT_PLAIN) . '</a>' . $sectionstring . '</h1>';
}
}
}
}
}
}
print_box_start();
if ($sectionhash != '') {
$pagename = $WS->pagedata->pagename . '#' . $sectionhash;
} else {
$pagename = $WS->pagedata->pagename;
}
switch ($WS->pageaction) {
case 'view':
wiki_release_lock($WS, $WS->dfwiki->id, $pagename);
wiki_view_content($WS);
break;
case 'edit':
if (wiki_set_lock($WS)) {
wiki_edit_content($WS);
}
break;
case 'info':
wiki_release_lock($WS, $WS->dfwiki->id, $pagename);
wiki_info_content($WS);
break;
case 'discussion':
wiki_release_lock($WS, $WS->dfwiki->id, $pagename);
wiki_release_lock($WS, $WS->dfwiki->id, $WS->page);
wiki_view_content($WS);
break;
case 'editdiscussion':
if (wiki_set_lock($WS)) {
wiki_edit_content($WS);
}
break;
case 'adddiscussion':
wiki_release_lock($WS, $WS->dfwiki->id, $pagename);
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:locallib.php
示例4: get_page_for_editing
/**
* Locks and retrieves info of page-section to be edited.
*
* @param int $pageid The page ID.
* @param string $section Section page title.
* @return array of warnings and page data.
* @since Moodle 3.1
*/
public static function get_page_for_editing($pageid, $section = null)
{
global $USER;
$params = self::validate_parameters(self::get_page_for_editing_parameters(), array('pageid' => $pageid, '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_set_lock($params['pageid'], $USER->id, $params['section'], true)) {
throw new moodle_exception('pageislocked', 'wiki');
}
$version = wiki_get_current_version($page->id);
if (empty($version)) {
throw new moodle_exception('versionerror', 'wiki');
}
if (!is_null($params['section'])) {
$content = wiki_parser_proxy::get_section($version->content, $version->contentformat, $params['section']);
} else {
$content = $version->content;
}
$pagesection = array();
$pagesection['content'] = $content;
$pagesection['contentformat'] = $version->contentformat;
$pagesection['version'] = $version->version;
$result = array();
$result['pagesection'] = $pagesection;
$result['warnings'] = $warnings;
return $result;
}
开发者ID:jackdaniels79,项目名称:moodle,代码行数:53,代码来源:external.php
示例5: print_content
public function print_content() {
global $USER, $PAGE;
$context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->id);
require_capability('mod/wiki:editpage', $context, NULL, true, 'noeditpermission', 'wiki');
wiki_set_lock($this->page->id, $USER->id, $this->section);
}
开发者ID:nuckey,项目名称:moodle,代码行数:8,代码来源:pagelib.php
注:本文中的wiki_set_lock函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论