本文整理汇总了PHP中forum_move_attachments函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_move_attachments函数的具体用法?PHP forum_move_attachments怎么用?PHP forum_move_attachments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_move_attachments函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: print_error
if ($forumto->type == 'single') {
print_error('cannotmovetosingleforum', 'forum', $return);
}
// Get target forum cm and check it is visible to current user.
$modinfo = get_fast_modinfo($course);
$forums = $modinfo->get_instances_of('forum');
if (!array_key_exists($forumto->id, $forums)) {
print_error('cannotmovetonotfound', 'forum', $return);
}
$cmto = $forums[$forumto->id];
if (!$cmto->uservisible) {
print_error('cannotmovenotvisible', 'forum', $return);
}
$destinationctx = context_module::instance($cmto->id);
require_capability('mod/forum:startdiscussion', $destinationctx);
if (!forum_move_attachments($discussion, $forum->id, $forumto->id)) {
echo $OUTPUT->notification("Errors occurred while moving attachment directories - check your file permissions");
}
$DB->set_field('forum_discussions', 'forum', $forumto->id, array('id' => $discussion->id));
$DB->set_field('forum_read', 'forumid', $forumto->id, array('discussionid' => $discussion->id));
$params = array('context' => $destinationctx, 'objectid' => $discussion->id, 'other' => array('fromforumid' => $forum->id, 'toforumid' => $forumto->id));
$event = \mod_forum\event\discussion_moved::create($params);
$event->add_record_snapshot('forum_discussions', $discussion);
$event->add_record_snapshot('forum', $forum);
$event->add_record_snapshot('forum', $forumto);
$event->trigger();
// Delete the RSS files for the 2 forums to force regeneration of the feeds
require_once $CFG->dirroot . '/mod/forum/rsslib.php';
forum_rss_delete_file($forum);
forum_rss_delete_file($forumto);
redirect($return . '&moved=-1&sesskey=' . sesskey());
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:discuss.php
示例2: has_capability
$canviewdiscussion = has_capability('mod/forum:viewdiscussion', $modcontext);
if ($forum->type == "news") {
if (!($USER->id == $discussion->userid || ($discussion->timestart == 0 || $discussion->timestart <= time()) && ($discussion->timeend == 0 || $discussion->timeend > time()))) {
error('Discussion ID was incorrect or no longer exists', "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}");
}
}
if (!empty($move)) {
if (!($sourceforum = get_record('forum', 'id', $fromforum))) {
error('Cannot find which forum this discussion is being moved from');
}
if ($sourceforum->type == 'single') {
error('Cannot move discussion from a simple single discussion forum');
}
require_capability('mod/forum:movediscussions', $modcontext);
if ($forum = get_record("forum", "id", $move)) {
if (!forum_move_attachments($discussion, $move)) {
notify("Errors occurred while moving attachment directories - check your file permissions");
}
set_field("forum_discussions", "forum", $forum->id, "id", $discussion->id);
$discussion->forum = $forum->id;
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
add_to_log($course->id, "forum", "move discussion", "discuss.php?d={$discussion->id}", "{$discussion->id}", $cm->id);
} else {
add_to_log($course->id, "forum", "move discussion", "discuss.php?d={$discussion->id}", "{$discussion->id}");
}
$discussionmoved = true;
require_once 'rsslib.php';
require_once $CFG->libdir . '/rsslib.php';
// Delete the RSS files for the 2 forums because we want to force
// the regeneration of the feeds since the discussions have been
// moved.
开发者ID:njorth,项目名称:marginalia,代码行数:31,代码来源:discuss.php
注:本文中的forum_move_attachments函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论