function __construct($chat) { global $DB; parent::__construct(); // Get course modules record $cm = $DB->get_record('course_modules', array('id' => $chat->cmid)); // Get course modules record $this->name = "[CHAT {$chat->cmid}:{$chat->name}]"; $this->chat_view = 'mod/chat/view.php'; $this->view_params = array('id' => $chat->cmid); if (!isset($chat->ajax) || !$chat->ajax) { $this->chat_post = 'mod/chat/gui_basic/index.php'; $this->post_params = array('id' => $chat->id); $this->posts = 5; $this->newonly = 0; $this->courseid = $cm->course; // Prepare all the regex's for insert into the post page hashtree $this->post_to_get = array('last', 'groupid', 'sesskey'); $post_regex = array(); foreach ($this->post_to_get as $name) { $post_regex[] = new regex("{$this->name} Get {$name}", $name, '<input.*?name="' . $name . '".*?value="(.*?)".*?\\/>'); } $this->post_regex = $post_regex; // Prepare the vars to post to the site $this->post_arguments = array('message' => $this->wordgenerator->getContent(10, 'txt'), 'id' => $chat->id); foreach ($this->post_to_get as $name) { $this->post_arguments[$name] = '${' . $name . '}'; } $this->chat_basic_startup(); } else { $this->chat_window = 'mod/chat/gui_ajax/index.php'; $this->window_params = array('id' => $chat->id); $this->window_regex = array(new regex("{$this->name} Get SID", 'chat_sid', '"sid":"(\\w+)"')); // chat init $this->chat_init = 'mod/chat/chat_ajax.php'; $this->init_params = array('action' => 'init', 'chat_init' => 1, 'chat_sid' => '${chat_sid}', 'theme' => 'undefined'); // post chat message $this->chat_post = 'mod/chat/chat_ajax.php?action=chat'; $this->post_params = array('chat_message' => $this->wordgenerator->getContent(10, 'txt'), 'chat_sid' => '${chat_sid}', 'theme' => 'compact'); // update chat $this->chat_update = 'mod/chat/chat_ajax.php?action=update'; $this->update_params = array('chat_lastrow' => 'false', 'chat_lasttime' => 0, 'chat_sid' => '${chat_sid}', 'theme' => 'compact'); $this->posts = 5; $this->courseid = $cm->course; // Prepare all the regex's for insert into the post page hashtree $this->post_to_get = array('lasttime', 'lastrow'); $post_regex = array(); foreach ($this->post_to_get as $name) { $post_regex[] = new regex("{$this->name} Get {$name}", 'chat_' . $name, '"' . $name . '":"(\\w+)"'); } $this->post_regex = $post_regex; // Prepare the vars to post to the site $this->post_update = array('chat_sid' => '${chat_sid}', 'theme' => 'compact'); foreach ($this->post_to_get as $name) { $this->post_update['chat_' . $name] = '${chat_' . $name . '}'; } $this->chat_ajax_startup(); } }
function __construct($glossary) { global $DB; parent::__construct(); // Get course modules record $cm = $DB->get_record('course_modules', array('id' => $glossary->cmid)); $this->name = "[GLOSSARY {$glossary->cmid}:{$glossary->name}]"; // Various URLs and base params $this->viewurl = 'mod/glossary/view.php'; $this->viewparams = array('id' => $cm->id); $this->addurl = 'mod/glossary/edit.php'; $this->addparams = array('cmid' => $cm->id); $this->deleteurl = 'mod/glossary/deleteentry.php'; $this->deleteparams = array('mode' => 'delete', 'id' => $cm->id, 'entry' => '${entryid}', 'prevmode' => '', 'hook' => 'ALL'); $this->confirmdeleteparams = $this->deleteparams; $this->confirmdeleteparams['confirm'] = 1; $search = array('[', ']'); $replace = array('\\[', '\\]'); // Regex for adding/editing the glossary entry $this->addargstoget = array('id', 'sesskey', '_qf__mod_glossary_entry_form', 'definition_editor[itemid]'); $addregex = array(); foreach ($this->addargstoget as $name) { $regex_name = str_replace($search, $replace, $name); $addregex[] = new regex("{$this->name} Get {$name}", $name, '<input.*?name="' . $regex_name . '".*?value="(.*?)".*?\\/>'); } $this->addregex = $addregex; $this->courseid = $cm->course; // Prepare the vars to post to the site $this->addargs = array('cmid' => $cm->id, 'MAX_FILE_SIZE' => 512000, 'definition_editor[text]' => $this->wordgenerator->getContent(50, 'html'), 'definition_editor[format]' => 1, 'usedynalink' => 1, 'submitbutton' => 'Save changes'); // Now add the regex to the add variables foreach ($this->addargstoget as $name) { $this->addargs[$name] = '${' . $name . '}'; } $this->addargs['definition[itemid]'] = '${definition_editor[itemid]}'; // The edit variables $this->editformargs = array('cmid' => $cm->id, 'id' => '${entryid}'); $this->editargs = $this->addargs; $this->editargs['id'] = '${entryid}'; $this->editargs['definition_editor[text]'] = $this->wordgenerator->getContent(50, 'html'); // Regex to get the glossary entry id from the returned URL $this->viewregex = array(); $this->viewregex[] = new regex("{$this->name} Get entryid", 'entryid', '^.*hook=(.*)[^0-9]?$', false, '$1$', false, 'URL'); if (isset($glossary->entries) && is_numeric($glossary->entries)) { $this->entries = $glossary->entries; } else { $this->entries = 5; } $this->glossary_startup(); }
function __construct($forum) { global $DB; parent::__construct(); // Get course modules record $cm = $DB->get_record('course_modules', array('id' => $forum->cmid)); $this->name = "[FORUM {$forum->cmid}:{$forum->name}]"; $this->forum_view = 'mod/forum/view.php'; $this->view_params = array('id' => $cm->id); $this->forum_post = 'mod/forum/post.php'; $this->post_params = array('forum' => $cm->instance); $this->posts = 1; $this->replys = 2; $this->courseid = $cm->course; // Prepare all the regex's for insert into the post page hashtree $this->post_to_get = array('message[itemid]', 'forum', 'discussion', 'parent', 'userid', 'groupid', 'edit', 'reply', 'timestart', 'timeend', 'sesskey', '_qf__mod_forum_post_form', 'course'); $post_regex = array(); $search = array('[', ']'); $replace = array('\\[', '\\]'); foreach ($this->post_to_get as $name) { $regex_name = str_replace($search, $replace, $name); $post_regex[] = new regex("{$this->name} Get {$name}", $name, '<input.*?name="' . $regex_name . '".*?value="(.*?)".*?\\/>'); } $this->post_regex = $post_regex; // Prepare the vars to post to the site $this->post_arguments = array('MAX_FILE_SIZE' => 512000, 'message[text]' => $this->wordgenerator->getContent(50, 'html'), 'message[format]' => 1, 'subscribe' => 0, 'submitbutton' => 'Post to forum'); foreach ($this->post_to_get as $name) { $this->post_arguments[$name] = '${' . $name . '}'; } $this->forum_discuss = 'mod/forum/discuss.php'; $this->discuss_params = array('d' => '${discussionid}'); $this->discuss_regex = array(new regex("{$this->name} Find random discussion", 'discussionid', 'discuss\\.php\\?d=(.+?)["\']>testing', '0')); $this->reply_regex = array(new regex("{$this->name} Find random reply", 'replyid', '\\/mod\\/forum\\/post\\.php\\?reply=([^\\\'"]*?)["\\\']', '0')); $this->reply_params = array('reply' => '${replyid}', 'draft' => 0); $this->forum_startup(); }