本文整理汇总了PHP中wiki_delete_comment函数的典型用法代码示例。如果您正苦于以下问题:PHP wiki_delete_comment函数的具体用法?PHP wiki_delete_comment怎么用?PHP wiki_delete_comment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wiki_delete_comment函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wiki_delete_pages
/**
* Delete pages and all related data
*
* @param mixed $context context in which page needs to be deleted.
* @param mixed $pageids id's of pages to be deleted
* @param int $subwikiid id of the subwiki for which all pages should be deleted
*/
function wiki_delete_pages($context, $pageids = null, $subwikiid = null)
{
global $DB;
if (!empty($pageids) && is_int($pageids)) {
$pageids = array($pageids);
} else {
if (!empty($subwikiid)) {
$pageids = wiki_get_page_list($subwikiid);
}
}
//If there is no pageid then return as we can't delete anything.
if (empty($pageids)) {
return;
}
/// Delete page and all it's relevent data
foreach ($pageids as $pageid) {
if (is_object($pageid)) {
$pageid = $pageid->id;
}
//Delete page comments
$comments = wiki_get_comments($context->id, $pageid);
foreach ($comments as $commentid => $commentvalue) {
wiki_delete_comment($commentid, $context, $pageid);
}
//Delete page tags
$tags = tag_get_tags_array('wiki_pages', $pageid);
foreach ($tags as $tagid => $tagvalue) {
tag_delete_instance('wiki_pages', $pageid, $tagid);
}
//Delete Synonym
wiki_delete_synonym($subwikiid, $pageid);
//Delete all page versions
wiki_delete_page_versions(array($pageid => array(0)));
//Delete all page locks
wiki_delete_locks($pageid);
//Delete all page links
wiki_delete_links(null, $pageid);
//Delete page
$params = array('id' => $pageid);
$DB->delete_records('wiki_pages', $params);
}
}
示例2: delete_comment
private function delete_comment($commentid) {
global $CFG, $PAGE;
$pageid = $this->page->id;
wiki_delete_comment($commentid, $this->modcontext, $pageid);
}
示例3: test_comment_deleted
/**
* Test comment_deleted event.
*/
public function test_comment_deleted()
{
$this->setUp();
$page = $this->wikigenerator->create_first_page($this->wiki);
$context = context_module::instance($this->wiki->cmid);
// Add comment so we can delete it later.
wiki_add_comment($context, $page->id, 'Test comment', 'html');
$comment = wiki_get_comments($context->id, $page->id);
$this->assertCount(1, $comment);
$comment = array_shift($comment);
// Triggering and capturing the event.
$sink = $this->redirectEvents();
wiki_delete_comment($comment->id, $context, $page->id);
$events = $sink->get_events();
$this->assertCount(1, $events);
$event = reset($events);
// Checking that the event contains the expected values.
$this->assertInstanceOf('\\mod_wiki\\event\\comment_deleted', $event);
$this->assertEquals($context, $event->get_context());
$this->assertEquals($page->id, $event->other['itemid']);
$this->assertEventContextNotUsed($event);
}
示例4: wiki_delete_pages
/**
* Delete pages and all related data
*
* @param mixed $context context in which page needs to be deleted.
* @param mixed $pageids id's of pages to be deleted
* @param int $subwikiid id of the subwiki for which all pages should be deleted
*/
function wiki_delete_pages($context, $pageids = null, $subwikiid = null)
{
global $DB, $CFG;
if (!empty($pageids) && is_int($pageids)) {
$pageids = array($pageids);
} else {
if (!empty($subwikiid)) {
$pageids = wiki_get_page_list($subwikiid);
}
}
//If there is no pageid then return as we can't delete anything.
if (empty($pageids)) {
return;
}
/// Delete page and all it's relevent data
foreach ($pageids as $pageid) {
if (is_object($pageid)) {
$pageid = $pageid->id;
}
//Delete page comments
$comments = wiki_get_comments($context->id, $pageid);
foreach ($comments as $commentid => $commentvalue) {
wiki_delete_comment($commentid, $context, $pageid);
}
//Delete page tags
core_tag_tag::remove_all_item_tags('mod_wiki', 'wiki_pages', $pageid);
//Delete Synonym
wiki_delete_synonym($subwikiid, $pageid);
//Delete all page versions
wiki_delete_page_versions(array($pageid => array(0)), $context);
//Delete all page locks
wiki_delete_locks($pageid);
//Delete all page links
wiki_delete_links(null, $pageid);
$params = array('id' => $pageid);
// Get page before deleting.
$page = $DB->get_record('wiki_pages', $params);
//Delete page
$DB->delete_records('wiki_pages', $params);
// Trigger page_deleted event.
$event = \mod_wiki\event\page_deleted::create(array('context' => $context, 'objectid' => $pageid, 'other' => array('subwikiid' => $subwikiid)));
$event->add_record_snapshot('wiki_pages', $page);
$event->trigger();
}
}
示例5: delete_comment
private function delete_comment($commentid) {
global $CFG, $PAGE;
$cm = $PAGE->cm;
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$pageid = $this->page->id;
wiki_delete_comment($commentid, $context, $pageid);
}