本文整理汇总了PHP中lesson::add_message方法的典型用法代码示例。如果您正苦于以下问题:PHP lesson::add_message方法的具体用法?PHP lesson::add_message怎么用?PHP lesson::add_message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lesson
的用法示例。
在下文中一共展示了lesson::add_message方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: construction_override
public function construction_override($pageid, lesson $lesson)
{
global $CFG, $PAGE, $DB;
require_sesskey();
$timenow = time();
// the new page is not the first page (end of cluster always comes after an existing page)
if (!($page = $DB->get_record("lesson_pages", array("id" => $pageid)))) {
print_error('cannotfindpages', 'lesson');
}
// could put code in here to check if the user really can insert an end of cluster
$newpage = new stdClass();
$newpage->lessonid = $lesson->id;
$newpage->prevpageid = $pageid;
$newpage->nextpageid = $page->nextpageid;
$newpage->qtype = $this->qtype;
$newpage->timecreated = $timenow;
$newpage->title = get_string("endofclustertitle", "lesson");
$newpage->contents = get_string("endofclustertitle", "lesson");
$newpageid = $DB->insert_record("lesson_pages", $newpage);
// update the linked list...
$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid));
if ($page->nextpageid) {
// the new page is not the last page
$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid));
}
// ..and the single "answer"
$newanswer = new stdClass();
$newanswer->lessonid = $lesson->id;
$newanswer->pageid = $newpageid;
$newanswer->timecreated = $timenow;
$newanswer->jumpto = LESSON_NEXTPAGE;
$newanswerid = $DB->insert_record("lesson_answers", $newanswer);
$lesson->add_message(get_string('addedendofcluster', 'lesson'), 'notifysuccess');
redirect($CFG->wwwroot . '/mod/lesson/edit.php?id=' . $PAGE->cm->id);
}
示例2: construction_override
public function construction_override($pageid, lesson $lesson)
{
global $DB, $CFG, $PAGE;
require_sesskey();
// first get the preceeding page
$timenow = time();
// the new page is not the first page (end of branch always comes after an existing page)
if (!($page = $DB->get_record("lesson_pages", array("id" => $pageid)))) {
print_error('cannotfindpagerecord', 'lesson');
}
// chain back up to find the (nearest branch table)
$btpage = clone $page;
$btpageid = $btpage->id;
while ($btpage->qtype != LESSON_PAGE_BRANCHTABLE && $btpage->prevpageid > 0) {
$btpageid = $btpage->prevpageid;
if (!($btpage = $DB->get_record("lesson_pages", array("id" => $btpageid)))) {
print_error('cannotfindpagerecord', 'lesson');
}
}
if ($btpage->qtype == LESSON_PAGE_BRANCHTABLE) {
$newpage = new stdClass();
$newpage->lessonid = $lesson->id;
$newpage->prevpageid = $pageid;
$newpage->nextpageid = $page->nextpageid;
$newpage->qtype = $this->qtype;
$newpage->timecreated = $timenow;
$newpage->title = get_string("endofbranch", "lesson");
$newpage->contents = get_string("endofbranch", "lesson");
$newpageid = $DB->insert_record("lesson_pages", $newpage);
// update the linked list...
$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid));
if ($page->nextpageid) {
// the new page is not the last page
$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid));
}
// ..and the single "answer"
$newanswer = new stdClass();
$newanswer->lessonid = $lesson->id;
$newanswer->pageid = $newpageid;
$newanswer->timecreated = $timenow;
$newanswer->jumpto = $btpageid;
$newanswerid = $DB->insert_record("lesson_answers", $newanswer);
$lesson->add_message(get_string('addedanendofbranch', 'lesson'), 'notifysuccess');
} else {
$lesson->add_message(get_string('nobranchtablefound', 'lesson'));
}
redirect($CFG->wwwroot . "/mod/lesson/edit.php?id=" . $PAGE->cm->id);
}
示例3: trim
switch ($mode) {
case 'add':
// Ensure that we came from view.php
if (!confirm_sesskey() or !data_submitted()) {
print_error('invalidformdata');
}
break;
case 'save':
if (confirm_sesskey() and $form = data_submitted($CFG->wwwroot.'/mod/lesson/view.php')) {
$name = trim(optional_param('name', '', PARAM_CLEAN));
// Make sure it is not empty
if (empty($name)) {
$lesson->add_message(get_string('missingname', 'lesson'));
$mode = 'add';
break;
}
// Check for censored words
$filterwords = explode(',', get_string('censorbadwords'));
foreach ($filterwords as $filterword) {
if (strstr($name, $filterword)) {
$lesson->add_message(get_string('namereject', 'lesson'));
$mode = 'add';
break;
}
}
// Bad word was found
if ($mode == 'add') {
break;
示例4: construction_override
public function construction_override($pageid, lesson $lesson)
{
global $PAGE, $CFG, $DB;
require_sesskey();
$timenow = time();
if ($pageid == 0) {
if ($lesson->has_pages()) {
if (!($page = $DB->get_record("lesson_pages", array("prevpageid" => 0, "lessonid" => $lesson->id)))) {
print_error('cannotfindpagerecord', 'lesson');
}
} else {
// This is the ONLY page
$page = new stdClass();
$page->id = 0;
}
} else {
if (!($page = $DB->get_record("lesson_pages", array("id" => $pageid)))) {
print_error('cannotfindpagerecord', 'lesson');
}
}
$newpage = new stdClass();
$newpage->lessonid = $lesson->id;
$newpage->prevpageid = $pageid;
if ($pageid != 0) {
$newpage->nextpageid = $page->nextpageid;
} else {
$newpage->nextpageid = $page->id;
}
$newpage->qtype = $this->qtype;
$newpage->timecreated = $timenow;
$newpage->title = get_string("clustertitle", "lesson");
$newpage->contents = get_string("clustertitle", "lesson");
$newpageid = $DB->insert_record("lesson_pages", $newpage);
// update the linked list...
if ($pageid != 0) {
$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid));
}
if ($pageid == 0) {
$page->nextpageid = $page->id;
}
if ($page->nextpageid) {
// the new page is not the last page
$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid));
}
// ..and the single "answer"
$newanswer = new stdClass();
$newanswer->lessonid = $lesson->id;
$newanswer->pageid = $newpageid;
$newanswer->timecreated = $timenow;
$newanswer->jumpto = LESSON_CLUSTERJUMP;
$newanswerid = $DB->insert_record("lesson_answers", $newanswer);
$lesson->add_message(get_string('addedcluster', 'lesson'), 'notifysuccess');
redirect($CFG->wwwroot . '/mod/lesson/edit.php?id=' . $PAGE->cm->id);
}