';
-print skip_main_destination();
+print $OUTPUT->skip_link_target();
+
+// Renderer hook so extra info can be added to global blog pages in theme.
+echo $oublogoutput->render_viewpage_prepost();
// Print blog posts.
if ($posts) {
@@ -162,9 +190,9 @@
// them know if there are no posts in the blog.
if (!isloggedin() || isguestuser()) {
print '
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
diff --git a/db/services.php b/db/services.php
new file mode 100644
index 0000000..21db646
--- /dev/null
+++ b/db/services.php
@@ -0,0 +1,69 @@
+.
+
+/**
+ * Web service definition.
+ *
+ * @package mod_oublog
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$functions = array(
+ 'mod_oublog_get_user_blogs' => array(
+ 'classname' => 'mod_oublog_external',
+ 'methodname' => 'get_user_blogs',
+ 'classpath' => 'mod/oublog/externallib.php',
+ 'description' => 'Get all user\'s blogs on system',
+ 'type' => 'read',
+ ),
+ 'mod_oublog_get_blog_info' => array(
+ 'classname' => 'mod_oublog_external',
+ 'methodname' => 'get_blog_info',
+ 'classpath' => 'mod/oublog/externallib.php',
+ 'description' => 'Get info on blog, inc access check',
+ 'type' => 'read',
+ ),
+ 'mod_oublog_get_blog_allposts' => array(
+ 'classname' => 'mod_oublog_external',
+ 'methodname' => 'get_blog_allposts',
+ 'classpath' => 'mod/oublog/externallib.php',
+ 'description' => 'Get importable user posts from blog',
+ 'type' => 'read',
+ ),
+ 'mod_oublog_get_blog_posts' => array(
+ 'classname' => 'mod_oublog_external',
+ 'methodname' => 'get_blog_posts',
+ 'classpath' => 'mod/oublog/externallib.php',
+ 'description' => 'Get selected user posts from blog',
+ 'type' => 'read',
+ ),
+
+);
+
+$services = array(
+ 'OUBlog import' => array(
+ 'shortname' => 'oublogimport',
+ 'functions' => array ('mod_oublog_get_user_blogs', 'mod_oublog_get_blog_info',
+ 'mod_oublog_get_blog_allposts', 'mod_oublog_get_blog_posts'),
+ 'requiredcapability' => '',
+ 'restrictedusers' => 1,
+ 'enabled' => 1,
+ 'downloadfiles' => 1
+ )
+);
diff --git a/db/upgrade.php b/db/upgrade.php
index bd27cbb..3ec4adc 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -154,5 +154,104 @@ function xmldb_oublog_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2013101000, 'oublog');
}
+ if ($oldversion < 2013102800) {
+
+ // Define field displayname to be added to oublog.
+ $table = new xmldb_table('oublog');
+ $field = new xmldb_field('displayname', XMLDB_TYPE_CHAR, '255', null, null, null, null,
+ 'reportingemail');
+
+ // Conditionally launch add field displayname.
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ // Oublog savepoint reached.
+ upgrade_mod_savepoint(true, 2013102800, 'oublog');
+ }
+
+ if ($oldversion < 2013102801) {
+
+ // Define field statblockon to be added to oublog.
+ $table = new xmldb_table('oublog');
+ $field = new xmldb_field('statblockon', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'displayname');
+
+ // Conditionally launch add field statblockon.
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+ upgrade_mod_savepoint(true, 2013102801, 'oublog');
+ }
+
+ if ($oldversion < 2013121100) {
+ // Numerous keys and indexes added.
+ // Define key oublog_posts_groupid_groups_fk (foreign) to be added to oublog_posts.
+ $table = new xmldb_table('oublog_posts');
+ $key = new xmldb_key('oublog_posts_groupid_groups_fk', XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
+
+ // Launch add key oublog_posts_groupid_groups_fk.
+ $dbman->add_key($table, $key);
+
+ // Define index allowcomments (not unique) to be added to oublog_posts.
+ $table = new xmldb_table('oublog_posts');
+ $index = new xmldb_index('allowcomments', XMLDB_INDEX_NOTUNIQUE, array('allowcomments'));
+
+ // Conditionally launch add index allowcomments.
+ if (!$dbman->index_exists($table, $index)) {
+ $dbman->add_index($table, $index);
+ }
+
+ // Define index visibility (not unique) to be added to oublog_posts.
+ $table = new xmldb_table('oublog_posts');
+ $index = new xmldb_index('visibility', XMLDB_INDEX_NOTUNIQUE, array('visibility'));
+
+ // Conditionally launch add index visibility.
+ if (!$dbman->index_exists($table, $index)) {
+ $dbman->add_index($table, $index);
+ }
+
+ // Define index timeposted (not unique) to be added to oublog_comments.
+ $table = new xmldb_table('oublog_comments');
+ $index = new xmldb_index('timeposted', XMLDB_INDEX_NOTUNIQUE, array('timeposted'));
+
+ // Conditionally launch add index timeposted.
+ if (!$dbman->index_exists($table, $index)) {
+ $dbman->add_index($table, $index);
+ }
+
+ // Oublog savepoint reached.
+ upgrade_mod_savepoint(true, 2013121100, 'oublog');
+ }
+
+ if ($oldversion < 2014012702) {
+
+ // Define field allowimport to be added to oublog.
+ $table = new xmldb_table('oublog');
+ $field = new xmldb_field('allowimport', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'statblockon');
+
+ // Conditionally launch add field allowimport.
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ // Oublog savepoint reached.
+ upgrade_mod_savepoint(true, 2014012702, 'oublog');
+ }
+
+ if ($oldversion < 2014042400) {
+
+ // Define field introonpost to be added to oublog.
+ $table = new xmldb_table('oublog');
+ $field = new xmldb_field('introonpost', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'allowimport');
+
+ // Conditionally launch add field introonpost.
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ // Oublog savepoint reached.
+ upgrade_mod_savepoint(true, 2014042400, 'oublog');
+ }
+
return true;
}
diff --git a/deletecomment.php b/deletecomment.php
index 0abcc5e..1893e3a 100644
--- a/deletecomment.php
+++ b/deletecomment.php
@@ -49,7 +49,7 @@
$PAGE->set_url($url);
// Check security.
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
oublog_check_view_permissions($oublog, $context, $cm);
// You can always delete your own comments, or any comment on your own
diff --git a/deletelink.php b/deletelink.php
index f6c455a..f26b3ee 100644
--- a/deletelink.php
+++ b/deletelink.php
@@ -45,7 +45,7 @@
$PAGE->set_url($url);
// Check security.
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
oublog_check_view_permissions($oublog, $context, $cm);
$oubloginstance = $link->oubloginstancesid ? $DB->get_record('oublog_instances', array('id'=>$link->oubloginstancesid)) : null;
diff --git a/deletepost.php b/deletepost.php
index c52b38e..5f08c80 100644
--- a/deletepost.php
+++ b/deletepost.php
@@ -20,27 +20,33 @@
* @package oublog
*/
require_once("../../config.php");
-require_once("locallib.php");
+require_once($CFG->dirroot . '/mod/oublog/locallib.php');
require_once($CFG->libdir . '/completionlib.php');
-$blog = required_param('blog', PARAM_INT); // Blog ID
-$postid = required_param('post', PARAM_INT); // Post ID for editing
-$confirm = optional_param('confirm', 0, PARAM_INT); // Confirm that it is ok to delete post
+$blog = required_param('blog', PARAM_INT); // Blog ID.
+$postid = required_param('post', PARAM_INT); // Post ID for editing.
+$confirm = optional_param('confirm', 0, PARAM_INT);// Confirm that it is ok to delete post.
+$delete = optional_param('delete', 0, PARAM_INT);
+$email = optional_param('email', 0, PARAM_INT); // Email author.
if (!$oublog = $DB->get_record("oublog", array("id"=>$blog))) {
print_error('invalidblog', 'oublog');
}
+if (!$post = oublog_get_post($postid, false)) {
+ print_error('invalidpost', 'oublog');
+}
if (!$cm = get_coursemodule_from_instance('oublog', $blog)) {
print_error('invalidcoursemodule');
}
if (!$course = $DB->get_record("course", array("id"=>$oublog->course))) {
print_error('coursemisconf');
}
-$url = new moodle_url('/mod/oublog/deletepost.php', array('blog'=>$blog, 'post'=>$postid, 'confirm'=>$confirm));
+$url = new moodle_url('/mod/oublog/deletepost.php',
+ array('blog' => $blog, 'post' => $postid, 'confirm' => $confirm));
$PAGE->set_url($url);
// Check security.
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
oublog_check_view_permissions($oublog, $context, $cm);
$postauthor=$DB->get_field_sql("
@@ -54,57 +60,205 @@
require_capability('mod/oublog:manageposts', $context);
}
+$oublogoutput = $PAGE->get_renderer('mod_oublog');
+
if ($oublog->global) {
$blogtype = 'personal';
$oubloguser = $USER;
- $viewurl = new moodle_url('/mod/oublog/view.php', array('user'=>$USER->id));
+ $viewurl = new moodle_url('/mod/oublog/view.php', array('user' => $USER->id));
+ // Print the header.
+ $PAGE->navbar->add(fullname($oubloguser), new moodle_url('/user/view.php',
+ array('id' => $oubloguser->id)));
+ $PAGE->navbar->add(format_string($oublog->name));
} else {
$blogtype = 'course';
- $viewurl = new moodle_url('/mod/oublog/view.php', array('id'=>$cm->id));
+ $viewurl = new moodle_url('/mod/oublog/view.php', array('id' => $cm->id));
}
-if (!empty($postid) && !empty($confirm)) {
- $expost=$DB->get_record('oublog_posts', array('id'=>$postid));
+if ($email) {
+ // Then open and process the form.
+ require_once($CFG->dirroot . '/mod/oublog/deletepost_form.php');
+ $customdata = (object)array('blog' => $blog, 'post' => $postid,
+ 'delete' => $delete, 'email' => $email, 'url' => $viewurl);
+ $mform = new mod_oublog_deletepost_form('deletepost.php', $customdata);
+ if ($mform->is_cancelled()) {
+ // Form is cancelled, redirect back to the blog.
+ redirect($viewurl);
+ } else if ($submitted = $mform->get_data()) {
+ // Mark the post as deleted.
+ oublog_do_delete($course, $cm, $oublog, $post);
+ // We need these for the call to render post.
+ $canaudit = $canmanageposts = false;
+
+ // Store copy of the post for the author.
+ // If subject is set in this post, use it.
+ if (!isset($post->title) || empty($post->title)) {
+ $post->title = get_string('deletedblogpost', 'oublog');
+ }
+ $messagepost = $oublogoutput->render_post($cm, $oublog, $post, $viewurl, $blogtype,
+ $canmanageposts, $canaudit, false, false, false, true);
+
+ // Set up the email message detail.
+ $messagetext = $submitted->message['text'];
+ $copyself = (isset($submitted->copyself)) ? true : false;
+ $includepost = (isset($submitted->includepost)) ? true : false;
+ $from = $SITE->fullname;
+
+ // Always send HTML version.
+ $user = (object)array(
+ 'email' => $post->email,
+ 'mailformat' => 1,
+ 'id' => $post->userid
+ );
+
+ $messagehtml = text_to_html($messagetext);
+ // Include the copy of the post in the email to the author.
+ if ($includepost) {
+ $messagehtml .= $messagepost;
+ }
+ // Send an email to the author of the post.
+ if (!email_to_user($user, $from, $post->title, '', $messagehtml)) {
+ print_error(get_string('emailerror', 'oublog'));
+ }
+ // Prepare for copies.
+ $emails = $selfmail = array();
+ if ($copyself) {
+ $selfmail[] = $USER->email;
+ }
+ // Addition of 'Email address of other recipients'.
+ if (!empty($submitted->emailadd)) {
+ $emails = preg_split('~[; ]+~', $submitted->emailadd);
+ }
+ $emails = array_merge($emails, $selfmail);
+
+ // If there are any recipients listed send them a copy.
+ if (!empty($emails[0])) {
+ $subject = strtoupper(get_string('copy')) . ' - '. $post->title;
+ foreach ($emails as $email) {
+ $fakeuser = (object)array(
+ 'email' => $email,
+ 'mailformat' => 1,
+ 'id' => -1
+ );
+ if (!email_to_user($fakeuser, $from, $subject, '', $messagehtml)) {
+ print_error(get_string('emailerror', 'oublog'));
+ }
+ }
+ }
+ redirect($viewurl);
+ } else if (($delete && $email) ) {
+ // If subject is set in this post, use it.
+ if (!isset($post->title) || empty($post->title)) {
+ $post->title = get_string('deletedblogpost', 'oublog');
+ }
+ $displayname = oublog_get_displayname($oublog, true);
+ // Prepare the object for the emailcontenthtml get_string.
+ $emailmessage = new stdClass;
+ $emailmessage->subject = $post->title;
+ $emailmessage->blog = $oublog->name;
+ $emailmessage->activityname = $displayname;
+ $emailmessage->firstname = $USER->firstname;
+ $emailmessage->lastname = $USER->lastname;
+ $emailmessage->course = $COURSE->fullname;
+ $emailmessage->deleteurl = $CFG->wwwroot . '/mod/oublog/viewpost.php?&post=' . $post->id;
+ $formdata = new stdClass;
+ $messagetext = get_string('emailcontenthtml', 'oublog', $emailmessage);
+ $formdata->message['text'] = $messagetext;
+ // Display the form.
+ echo $OUTPUT->header();
+ $mform->set_data($formdata);
+ $mform->display();
+ }
+} else {
+ if (!$confirm) {
+ $PAGE->set_title(format_string($oublog->name));
+ $PAGE->set_heading(format_string($course->fullname));
+ echo $OUTPUT->header();
+ $confirmdeletestring = get_string('confirmdeletepost', 'oublog');
+ $confirmstring = get_string('deleteemailpostdescription', 'oublog');
+
+ $deletebutton = new single_button(new moodle_url('/mod/oublog/deletepost.php',
+ array('blog' => $blog, 'post' => $postid, 'delete' => '1',
+ 'confirm' => '1')), get_string('delete'), 'post');
+ $cancelbutton = new single_button($viewurl, get_string('cancel'), 'get');
+
+ if ($USER->id == $post->userid) {
+ print $OUTPUT->confirm($confirmdeletestring, $deletebutton, $cancelbutton);
+ } else {
+ // Delete - Delete and email || Cancel.
+ $deleteemailbutton = new single_button(new moodle_url('/mod/oublog/deletepost.php',
+ array('blog' => $blog, 'post' => $postid, 'email' => '1', 'delete' => '1')),
+ get_string('deleteemailpostbutton', 'oublog'), 'post');
+ print oublog_three_button($confirmstring,
+ $deletebutton,
+ $deleteemailbutton,
+ $cancelbutton);
+ }
+ } else {
+ // Mark the post as deleted.
+ oublog_do_delete($course, $cm, $oublog, $post);
+ redirect($viewurl);
+ }
+}
+
+echo $OUTPUT->footer();
+
+function oublog_do_delete($course, $cm, $oublog, $post) {
+ global $DB, $USER;
$updatepost = (object)array(
- 'id' => $postid,
- 'deletedby' => $USER->id,
- 'timedeleted' => time()
+ 'id' => $post->id,
+ 'deletedby' => $USER->id,
+ 'timedeleted' => time()
);
- $tw=new transaction_wrapper();
+ $transaction = $DB->start_delegated_transaction();
$DB->update_record('oublog_posts', $updatepost);
- if (!oublog_update_item_tags($expost->oubloginstancesid, $expost->id, array(), $expost->visibility)) {
- $tw->rollback();
+ if (!oublog_update_item_tags($post->oubloginstancesid, $post->id,
+ array(), $post->visibility)) {
print_error('tagupdatefailed', 'oublog');
}
if (oublog_search_installed()) {
- $doc=oublog_get_search_document($updatepost, $cm);
+ $doc = oublog_get_search_document($updatepost, $cm);
$doc->delete();
}
// Inform completion system, if available.
$completion = new completion_info($course);
if ($completion->is_enabled($cm) && ($oublog->completionposts)) {
- $completion->update_state($cm, COMPLETION_INCOMPLETE, $postauthor);
+ $completion->update_state($cm, COMPLETION_INCOMPLETE, $post->userid);
}
- $tw->commit();
- redirect($viewurl);
- exit;
+ $transaction->allow_commit();
}
-// Get Strings.
-$stroublogs = get_string('modulenameplural', 'oublog');
-$stroublog = get_string('modulename', 'oublog');
+/**
+ * Print a message along with three buttons buttoneone/buttontwo/Cancel
+ *
+ * If a string or moodle_url is given instead of a single_button, method defaults to post.
+ *
+ * @param string $message The question to ask the user.
+ * @param single_button $buttonone The single_button component representing the buttontwo response.
+ * @param single_button $buttontwo The single_button component representing the buttontwo response.
+ * @param single_button $cancel The single_button component representing the Cancel response.
+ * @return string HTML fragment
+ */
+function oublog_three_button($message, $buttonone, $buttontwo, $cancel) {
+ global $OUTPUT;
+ if (!($buttonone instanceof single_button)) {
+ throw new coding_exception('The buttonone param must be an instance of a single_button.');
+ }
+
+ if (!($buttontwo instanceof single_button)) {
+ throw new coding_exception('The buttontwo param must be an instance of a single_button.');
+ }
-// Print the header
+ if (!($cancel instanceof single_button)) {
+ throw new coding_exception('The cancel param must be an instance of a single_button.');
+ }
-if ($blogtype == 'personal') {
- $PAGE->navbar->add(fullname($oubloguser), new moodle_url('/user/view.php', array('id'=>$oubloguser->id)));
- $PAGE->navbar->add(format_string($oublog->name));
+ $output = $OUTPUT->box_start('generalbox', 'notice');
+ $output .= html_writer::tag('p', $message);
+ $buttons = $OUTPUT->render($buttonone) . $OUTPUT->render($buttontwo) . $OUTPUT->render($cancel);
+ $output .= html_writer::tag('div', $buttons, array('class' => 'buttons'));
+ $output .= $OUTPUT->box_end();
+ return $output;
}
-$PAGE->set_title(format_string($oublog->name));
-$PAGE->set_heading(format_string($course->fullname));
-echo $OUTPUT->header();
-echo $OUTPUT->confirm(get_string('confirmdeletepost', 'oublog'),
- new moodle_url('/mod/oublog/deletepost.php', array('blog'=>$blog, 'post'=>$postid, 'confirm'=>'1')),
- $viewurl);
diff --git a/deletepost_form.php b/deletepost_form.php
new file mode 100644
index 0000000..ffb9883
--- /dev/null
+++ b/deletepost_form.php
@@ -0,0 +1,91 @@
+.
+
+require_once($CFG->libdir.'/formslib.php');
+
+/**
+ * Form for sending an email to the author of a post when deleting
+ * @package mod
+ * @subpackage oublog
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class mod_oublog_deletepost_form extends moodleform {
+
+ public function definition() {
+ $mform =& $this->_form;
+
+ // Header.
+ $mform->addElement('header', 'general', get_string('deleteandemail', 'oublog'));
+
+ // Message box.
+ $mform->addElement('editor', 'message',
+ get_string('emailmessage', 'oublog'), array('size'=>'64', 'id' => 'id_oublog_delete_msg'));
+ $mform->setType('message', PARAM_RAW);
+ $mform->addRule('message', null, 'required', null, 'client');
+
+ // Send a copy to self.
+ $mform->addElement('checkbox', 'copyself', get_string('copytoself', 'oublog'));
+
+ // Adding optional text field 'Email address of other recipients'.
+ $mform->addElement('text', 'emailadd', get_string('extra_emails', 'oublog'),
+ array('size' => '48'));
+ $mform->addHelpButton('emailadd', 'extra_emails', 'oublog');
+ $mform->setType('emailadd', PARAM_RAW);
+
+ // Include a copy of the post.
+ $mform->addElement('checkbox', 'includepost', get_string('includepost', 'oublog'));
+
+ // Hidden fields for return url.
+ $mform->addElement('hidden', 'blog', $this->_customdata->blog);
+ $mform->setType('blog', PARAM_INT);
+
+ $mform->addElement('hidden', 'post', $this->_customdata->post);
+ $mform->setType('post', PARAM_INT);
+
+ $mform->addElement('hidden', 'email', $this->_customdata->email);
+ $mform->setType('email', PARAM_INT);
+
+ $mform->addElement('hidden', 'delete', $this->_customdata->delete);
+ $mform->setType('delete', PARAM_INT);
+
+ $mform->addElement('hidden', 'confirm', 1);
+ $mform->setType('confirm', PARAM_INT);
+
+ // Add some buttons.
+ $this->add_action_buttons(true, get_string('sendanddelete', 'oublog'));
+
+ }
+
+ public function validation($data, $files) {
+ $errors = parent::validation($data, $files);
+ if (!empty($data['emailadd'])) {
+ $emails = preg_split('~[; ]+~', $data['emailadd']);
+ if (count($emails) < 1) {
+ $errors['emailadd'] = get_string('invalidemails', 'forumng');
+ } else {
+ foreach ($emails as $email) {
+ if (!validate_email($email)) {
+ $errors['emailadd'] = get_string('invalidemails', 'forumng');
+ break;
+ }
+ }
+ }
+ }
+ return $errors;
+ }
+
+}
diff --git a/editcomment.php b/editcomment.php
index eb61124..0a08198 100644
--- a/editcomment.php
+++ b/editcomment.php
@@ -39,7 +39,7 @@
if (!$course = $DB->get_record("course", array("id"=>$oublog->course))) {
print_error('coursemisconf');
}
-if (!$post = $DB->get_record('oublog_posts', array('id'=>$postid))) {
+if (!$post = oublog_get_post($postid)) {
print_error('invalidpost', 'oublog');
}
if (!$oubloginstance = $DB->get_record('oublog_instances', array('id'=>$post->oubloginstancesid))) {
@@ -49,7 +49,7 @@
$PAGE->set_url($url);
// Check security.
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
oublog_check_view_permissions($oublog, $context, $cm);
$post->userid=$oubloginstance->userid; // oublog_can_view_post needs this
@@ -76,6 +76,8 @@
$blogtype = 'course';
}
+$renderer = $PAGE->get_renderer('mod_oublog');
+
// Get strings.
$stroublogs = get_string('modulenameplural', 'oublog');
$stroublog = get_string('modulename', 'oublog');
@@ -92,7 +94,8 @@
'postid' => $postid,
'moderated' => $moderated,
'confirmed' => $confirmed,
- 'maxbytes' => $oublog->maxbytes
+ 'maxbytes' => $oublog->maxbytes,
+ 'postrender' => $renderer->render_post($cm, $oublog, $post, $url, $blogtype, false, false, false, false, false, true),
));
if ($mform->is_cancelled()) {
diff --git a/editinstance.php b/editinstance.php
index 1ad664c..1e269ef 100644
--- a/editinstance.php
+++ b/editinstance.php
@@ -53,7 +53,7 @@
$url = new moodle_url('/mod/oublog/editinstance.php', array('instance'=>$bloginstancesid, 'post'=>$postid));
$PAGE->set_url($url);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
oublog_check_view_permissions($oublog, $context, $cm);
$oubloguser = $DB->get_record('user', array('id'=>$oubloginstance->userid));
$viewurl = 'view.php?user='.$oubloginstance->userid;
@@ -65,7 +65,6 @@
// Get strings.
$stroublogs = get_string('modulenameplural', 'oublog');
$stroublog = get_string('modulename', 'oublog');
-$straddpost = get_string('newpost', 'oublog');
$streditpost = get_string('editpost', 'oublog');
$strblogoptions = get_string('blogoptions', 'oublog');
diff --git a/editlink.php b/editlink.php
index 9c527b7..0e36d73 100644
--- a/editlink.php
+++ b/editlink.php
@@ -50,7 +50,7 @@
$PAGE->set_url($url);
// Check security.
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
oublog_check_view_permissions($oublog, $context, $cm);
if ($linkid) {
diff --git a/editpost.php b/editpost.php
index 96404f4..4fd6763 100644
--- a/editpost.php
+++ b/editpost.php
@@ -50,12 +50,13 @@
$url = new moodle_url('/mod/oublog/editpost.php', array('blog'=>$blog, 'post'=>$postid));
$PAGE->set_url($url);
-$PAGE->requires->js_init_call('M.mod_oublog.init', null, true);
// Check security.
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
oublog_check_view_permissions($oublog, $context, $cm);
+$PAGE->requires->js_init_call('M.mod_oublog.init', null, true);
+
if ($oublog->global) {
$blogtype = 'personal';
@@ -94,7 +95,7 @@
// Get strings.
$stroublogs = get_string('modulenameplural', 'oublog');
$stroublog = get_string('modulename', 'oublog');
-$straddpost = get_string('newpost', 'oublog');
+$straddpost = get_string('newpost', 'oublog', oublog_get_displayname($oublog));
$streditpost = get_string('editpost', 'oublog');
@@ -111,7 +112,8 @@
'allowcomments' => $oublog->allowcomments,
'edit' => !empty($postid),
'personal' => $oublog->global,
- 'maxbytes' => $oublog->maxbytes));
+ 'maxbytes' => $oublog->maxbytes,
+ 'maxattachments' => $oublog->maxattachments));
if ($mform->is_cancelled()) {
redirect($viewurl);
exit;
@@ -158,7 +160,8 @@
$PAGE->set_title(format_string($oublog->name));
$PAGE->set_heading(format_string($course->fullname));
echo $OUTPUT->header();
-
+ $renderer = $PAGE->get_renderer('mod_oublog');
+ echo $renderer->render_pre_postform($oublog, $cm);
$mform->display();
echo $OUTPUT->footer();
diff --git a/externallib.php b/externallib.php
new file mode 100644
index 0000000..9c5fc7d
--- /dev/null
+++ b/externallib.php
@@ -0,0 +1,302 @@
+.
+
+/**
+ * External oublog API.
+ * Used for importing posts from another server.
+ *
+ * @package mod
+ * @subpackage oublog
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once("$CFG->libdir/externallib.php");
+require_once("$CFG->dirroot/mod/oublog/locallib.php");
+
+class mod_oublog_external extends external_api {
+
+ public static function get_user_blogs_parameters() {
+ return new external_function_parameters(array(
+ 'username' => new external_value(PARAM_USERNAME, 'User username')
+ ));
+ }
+
+ /**
+ * Return all blogs on the system for the user
+ * @param string $username
+ */
+ public static function get_user_blogs($username) {
+ global $DB;
+ $username = self::validate_parameters(self::get_user_blogs_parameters(),
+ array('username' => $username));
+ $user = $DB->get_field('user', 'id', array('username' => $username['username']), IGNORE_MISSING);
+ if (!$user) {
+ return array();
+ }
+ $result = oublog_import_getblogs($user);
+ // Add remote property to each blog to identify that it came from web service.
+ foreach ($result as &$blog) {
+ $blog->remote = true;
+ }
+ return $result;
+ }
+
+ public static function get_user_blogs_returns() {
+ return new external_multiple_structure(
+ new external_single_structure(
+ array(
+ 'cmid' => new external_value(PARAM_INT, 'blog course module id'),
+ 'coursename' => new external_value(PARAM_TEXT, 'course name text'),
+ 'numposts' => new external_value(PARAM_INT, 'number of posts in blog'),
+ 'name' => new external_value(PARAM_TEXT, 'activity name text'),
+ 'remote' => new external_value(PARAM_BOOL, 'identifies activity is remote'),
+ )
+ )
+ );
+ }
+
+ public static function get_blog_info_parameters() {
+ return new external_function_parameters(
+ array(
+ 'cmid' => new external_value(PARAM_INT, 'Blog cm id'),
+ 'username' => new external_value(PARAM_USERNAME, 'User username'),
+ )
+ );
+ }
+
+ public static function get_blog_info($cmid, $username) {
+ global $DB;
+ $params = self::validate_parameters(self::get_blog_info_parameters(),
+ array('cmid' => $cmid, 'username' => $username));
+ $user = $DB->get_field('user', 'id', array('username' => $params['username']), IGNORE_MISSING);
+ if (!$user) {
+ return array();
+ }
+ $result = oublog_import_getbloginfo($params['cmid'], $user);
+ return array(
+ 'bcmid' => $result[0],
+ 'boublogid' => $result[1],
+ 'bcontextid' => $result[2],
+ 'boublogname' => $result[3],
+ 'bcoursename' => $result[4],
+ );
+ }
+
+ public static function get_blog_info_returns() {
+ return new external_single_structure(
+ array(
+ 'bcmid' => new external_value(PARAM_INT, 'Blog cm id'),
+ 'boublogid' => new external_value(PARAM_INT, 'Blog id'),
+ 'bcontextid' => new external_value(PARAM_INT, 'Blog context id'),
+ 'boublogname' => new external_value(PARAM_TEXT, 'Blog name'),
+ 'bcoursename' => new external_value(PARAM_TEXT, 'Course short name'),
+ ));
+ }
+
+ public static function get_blog_allposts_parameters() {
+ return new external_function_parameters(
+ array(
+ 'blogid' => new external_value(PARAM_INT, 'Blog id'),
+ 'sort' => new external_value(PARAM_TEXT, 'sort sql'),
+ 'username' => new external_value(PARAM_USERNAME, 'User username'),
+ 'page' => new external_value(PARAM_INT, 'results page', VALUE_OPTIONAL, 0),
+ 'tags' => new external_value(PARAM_SEQUENCE, 'tags to filter by', VALUE_OPTIONAL, null),
+ )
+ );
+ }
+
+ /**
+ * Gets all user posts from blog, filtered by page and tags
+ * @param int $blogid
+ * @param string $sort
+ * @param string $username
+ * @param int $page
+ * @param string $tags comma separated sequence of selected tag ids to filter by
+ * @return array
+ */
+ public static function get_blog_allposts($blogid, $sort, $username, $page = 0, $tags = null) {
+ global $DB;
+ $params = self::validate_parameters(self::get_blog_allposts_parameters(),
+ array('blogid' => $blogid, 'sort' => $sort, 'username' => $username,
+ 'page' => $page, 'tags' => $tags));
+ $user = $DB->get_field('user', 'id', array('username' => $params['username']), IGNORE_MISSING);
+ if (!$user) {
+ return array();
+ }
+ $result = oublog_import_getallposts($params['blogid'], $params['sort'], $user,
+ $params['page'], $params['tags']);
+ if (!is_array($result[2])) {
+ $result[2] = array();
+ }
+ foreach ($result[0] as &$post) {
+ if (isset($post->tags)) {
+ $tagupdate = array();
+ // Update post tags into a format that Moodle WS can work with.
+ foreach ($post->tags as $id => $tag) {
+ $tagupdate[] = (object) array('id' => $id, 'tag' => $tag);
+ }
+ $post->tags = $tagupdate;
+ }
+ }
+ return array('posts' => $result[0], 'total' => $result[1], 'tagnames' => $result[2]);
+ }
+
+ public static function get_blog_allposts_returns() {
+ return new external_single_structure(array(
+ 'posts' => new external_multiple_structure(new external_single_structure(array(
+ 'id' => new external_value(PARAM_INT, 'post id'),
+ 'title' => new external_value(PARAM_TEXT, 'title'),
+ 'timeposted' => new external_value(PARAM_INT, 'created'),
+ 'tags' => new external_multiple_structure(new external_single_structure(array(
+ 'id' => new external_value(PARAM_INT, 'tag id'),
+ 'tag' => new external_value(PARAM_TEXT, 'tag value'))
+ ), 'tags', VALUE_OPTIONAL),
+ ))),
+ 'total' => new external_value(PARAM_INT, 'total user posts in blog'),
+ 'tagnames' => new external_multiple_structure(
+ new external_single_structure(array(
+ 'id' => new external_value(PARAM_INT, 'tag id'),
+ 'tag' => new external_value(PARAM_TEXT, 'tag value'),
+ )), 'tags', VALUE_OPTIONAL)
+ ));
+ }
+
+ public static function get_blog_posts_parameters() {
+ return new external_function_parameters(
+ array(
+ 'blogid' => new external_value(PARAM_INT, 'Blog id'),
+ 'bcontextid' => new external_value(PARAM_INT, 'Blog module context id'),
+ 'selected' => new external_value(PARAM_SEQUENCE, 'post ids'),
+ 'inccomments' => new external_value(PARAM_BOOL, 'include comments',
+ VALUE_OPTIONAL, false),
+ 'username' => new external_value(PARAM_USERNAME, 'User username'),
+ )
+ );
+ }
+
+ /**
+ * Get selected blog posts from blog
+ * @param int $blogid
+ * @param string $selected comma separated sequence of selected post ids to filter by
+ * @param bool $inccomments - blog uses comments or not
+ * @param string $username - used to ensure user posts only
+ * @return array of posts
+ */
+ public static function get_blog_posts($blogid, $bcontextid, $selected, $inccomments = false, $username) {
+ global $DB;
+ $params = self::validate_parameters(self::get_blog_posts_parameters(),
+ array('blogid' => $blogid, 'bcontextid' => $bcontextid, 'selected' => $selected,
+ 'inccomments' => $inccomments, 'username' => $username));
+ $user = $DB->get_field('user', 'id', array('username' => $username), IGNORE_MISSING);
+ if (!$user) {
+ return array();
+ }
+ $selected = explode(',', $params['selected']);
+ $return = oublog_import_getposts($params['blogid'], $params['bcontextid'],
+ $selected, $params['inccomments'], $user);
+ // Convert file objects into a custom known object to send.
+ foreach ($return as &$post) {
+ foreach ($post->images as &$file) {
+ $file = (object) array(
+ 'contextid' => $file->get_contextid(),
+ 'filearea' => $file->get_filearea(),
+ 'filepath' => $file->get_filepath(),
+ 'filename' => $file->get_filename(),
+ 'itemid' => $file->get_itemid()
+ );
+ }
+ foreach ($post->attachments as &$file) {
+ $file = (object) array(
+ 'contextid' => $file->get_contextid(),
+ 'filearea' => $file->get_filearea(),
+ 'filepath' => $file->get_filepath(),
+ 'filename' => $file->get_filename(),
+ 'itemid' => $file->get_itemid()
+ );
+ }
+ foreach ($post->comments as &$comment) {
+ foreach ($comment->images as &$file) {
+ $file = (object) array(
+ 'contextid' => $file->get_contextid(),
+ 'filearea' => $file->get_filearea(),
+ 'filepath' => $file->get_filepath(),
+ 'filename' => $file->get_filename(),
+ 'itemid' => $file->get_itemid()
+ );
+ }
+ }
+ }
+ return $return;
+ }
+
+ public static function get_blog_posts_returns() {
+ return new external_multiple_structure(new external_single_structure(array(
+ 'id' => new external_value(PARAM_INT, 'post id'),
+ 'oubloginstancesid' => new external_value(PARAM_INT, 'instance id'),
+ 'groupid' => new external_value(PARAM_INT, 'group id'),
+ 'title' => new external_value(PARAM_TEXT, 'title'),
+ 'message' => new external_value(PARAM_RAW, 'message'),
+ 'timeposted' => new external_value(PARAM_INT, 'created'),
+ 'allowcomments' => new external_value(PARAM_INT, 'comments allowed'),
+ 'timeupdated' => new external_value(PARAM_INT, 'updated'),
+ 'deletedby' => new external_value(PARAM_INT, 'deleted by'),
+ 'timedeleted' => new external_value(PARAM_INT, 'deleted'),
+ 'visibility' => new external_value(PARAM_INT, 'visibility'),
+ 'lasteditedby' => new external_value(PARAM_INT, 'edited by'),
+ 'tags' => new external_multiple_structure(new external_single_structure(array(
+ 'id' => new external_value(PARAM_INT, 'tag id'),
+ 'tag' => new external_value(PARAM_TEXT, 'tag value'),
+ 'postid' => new external_value(PARAM_INT, 'tag post id'),
+ )), 'tags', VALUE_OPTIONAL),
+ 'images' => new external_multiple_structure(new external_single_structure(array(
+ 'contextid' => new external_value(PARAM_INT, 'context id'),
+ 'filearea' => new external_value(PARAM_AREA, 'filearea'),
+ 'filepath' => new external_value(PARAM_PATH, 'path'),
+ 'filename' => new external_value(PARAM_FILE, 'filename'),
+ 'itemid' => new external_value(PARAM_INT, 'item id'),
+ )), 'images', VALUE_OPTIONAL),
+ 'attachments' => new external_multiple_structure(new external_single_structure(array(
+ 'contextid' => new external_value(PARAM_INT, 'context id'),
+ 'filearea' => new external_value(PARAM_AREA, 'filearea'),
+ 'filepath' => new external_value(PARAM_PATH, 'filepath'),
+ 'filename' => new external_value(PARAM_FILE, 'filename'),
+ 'itemid' => new external_value(PARAM_INT, 'item id'),
+ )), 'attachments', VALUE_OPTIONAL),
+ 'comments' => new external_multiple_structure(
+ new external_single_structure(array(
+ 'id' => new external_value(PARAM_INT, 'id'),
+ 'postid' => new external_value(PARAM_INT, 'post id'),
+ 'userid' => new external_value(PARAM_INT, 'user id'),
+ 'title' => new external_value(PARAM_TEXT, 'title'),
+ 'message' => new external_value(PARAM_RAW, 'message'),
+ 'timeposted' => new external_value(PARAM_INT, 'posted'),
+ 'deletedby' => new external_value(PARAM_INT, 'deleted by'),
+ 'timedeleted' => new external_value(PARAM_INT, 'deleted'),
+ 'authorname' => new external_value(PARAM_INT, 'ex author'),
+ 'authorip' => new external_value(PARAM_INT, 'ex author ip'),
+ 'timeapproved' => new external_value(PARAM_INT, 'approved'),
+ 'images' => new external_multiple_structure(new external_single_structure(array(
+ 'contextid' => new external_value(PARAM_INT, 'context id'),
+ 'filearea' => new external_value(PARAM_AREA, 'filearea'),
+ 'filepath' => new external_value(PARAM_PATH, 'path'),
+ 'filename' => new external_value(PARAM_FILE, 'filename'),
+ 'itemid' => new external_value(PARAM_INT, 'item id'),
+ )), 'images', VALUE_OPTIONAL),
+ )), 'comments', VALUE_OPTIONAL)
+ )));
+ }
+}
diff --git a/feed.php b/feed.php
index 54f6c0f..e94c915 100644
--- a/feed.php
+++ b/feed.php
@@ -38,7 +38,7 @@
$url = new moodle_url('/mod/oublog/feed.php', array('format'=>$format, 'blog'=>$blogid,
'bloginstance'=>$bloginstancesid, 'post'=>$postid));
$PAGE->set_url($url);
-$PAGE->set_context(get_system_context());
+$PAGE->set_context(context_system::instance());
// Validate Parameters.
$format = strtolower($format);
@@ -93,8 +93,8 @@
}
// Check browser compatibility.
-if (check_browser_version('MSIE', 0) || check_browser_version('Firefox', 0)) {
- if (!check_browser_version('MSIE', '7') && !check_browser_version('Firefox', '2')) {
+if (core_useragent::check_browser_version('MSIE', 0) || core_useragent::check_browser_version('Firefox', 0)) {
+ if (!core_useragent::check_browser_version('MSIE', '7') && !core_useragent::check_browser_version('Firefox', '2')) {
if ($blog->global) {
$url='view.php?user='.$bloginstance->userid;
} else {
@@ -174,14 +174,14 @@
} else {
// Must have access all groups
require_capability('moodle/site:accessallgroups',
- get_context_instance(CONTEXT_MODULE, $cm->id), $user->id);
+ context_module::instance($cm->id), $user->id);
}
}
// Get data for feed in a standard form.
if ($comments) {
$feeddata = oublog_get_feed_comments($blogid, $bloginstancesid, $postid, $user,
- $allowedvisibility, $groupid, $cm);
+ $allowedvisibility, $groupid, $cm, $blog, $individualid);
$feedname = strip_tags($blog->name) . ': ' . get_string('commentsfeed', 'oublog');
$feedsummary='';
} else {
diff --git a/import.php b/import.php
new file mode 100644
index 0000000..4b3f753
--- /dev/null
+++ b/import.php
@@ -0,0 +1,481 @@
+.
+
+/**
+ * Import pages into the current blog
+ * Supports imports from Individual blog to Individual blog (same user)
+ *
+ * @package mod
+ * @subpackage oublog
+ * @copyright 2013 The open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once(dirname(__FILE__) . '/../../config.php');
+require_once($CFG->dirroot . '/mod/oublog/locallib.php');
+
+$id = required_param('id', PARAM_INT);// Blog cm ID.
+
+// Load efficiently (and with full $cm data) using get_fast_modinfo.
+$course = $DB->get_record_select('course',
+ 'id = (SELECT course FROM {course_modules} WHERE id = ?)', array($id),
+ '*', MUST_EXIST);
+$modinfo = get_fast_modinfo($course);
+$cm = $modinfo->get_cm($id);
+if ($cm->modname !== 'oublog') {
+ print_error('invalidcoursemodule');
+}
+
+if (!$oublog = $DB->get_record('oublog', array('id' => $cm->instance))) {
+ print_error('invalidcoursemodule');
+}
+
+$context = context_module::instance($cm->id);
+$tempoublog = clone $oublog;
+if ($tempoublog->global) {
+ $tempoublog->maxvisibility = OUBLOG_VISIBILITY_LOGGEDINUSER;// Force login regardless of setting.
+} else {
+ $tempoublog->maxvisibility = OUBLOG_VISIBILITY_COURSEUSER;// Force login regardless of setting.
+}
+oublog_check_view_permissions($tempoublog, $context, $cm);
+$blogname = oublog_get_displayname($oublog);
+
+// Is able to import check for current blog.
+if (!$oublog->allowimport ||
+ (!$oublog->global && $oublog->individual == OUBLOG_NO_INDIVIDUAL_BLOGS)) {
+ // Must have import enabled. Individual blog mode only.
+ print_error('import_notallowed', 'oublog', null, $blogname);
+}
+// Check if group mode set - need to check user is in selected group etc.
+$groupmode = oublog_get_activity_groupmode($cm, $course);
+$currentgroup = 0;
+if ($groupmode != NOGROUPS) {
+ $currentgroup = oublog_get_activity_group($cm);
+ $ingroup = groups_is_member($currentgroup);
+ if ($oublog->individual != OUBLOG_NO_INDIVIDUAL_BLOGS && ($currentgroup && !$ingroup)) {
+ // Must be group memeber for individual blog with group mode on.
+ print_error('import_notallowed', 'oublog', null, $blogname);
+ }
+}
+
+$step = optional_param('step', 0, PARAM_INT);
+if (optional_param('cancel', '', PARAM_ALPHA) == get_string('cancel')) {
+ $step -= 2;// Go back 2 steps if cancel.
+}
+$oublogoutput = $PAGE->get_renderer('mod_oublog');
+
+// Page header.
+$params = array('id' => $id);
+$PAGE->set_url('/mod/oublog/import.php', $params);
+$errlink = new moodle_url('/mod/oublog/import.php', $params);
+$PAGE->set_title(get_string('import', 'oublog'));
+$PAGE->navbar->add(get_string('import', 'oublog'));
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('import', 'oublog'));
+
+echo html_writer::start_div('oublog_import_step oublog_import_step' . $step);
+
+if ($step == 0) {
+ // Show list of oublog activities user has access to import from.
+ echo html_writer::tag('p', get_string('import_step0_inst', 'oublog'));
+ $curcourse = -1;
+ $blogs = oublog_import_getblogs($USER->id, $cm->id);
+ try {
+ if ($remoteblogs = oublog_import_remote_call('mod_oublog_get_user_blogs',
+ array('username' => $USER->username))) {
+ $blogs = array_merge($blogs, $remoteblogs);
+ }
+ } catch (moodle_exception $e) {
+ // Ignore fail when contacting external server, keep message for debugging.
+ debugging($e->getMessage());
+ }
+ $personalblogout = '';
+ $blogout = '';
+ foreach ($blogs as $bloginfo) {
+ if ($bloginfo->coursename != '' && $curcourse != $bloginfo->coursename) {
+ if ($curcourse != -1) {
+ $blogout .= html_writer::end_tag('ul');
+ }
+ $blogout .= $OUTPUT->heading($bloginfo->coursename, 3);
+ $blogout .= html_writer::start_tag('ul');
+ $curcourse = $bloginfo->coursename;
+ }
+ // Use this activity icon for all blogs (in case from another server).
+ $img = html_writer::empty_tag('img', array('src' => $cm->get_icon_url($oublogoutput),
+ 'alt' => ''));
+ $bloglink = '';
+ if ($bloginfo->numposts) {
+ $url = new moodle_url('/mod/oublog/import.php', $params +
+ array('step' => 1, 'bid' => $bloginfo->cmid));
+ if (isset($bloginfo->remote)) {
+ $url->param('remote', true);
+ }
+ $link = html_writer::link($url, $bloginfo->name);
+ $bloglink = html_writer::tag('li', $img . ' ' . $link . ' ' .
+ get_string('import_step0_numposts', 'oublog', $bloginfo->numposts));
+ } else {
+ $bloglink = html_writer::tag('li', $img . ' ' . $bloginfo->name . ' ' .
+ get_string('import_step0_numposts', 'oublog', 0));
+ }
+ if ($bloginfo->coursename != '') {
+ $blogout .= $bloglink;
+ } else {
+ $personalblogout .= $bloglink;
+ }
+ }
+ if ($personalblogout != '') {
+ echo html_writer::tag('ul', $personalblogout);
+ }
+ echo $blogout;
+ if ($curcourse != -1) {
+ echo html_writer::end_tag('ul');
+ }
+ if (empty($blogs)) {
+ echo $OUTPUT->error_text(get_string('import_step0_nonefound', 'oublog'));
+ }
+} else if ($step == 1) {
+ // Get available posts, first get selected blog info + check access.
+ $bid = required_param('bid', PARAM_INT);
+ $stepinfo = array('step' => 1, 'bid' => $bid);
+ if ($remote = optional_param('remote', false, PARAM_BOOL)) {
+ $stepinfo['remote'] = true;
+ // Blog on remote server, use WS to get info.
+ if (!$result = oublog_import_remote_call('mod_oublog_get_blog_info',
+ array('username' => $USER->username, 'cmid' => $bid))) {
+ throw new moodle_exception('invalidcoursemodule', 'error');
+ }
+ $boublogid = $result->boublogid;
+ $bcontextid = $result->bcontextid;
+ $boublogname = $result->boublogname;
+ $bcoursename = $result->bcoursename;
+ } else {
+ list($bid, $boublogid, $bcontextid, $boublogname, $bcoursename) = oublog_import_getbloginfo($bid);
+ }
+ echo html_writer::start_tag('p', array('class' => 'oublog_import_step1_from'));
+ echo get_string('import_step1_from', 'oublog') . ' ' . html_writer::tag('span', $boublogname);
+ echo html_writer::end_tag('p');
+ // Setup table early so sort can be determined (needs setup to be called first).
+ $table = new flexible_table($cm->id * $bid);
+ $url = new moodle_url('/mod/oublog/import.php', $params + $stepinfo);
+ $table->define_baseurl($url);
+ $table->define_columns(array('title', 'timeposted', 'tags', 'include'));
+ $table->column_style('include', 'text-align', 'center');
+ $table->sortable(true, 'timeposted', SORT_DESC);
+ $table->maxsortkeys = 1;
+ $table->no_sorting('tags');
+ $table->no_sorting('include');
+ $table->setup();
+ $sort = flexible_table::get_sort_for_table($cm->id * $bid);
+ if (empty($sort)) {
+ $sort = 'timeposted DESC';
+ }
+ if ($tags = optional_param('tags', null, PARAM_SEQUENCE)) {
+ // Filter by joining tag instances.
+ $stepinfo['tags'] = $tags;
+ }
+ $perpage = 100;// Must match value in oublog_import_getallposts.
+ $page = optional_param('page', 0, PARAM_INT);
+ $stepinfo['page'] = $page;
+ $preselected = optional_param('preselected', '', PARAM_SEQUENCE);
+ $stepinfo['preselected'] = $preselected;
+ $preselected = array_filter(array_unique(explode(',', $preselected)));
+ if ($remote) {
+ $result = oublog_import_remote_call('mod_oublog_get_blog_allposts', array(
+ 'blogid' => $boublogid, 'username' => $USER->username, 'sort' => $sort,
+ 'page' => $page, 'tags' => $tags));
+ $posts = $result->posts;
+ $total = $result->total;
+ $tagnames = $result->tagnames;
+ // Fix up post tags to required format as passed differently from WS.
+ foreach ($posts as &$post) {
+ if (isset($post->tags)) {
+ $newtagarr = array();
+ foreach ($post->tags as $tag) {
+ $newtagarr[$tag->id] = $tag->tag;
+ }
+ $post->tags = $newtagarr;
+ }
+ }
+ } else {
+ list($posts, $total, $tagnames) = oublog_import_getallposts($boublogid, $sort, $USER->id,
+ $page, $tags);
+ }
+ if ($posts) {
+ // Finish seting up table vars.
+ $url = new moodle_url('/mod/oublog/import.php', $params + $stepinfo);
+ $table->define_baseurl($url);
+ $perpage = $total < $perpage ? $total : $perpage;
+ $table->pagesize($perpage, $total);
+ $taghead = get_string('import_step1_table_tags', 'oublog');
+ if (!empty($tagnames)) {
+ // Add tag filter removal links.
+ $taghead .= ' ';
+ foreach ($tagnames as $tagid => $tag) {
+ $tagaarcopy = explode(',', $tags);
+ unset($tagaarcopy[array_search($tagid, $tagaarcopy)]);
+ $turl = new moodle_url('/mod/oublog/import.php',
+ array_merge($params, $stepinfo, array('tags' => implode(',', $tagaarcopy))));
+ $taghead .= ' ' . html_writer::link($turl, $OUTPUT->pix_icon('t/delete',
+ get_string('import_step1_removetag', 'oublog', $tag->tag))) .
+ ' ' . format_text($tag->tag, FORMAT_HTML);
+ }
+ }
+ $table->define_headers(array(get_string('import_step1_table_title', 'oublog'),
+ get_string('import_step1_table_posted', 'oublog'),
+ $taghead,
+ get_string('import_step1_table_include', 'oublog')));
+ echo html_writer::start_tag('form', array('method' => 'post', 'action' => qualified_me()));
+ $untitledcount = 1;
+ foreach ($posts as &$post) {
+ $tagcol = '';
+ if (isset($post->tags)) {
+ // Create tag column for post.
+ foreach ($post->tags as $tagid => $tag) {
+ $newtagval = empty($tags) ? $tagid : $tags . ",$tagid";
+ $turl = new moodle_url('/mod/oublog/import.php',
+ array_merge($params, $stepinfo, array('tags' => $newtagval)));
+ $tagcol .= html_writer::link($turl, format_text($tag, FORMAT_HTML),
+ array('class' => 'oublog_import_tag'));
+ }
+ }
+ if (empty($post->title)) {
+ $post->title = get_string('untitledpost', 'oublog') . ' ' . $untitledcount;
+ $untitledcount++;
+ }
+ $importcol = html_writer::checkbox('post_' . $post->id, $post->id, in_array($post->id, $preselected),
+ get_string('import_step1_include_label', 'oublog', format_string($post->title)));
+ $table->add_data(array(
+ format_string($post->title),
+ oublog_date($post->timeposted),
+ $tagcol, $importcol));
+ }
+ $module = array ('name' => 'mod_oublog');
+ $module['fullpath'] = '/mod/oublog/module.js';
+ $module['requires'] = array('node', 'node-event-delegate', 'querystring');
+ $PAGE->requires->strings_for_js(array('import_step1_all', 'import_step1_none'), 'oublog');
+ $PAGE->requires->js_init_call('M.mod_oublog.init_posttable', null, false, $module);
+ $table->finish_output();
+ echo html_writer::start_div();
+ foreach (array_merge($params, $stepinfo, array('step' => 2, 'sesskey' => sesskey())) as $param => $value) {
+ echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $param, 'value' => $value));
+ }
+ echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'submit',
+ 'value' => get_string('import_step1_submit', 'oublog')));
+ echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'cancel',
+ 'value' => get_string('cancel')));
+ echo html_writer::end_div();
+ echo html_writer::end_tag('form');
+ }
+} else if ($step == 2) {
+ // Do the import, show feedback. First check access.
+ echo html_writer::tag('p', get_string('import_step2_inst', 'oublog'));
+ flush();
+ $bid = required_param('bid', PARAM_INT);
+ if ($remote = optional_param('remote', false, PARAM_BOOL)) {
+ // Blog on remote server, use WS to get info.
+ if (!$result = oublog_import_remote_call('mod_oublog_get_blog_info',
+ array('username' => $USER->username, 'cmid' => $bid))) {
+ throw new moodle_exception('invalidcoursemodule', 'error');
+ }
+ $boublogid = $result->boublogid;
+ $bcontextid = $result->bcontextid;
+ $boublogname = $result->boublogname;
+ $bcoursename = $result->bcoursename;
+ } else {
+ list($bid, $boublogid, $bcontextid, $boublogname, $bcoursename) = oublog_import_getbloginfo($bid);
+ }
+ require_sesskey();
+ // Get selected and pre-selected posts.
+ $preselected = explode(',', optional_param('preselected', '', PARAM_SEQUENCE));
+ $selected = array();
+ foreach ($_POST as $name => $val) {
+ if (strpos($name, 'post_') === 0) {
+ $selected[] = $val;
+ }
+ }
+ $selected = array_filter(array_unique(array_merge($selected, $preselected), SORT_NUMERIC));
+ $stepinfo = array('step' => 2, 'bid' => $bid, 'preselected' => implode(',', $selected), 'remote' => $remote);
+ if (empty($selected)) {
+ echo html_writer::tag('p', get_string('import_step2_none', 'oublog'));
+ echo $OUTPUT->continue_button(new moodle_url('/mod/oublog/import.php',
+ array_merge($params, $stepinfo, array('step' => 1))));
+ echo $OUTPUT->footer();
+ exit;
+ }
+
+ if ($remote) {
+ $posts = oublog_import_remote_call('mod_oublog_get_blog_posts',
+ array('username' => $USER->username, 'blogid' => $boublogid, 'selected' => implode(',', $selected),
+ 'inccomments' => $oublog->allowcomments != OUBLOG_COMMENTS_PREVENT, 'bcontextid' => $bcontextid));
+ } else {
+ $posts = oublog_import_getposts($boublogid, $bcontextid, $selected,
+ $oublog->allowcomments != OUBLOG_COMMENTS_PREVENT, $USER->id);
+ }
+
+ if (empty($posts)) {
+ print_error('import_step2_none', 'oublog');
+ }
+
+ // Get/create user blog instance for this activity.
+ if ($oublog->global) {
+ list($notused, $oubloginstance) = oublog_get_personal_blog($USER->id);
+ } else {
+ if (!$oubloginstance = $DB->get_record('oublog_instances', array('oublogid' => $oublog->id, 'userid' => $USER->id))) {
+ if (!$oubloginstance = oublog_add_bloginstance($oublog->id, $USER->id)) {
+ print_error('Failed to create blog instance');
+ }
+ $oubloginstance = (object) array('id' => $oubloginstance);
+ }
+ }
+ // Copy all posts (updating group), checking for conflicts first.
+ $bar = new progress_bar('oublog_import_step2_prog', 500, true);
+ $conflicts = array();
+ $ignoreconflicts = optional_param('ignoreconflicts', false, PARAM_BOOL);
+ $cur = 0;
+ $files = get_file_storage();
+ foreach ($posts as $post) {
+ $cur++;
+ // Is there a conflict, if so add to our list so we can re-do these later.
+ if (!$ignoreconflicts && $DB->get_records('oublog_posts', array('title' => $post->title,
+ 'timeposted' => $post->timeposted, 'oubloginstancesid' => $oubloginstance->id))) {
+ $conflicts[] = $post->id;
+ $bar->update($cur, count($posts), get_string('import_step2_prog', 'oublog'));
+ continue;
+ }
+ $trans = $DB->start_delegated_transaction();
+ $newpost = new stdClass();
+ $newpost->oubloginstancesid = $oubloginstance->id;
+ $newpost->groupid = 0;// Force 0 as individual mode.
+ $newpost->title = $post->title;
+ $newpost->message = $post->message;
+ $newpost->timeposted = $post->timeposted;
+ $newpost->allowcomments = $post->allowcomments;
+ $newpost->timeupdated = time();
+ $newpost->visibility = $post->visibility;
+ if ($oublog->maxvisibility < $newpost->visibility) {
+ $newpost->visibility = $oublog->maxvisibility;
+ }
+ if ($oublog->allowcomments == OUBLOG_COMMENTS_PREVENT) {
+ $newpost->allowcomments = OUBLOG_COMMENTS_PREVENT;
+ }
+ $newid = $DB->insert_record('oublog_posts', $newpost);
+ // Add tags copied from original + new short code tag.
+ if ($bcoursename) {
+ $tagname = textlib::strtolower($bcoursename);
+ if (!$bctag = $DB->get_field('oublog_tags', 'id',
+ array('tag' => $tagname))) {
+ $bctag = $DB->insert_record('oublog_tags',
+ (object) array('tag' => $tagname));
+ }
+ if (!isset($post->tags)) {
+ $post->tags = array((object) array('id' => $bctag, 'tag' => $tagname));
+ } else {
+ $post->tags[] = (object) array('id' => $bctag, 'tag' => $tagname);
+ }
+ }
+ if (isset($post->tags)) {
+ foreach ($post->tags as $tagval) {
+ if (!$remote || ($bcoursename && $tagval == $tagname)) {
+ $DB->insert_record('oublog_taginstances', (object) array(
+ 'oubloginstancesid' => $oubloginstance->id, 'postid' => $newid, 'tagid' => $tagval->id));
+ } else {
+ // Find/create tag.
+ if (!$tagid = $DB->get_field('oublog_tags', 'id', array('tag' => $tagval->tag))) {
+ $tagid = $DB->insert_record('oublog_tags', (object) array('tag' => $tagval->tag));
+ }
+ $DB->insert_record('oublog_taginstances', (object) array(
+ 'oubloginstancesid' => $oubloginstance->id, 'postid' => $newid, 'tagid' => $tagid));
+ }
+ }
+ }
+ // Copy across images/attachments (no maximum check).
+ if ($remote) {
+ // Download remote files and add to new post.
+ oublog_import_remotefiles($post->images, $context->id, $newid);
+ oublog_import_remotefiles($post->attachments, $context->id, $newid);
+ } else {
+ foreach ($post->images as $image) {
+ $files->create_file_from_storedfile(array('itemid' => $newid, 'contextid' => $context->id), $image);
+ }
+ foreach ($post->attachments as $attach) {
+ $files->create_file_from_storedfile(array('itemid' => $newid, 'contextid' => $context->id), $attach);
+ }
+ }
+ // Copy own comments (if enabled on this blog).
+ if (!empty($post->comments)) {
+ foreach ($post->comments as $comment) {
+ $oldcid = $comment->id;
+ unset($comment->id);
+ $comment->postid = $newid;
+ $comment->userid = $USER->id;
+ $newcid = $DB->insert_record('oublog_comments', $comment);
+ // Copy comment images.
+ if (!$remote) {
+ foreach ($comment->images as $image) {
+ $files->create_file_from_storedfile(array('itemid' => $newcid,
+ 'contextid' => $context->id), $image);
+ }
+ } else {
+ oublog_import_remotefiles($comment->images, $context->id, $newcid);
+ }
+ }
+ // Inform completion system, if available.
+ $completion = new completion_info($course);
+ if ($completion->is_enabled($cm) && ($oublog->completioncomments)) {
+ $completion->update_state($cm, COMPLETION_COMPLETE);
+ }
+ }
+ // Update search (add required properties to newpost).
+ $newpost->id = $newid;
+ $newpost->userid = $USER->id;
+ $newpost->tags = array();
+ if (isset($post->tags)) {
+ foreach ($post->tags as $tag) {
+ $newpost->tags[$tag->id] = $tag->tag;
+ }
+ }
+ oublog_search_update($newpost, $cm);
+ $trans->allow_commit();
+ $bar->update($cur, count($posts), get_string('import_step2_prog', 'oublog'));
+ }
+ if (count($conflicts) != count($posts)) {
+ // Inform completion system, if available.
+ $completion = new completion_info($course);
+ if ($completion->is_enabled($cm) && ($oublog->completionposts)) {
+ $completion->update_state($cm, COMPLETION_COMPLETE);
+ }
+ }
+ echo html_writer::tag('p', get_string('import_step2_total', 'oublog',
+ (count($posts) - count($conflicts))));
+ $continueurl = '/mod/oublog/view.php?id=' . $cm->id;
+ if ($oublog->global) {
+ $continueurl = '/mod/oublog/view.php?user=' . $USER->id;
+ }
+ if (count($conflicts)) {
+ // Enable conflicts to be ignored by resending only these.
+ $stepinfo['ignoreconflicts'] = true;
+ $stepinfo['preselected'] = implode(',', $conflicts);
+ $url = new moodle_url('/mod/oublog/import.php', array_merge($params, $stepinfo));
+ $conflictimport = new single_button($url, get_string('import_step2_conflicts_submit', 'oublog'));
+ echo $OUTPUT->confirm(get_string('import_step2_conflicts', 'oublog', count($conflicts)),
+ $conflictimport, $continueurl);
+ } else {
+ echo $OUTPUT->continue_button($continueurl);
+ }
+}
+
+echo html_writer::end_div();
+echo $OUTPUT->footer();
diff --git a/internaldoc/testcase.basic.txt b/internaldoc/testcase.basic.txt
new file mode 100644
index 0000000..bdeefbf
--- /dev/null
+++ b/internaldoc/testcase.basic.txt
@@ -0,0 +1,88 @@
+This script describes steps to test OU Blog standard functionality. It is intended to cover most of the UI and features.
+
+NOTE: In this test case, the word 'blog' always refers to the OU blog.
+
+Some test steps in this script follow on from each other and aren't independent. In these cases the prerequisite steps are listed.
+
+Initial setup
+=============
+
+This test case requires:
+
+- a user with administration rights
+- a test course.
+
+The test server must have debugging set to DEVELOPER level and to display
+errors; during all parts of the test script, there should be no debugging
+warnings.
+
+CRE Creating blog and data
+==========================
+
+CRE01 / admin.
+ Enter test course and turn editing on.
+ Create a blog called CRE01 which is a whole-course blog (no groups) and
+ visible to anyone in the world.
+
+INT Testing Intro display
+(Requires CRE)
+=========================
+
+INT01 / admin
+ Enter blog "CRE01".
+ Select 'Edit settings' link in the Administration block.
+ Add any text and any uploaded image into the Intro field.
+ Select 'Show intro when posting' checkbox.
+ Select 'Save and display' to save changes.
+-- Verify intro text and image added are now displayed in the top block to the side of the blog posts area.
+
+INT02 / admin
+ Select the 'New blog post' button.
+-- Verify intro text and image added are displayed at the top of the new post page.
+ Enter some text into the 'Message' field.
+ Select 'Add post' button to save the new post and return to main blog view.
+-- Verify post created is displayed at the top of the posts area.
+-- Verify post created is top of the list in the 'My participation summary' panel in the 'Blog usage' block.
+ Select 'Edit' link within post just created.
+-- Verify intro text and image added are displayed at the top of the new post page.
+ Select 'Cancel' to return to main blog view.
+
+INT03 / admin
+ Select 'Edit settings' link in the Administration block.
+ Select 'Show intro when posting' checkbox (making it not checked).
+ Select 'Save and display' to save changes.
+ Select the 'New blog post' button.
+-- Verify intro text and image added are NOT displayed at the top of the new post page.
+ Return to test course home page.
+
+COM Testing adding comments
+(Requires CRE)
+===========================
+
+COM1 / admin
+ Enter blog "CRE01".
+ Select the 'New blog post' button.
+ Enter 'COM1' into the title field.
+ Enter some text and an uploaded image into the 'Message' field.
+ Select 'Add post' button to save the new post and return to main blog view.
+-- Verify 'Add your comment' link is not shown against post COM1.
+
+COM02 / admin
+ Select 'Edit settings' link in the Administration block.
+ Set 'Allow comments' drop down to 'Yes, from everybody (even if not logged in)'.
+ Select 'Save and display' to save changes.
+ Select 'Edit' against post 'COM1'.
+ Set 'Allow comments' to 'Yes, from logged-in users'.
+ Select 'Save changes'.
+-- Verify 'Add your comment' link is shown against post COM1.
+
+COM03 / admin
+ Select 'Add your comment' link against post COM1.
+-- Verify 'New comment' screen is shown with 'Post' (collapsed) and 'New comment' (expanded) sections.
+ Select 'Post' section to expand.
+-- Verify COM1 post is shown correctly, checking display of image and user information.
+ Enter some text into the 'Add your comment' field.
+ Select 'Add comment' button.
+-- Verify returned to blog main view and post COM1 has a '1 comment' link.
+
+Test ends.
diff --git a/internaldoc/testcase.delete.txt b/internaldoc/testcase.delete.txt
new file mode 100644
index 0000000..9255a12
--- /dev/null
+++ b/internaldoc/testcase.delete.txt
@@ -0,0 +1,321 @@
+This script describes steps to test the OU Blog facility for deleting and emailing a user
+notification. It is intended to cover most of the UI and features.
+
+NOTE: In this test case, the word 'blog' always refers to the OU blog.
+
+The test steps in this script follow on from each other and aren't independent.
+
+Initial setup
+=============
+
+This test case requires:
+
+- a course which has at least one blog.
+- two test student users (US1, and US2).
+- make use of the admin and (UET) a user with the teacher role.
+- a reporting email is provided in oublog administration settings, to enable the 'Report post' link.
+- access to each test users email account to read delete notification emails.
+- at least two web browsers, to enable distinctly different sessions,
+ with and without javascript enabled.
+
+The test server must have debugging set to DEVELOPER level and to display
+errors; during all parts of the test script, there should be no debugging
+warnings.
+
+
+CRE Creating blog and data
+===========================
+
+CRE01 / Logged in as admin.
+ Create a blog called CRE01 which is a whole-course blog (no groups) and
+ visible to anyone in the world.
+
+CRE01-A / Log out user Admin.
+CRE01-B / Log in as US1.
+
+CRE01-UP1 / Logged in as US1.
+ Go to blog "CRE01".
+ Click to add a new post with title "CRE01-P1" and text "User one post one visible to participants
+ on this course. To be deleted without the possibility of email notification.".
+ Insert any image to the text area, give the image a description.
+ Insert the tag 'us1t1'.
+ Leave 'Allow comments' at default setting.
+ Add the same image as an attachment to the post.
+-- Click 'Add post'.
+
+CRE01-UP2 / Logged in as US1.
+ Add a new post with title "CRE01-P2" and text "User one post two visible to participants on this course.
+ To be deleted with the possibility of email notification.".
+ Insert a new image to the text area, give the image a description.
+ Insert the tags 'us1t2, us1t1'.
+ Leave 'Allow comments' at default setting.
+ Add the same image as an attachment to the post.
+-- Click the 'Add post' button.
+
+CRE01-UP3 / Logged in as US1.
+ Add a new post with title "CRE01-P3" and text "User one post three visible to participants on this course.
+ To be deleted with email notification.".
+ Insert a third image to the text area, give the image a description.
+ Insert the tags 'us1t3,us1t2, us1t1'.
+ Leave 'Allow comments' at default setting.
+ Add the same image as an attachment to the post.
+-- Click the 'Add post' button to save the post.
+
+CRE01-UP4 / Logged in as US1.
+ Add a new post with title "CRE01-P4" and text "User one post four to remain visible to participants on this course.".
+ Insert an image to the text area, give the image a description.
+ Insert the tags 'us1t4,us1t3,us1t2,us1t1'.
+ Leave 'Allow comments' at default setting.
+ Add the same image as an attachment to the post.
+-- Click the 'Add post' button to save the post.
+
+CRE01-C / Log out user US1.
+CRE01-D / Log in as US2.
+
+CRE02-UP1 / Logged in as US2.
+ Go to blog "CRE01".
+ Add a new post with title "CRE01-P5" and text "User two post one visible to participants on this course.
+ To be deleted without the possibility of email notification.".
+ Insert an image to the text area, give the image a description.
+ Insert the tag 'us2t4,us2t3,us2t2,us2t1'.
+ Leave 'Allow comments' at default setting.
+ Add the same image as an attachment to the post.
+-- Click 'Add post' and save this post.
+
+CRE02-UP2 / Logged in as US2.
+ Add a new post with title "CRE01-P6" and text "User two post two visible to participants on this course.
+ To be deleted with email notification.".
+ Insert an image to the text area, give the image a description.
+ Insert the tag 'us2t3,us2t2,us2t1'.
+ Leave 'Allow comments' at default setting.
+ Add the same image as an attachment to the post.
+-- Click 'Add post'.
+
+CRE02-UP3 / Logged in as US2.
+ Add a new post with title "CRE01-P7" and text "User two post three remaining visible to participants on this course.".
+ Insert an to the text area, give the image a description.
+ Insert the tag 'us2t1'.
+ Leave 'Allow comments' at default setting.
+ Add the same image as an attachment to the post.
+-- Click 'Add post' again.
+
+CRE03-A / Log out user US2.
+CRE03-B / Log in as UET.
+
+CRE03-P1 / Logged in as UET.
+ Go to blog "CRE01".
+ Add a new post with title "CRE01-P8" and text "Teacher post one visible to participants on this course,
+ to be deleted.".
+ Insert an image to the text area, give the image a description.
+ Insert the tag 'uett1'.
+ Leave 'Allow comments' at default setting.
+ Add the same image as an attachment to the post.
+-- Click 'Add post' again.
+
+CRE03-P2 / Logged in as UET.
+ Add a new post with title "CRE01-P9" and text "Teacher post two stays visible to participants on this course.".
+ Insert an image to the text area, give the image a description.
+ Insert the tag 'uett1, uett2'.
+ Leave 'Allow comments' at default setting.
+ Add the same image as an attachment to the post.
+-- Click 'Add post'.
+
+
+BSC Basic Delete usage (JS not enabled in the browser)
+======================
+
+BSC01-NJ1 / Log in as UET
+ Go to blog "CRE01".
+ Tab to the 'Delete' link beneath "CRE01-P1".
+ Click this 'Delete' link..
+-- Confirm that the page refreshes and shows a boxed form, with the description
+ 'Select to delete the post or delete and send a customisable email notification.'
+ and three buttons; 'Delete', 'Delete and email' and 'Cancel'.
+
+BSC01-NJ2 / as UET.
+ Tab to the 'Cancel' button and activate it.
+-- Verify that the page refreshes, when 'Cancel' is clicked, returning to the blog view page,
+ without making any changes.
+
+BSC01-NJ3 / as UET.
+ Click 'Delete' beneath "CRE01-P1" again.
+-- Confirming that the dialog page appears.
+
+BSC01-NJ4 / as UET.
+ Tab to the 'Delete' button.
+ Activate this 'Delete' button.
+-- Confirm that the page refreshes. (The page should automatically redirect. If nothing happens please use the continue link.)
+-- Verify that the page refreshes and that all "CRE01-P1" post content is now dimmed,
+ and that there is now an additional entry beneath the post title and attachments block;
+ 'Deleted by' {uet username} 'the date', which has highlighting in red.
+
+BSC01-NJ5 / as UET.
+ Tab to the 'Delete' link beneath post "CRE01-P2".
+ Click this 'Delete' link.
+-- Confirm that a dialog page opens as before.
+ This time tab to the 'Delete and email' button and click it.
+-- Confirm that a new page 'Delete and email' opens, with a form showing a message box with a default message
+ notification showing that the post was deleted by {uet username} and a block of post detail showing
+ Subject, Blog and Module, followed by an html link 'View the deleted post'.
+-- Confirm that below this message box are;
+ 'Send a copy to yourself' check box ,
+ 'Email address of other recipients', text input box for list entry and
+ 'Include post' check box.
+-- Confirm that the form ends with 'Send and delete' and 'Cancel' buttons.
+
+BSC01-NJ5a / as UET.
+ Tab to the 'Cancel' button and activate it.
+-- Verify that the page refreshes, when 'Cancel' is clicked, returning to the blog view page
+ and that the post has not been deleted.
+
+BSC01-NJ6 / as UET.
+ Again tab to the 'Delete' link beneath post "CRE01-P2".
+ Click this 'Delete' link.
+ Tab to the 'Delete and email' button and click it.
+ Leave all 'Delete and email' form settings at their defaults and click
+ 'Send and delete'.
+-- Verify that the page refreshes and that all "CRE01-P2" content is now dimmed,
+ and that there is now an additional entry beneath the post title - 'Deleted by' {uet username} 'the date'
+ with highlighting in red.
+
+BSC01-NJ7a / as UET.
+-- Verify that an email notification has been received:
+ This is a notification to advise you that your Blog post with the
+ following details has been deleted by {uet username}:
+ Subject: CRE01-P2
+ Blog: CRE-01
+ Module: OUBlog delete and email functionality
+ View the deleted post (an html link)
+
+BSC01-NJ7b / as UET.
+ Click to open the 'View the deleted post' link in the email.
+ In the browser which opens from this link, login as student user US.1.
+ (It may be necessary to click the link in the email again)
+-- Confirm that the post "CRE01-P2" is opened in the 'Viewpost' page and that the post appears
+ the same as in the main page, ie dimmed and with the deleted notification.
+ Log out and close the browser.
+
+BSC01-NJ7c / as UET.
+ Click to open the 'View the deleted post' link in the email.
+ In the browser which opens from this link, login as student user US.2.
+ (It may be necessary to click the link in the email again)
+-- Confirm that the post "CRE01-P2" can not be seen by as student user US.2.
+ Log out and close the browser.
+
+Return to the blog main page, in the original browser session.
+
+BSC01-NJ8 / as UET.
+ Tab to the 'Delete' link beneath post "CRE01-P3".
+ Click this 'Delete' button.
+-- Confirm that a dialog page opens as before.
+ Tab to the 'Delete and email' button and click it.
+-- Confirm that a new page 'Delete and email' opens, with a form showing a message box with a default message
+ notification showing that the post was deleted by {uet username} and a block of post detail showing
+ Subject, Blog and Module, followed by a link 'View the deleted post'.
+-- Confirm that below this message box are;
+ 'Send a copy to yourself' check box,
+ 'Email address of other recipients', text input box for list entry and
+ 'Include post' check box.
+
+BSC01-NJ9 / as UET.
+ Click both checkboxes, and enter the known checkable email address into the text input box.
+ Click the 'Send and delete' button.
+-- Verify that the page refreshes and that all "CRE01-P3" content is now dimmed,
+ and that there is now an additional entry beneath the post title -
+ 'Deleted by' {uet username} 'the date' with highlighting in red.
+
+BSC01-NJ10 / as UET.
+-- Confirm that email notifications have been recieved by each test user.
+-- Confirm that the notification is as above, and that the email also contains the content of the blog post
+ in plain html format, with no delete highlighting.
+
+Return to the blog main page.
+
+BSC Basic delete usage (JS enabled)
+======================
+ Return to the main blog page.
+
+BSC02-JE1 / Log in as UET.
+ Go to blog "CRE01".
+ Tab to the 'Delete' link beneath "CRE01-P5".
+ Click this 'Delete' link.
+-- Confirm that the current page is slightly dimmed and grey all over, highlighting the central popup box
+ with a close widget [X] and the description
+ 'Select to delete the post or delete and send a customisable email notification.'
+ and three buttons; 'Delete', 'Delete and email' and 'Cancel'.
+
+BSC02-JE2 / as UET.
+ Tab to the close widget, and click it.
+-- Verify that the dialog disappears, when the close widget is clicked.
+ On post "CRE01-P5" click 'Delete' again, and tab to the 'Cancel' button.
+-- Verify that the dialog disappears, when the 'Cancel' button is clicked,
+ and that focus remains upon the "CRE01-P5" 'Delete' link.
+
+BSC02-JE3 / as UET.
+ Click this 'Delete' link again beneath "CRE01-P5" post content.
+-- Confirm that a dialog pops up as before.
+ Tab to the 'Delete' button and click it.
+-- Verify that the page refreshes.
+-- Confirm that all "CRE01-P5" post content is now dimmed,
+ and that there is an additional entry beneath the post title -
+ 'Deleted by' {uet username} 'the date' with highlighting in red.
+
+BSC02-JE4 / as UET.
+ Tab to the 'Delete' link beneath "CRE01-P6".
+ Click this 'Delete' link.
+-- Confirm that the dialog pops up as before.
+ Tab to the 'Delete and email' button and click it.
+-- Confirm that a new page opens containing a 'Delete and email' form page.
+
+BSC02-JE5 / as UET.
+ Leave all form settings at their defaults and click 'Send and delete'.
+ (This page should automatically redirect. If nothing happens please use the continue link.)
+-- Verify that the page refreshes and that all "CRE01-P6" post content is now dimmed,
+ and that there is now an additional entry beneath the post title -
+ 'Deleted by' {uet username} 'the date' with highlighting in red.
+
+BSC02-JE6 / as UET.
+-- Confirm that an email notification has been recieved :
+ This is a notification to advise you that your blog post with the
+ following details has been deleted by 'uetuser teacher':
+ Subject: CRE01-P6
+ Blog: CRE01
+ Course: OUBlog delete and email functionality
+ View the deleted post (an html link)
+
+Return to the blog main page.
+
+BSC02-JE7 / as UET.
+ Tab to the 'Delete' link beneath post "CRE01-P8" by user UET.
+ Click this 'Delete' link.
+-- Confirm that the page refreshes and shows a boxed form, with the description
+ 'Are you sure you want to delete this post?'
+ and two buttons 'Delete' and 'Cancel'.
+
+BSC02-JE8 / as UET.
+ Click the 'Delete' button.
+ (This page should automatically redirect. If nothing happen please use the continue link.)
+-- Verify that the page refreshes and that all "CRE01-P8" content is now dimmed,
+ and that there is also an additional entry beneath the post title -
+ 'Deleted by' {uet username} 'the date' with highlighting in red.
+-- Confirm that no email was sent following this deletion.
+
+
+Student user post visibility test.
+----------------------------------
+
+BSC03-U01 / Log in as US.1.
+ Go to blog main page for "CRE01".
+-- Confirm that only five posts are visible as US.1.
+ Posts CRE01-P9 by {uet username}.
+ Posts CRE01-P7 and CRE01-P4 by students two and one.
+ And deleted posts CRE01-P3, CRE01-P2 and CRE01-P1 by student user one
+
+BSC03-U02 / Log in as US.2.
+ Go to blog main page for "CRE01".
+-- Confirm that only five posts are visible as US.2.
+ Posts CRE01-P9 by {uet username}.
+ Post CRE01-P7 and CRE01-P4 by students two and one.
+ And deleted posts, CRE01-P6 and CRE01-P5 by student user two
+
+Test ends.
diff --git a/internaldoc/testcase.importpages.txt b/internaldoc/testcase.importpages.txt
new file mode 100644
index 0000000..2a7c130
--- /dev/null
+++ b/internaldoc/testcase.importpages.txt
@@ -0,0 +1,297 @@
+This script describes steps to test the OU Blog facility for importing posts from a user
+perspective. It is intended to cover most of the UI and features.
+
+NOTE: In this test case, the word 'blog' always refers to the OU blog.
+
+The test steps in this script follow on from each other and aren't independent.
+
+
+Initial setup
+=============
+
+This test case requires:
+
+- 2 users. S1 - a student user and an admin user (both system-wide, not 'view as' or course roles).
+- Two test courses, referred to as TC1 and TC2, that are visible to students.
+- User S1 should be enrolled on TC1 and TC2.
+
+The test server must have debugging set to DEVELOPER level and to display
+errors; during all parts of the test script, there should be no debugging
+warnings.
+
+
+CRE Creating blog and data
+===========================
+
+CRE01 / admin.
+ Enter TC1.
+ Create a blog called WCB01 - a whole-course blog (blog together, no group mode).
+ Create a blog called IB01 - set to Separate individual blogs, enable comments from logged-in users.
+ Create a blog called IB02 - set to Separate individual blogs.
+ Create a blog called IB03 - set to Separate individual blogs - make this hidden from students.
+
+CRE02 / admin
+ Enter TC2.
+ Create a blog called IB04 - set to Separate individual blogs, enable comments from logged-in users.
+
+CRE03 / admin
+ Enter TC1 and enter blog IB01.
+ Create a new post, titled "CRE03 - admin", any message text, other options at default.
+
+CRE04 / S1 (change)
+ Enter TC1 and enter blog IB01.
+ Create a new post:
+ Leave title as blank
+ Add any text to message, upload any image into the text
+ Ensure comments are allowed
+ Add the same image as an attachment
+ Add tags "a,b,c"
+ Save
+ -- Verify new post is displayed in blog view page.
+
+CRE05 / S1
+ Repeat CRE04, using tags value "a,b".
+
+CRE06 / S1
+ Repeat CRE04, making title "CRE06" and tags value "a".
+
+CRE07 / S1
+ Against CRE06 post, add a new comment by selecting 'Add your comment'
+ Add any text to the comment message, include an uploaded image
+ Save comment
+ -- Verify comment text with image shows.
+
+CRE08 / admin (change)
+ Enter TC1 and enter blog IB01.
+ Against CRE06 post, add a new comment by selecting 'Add your comment'
+ Add any text to the comment message
+ Save comment
+ -- Verify comment text with image shows.
+
+AVL Import pages availability
+=============================
+
+AVL01 / admin
+ Enter TC2 and select blog IB04
+ -- Verify 'Import posts' button is not shown next to New blog post button.
+
+AVL02 / admin
+ Select Edit settings under OU blog administration (Administration block)
+ Check 'Enable post import' checkbox
+ Select Save and display
+ -- Verify 'Import posts' button is now shown next to 'New blog post' button.
+
+AVL03 / admin
+ Enter TC1 and select blog WCB01
+ -- Verify 'Import posts' button is not shown next to New blog post button.
+
+AVL04 / admin
+ Select Edit settings under OU blog administration (Administration block)
+ Check 'Enable post import' checkbox
+ Select Save and display
+ -- Verify warning is shown advising post import cannot be enabled and form is not saved.
+ Exit edit settings page.
+
+SEL Import page selection
+=========================
+
+SEL01 / S1 (change)
+ Enter TC2 and select blog IB04
+ Select the 'Import posts' button
+ -- Verify that the 'Import pages' screen is shown. This should only list the following:
+ -- TC1
+ -- IB01 (3 posts) [Where IB01 is a link]
+ -- IB02 (0 posts) [Where IB02 is not a link]
+ -- [Note that other courses/blogs not setup in this test may appear depending on system content]
+
+SEL02 / S1
+ Select the IB01 link
+ -- Verify page changes, and shows:
+ -- Import from: [TC1 shortname and full name] : IB01
+ -- A table with 'Title', 'Date posted', 'Tags' and 'Include in import' columns
+ -- Table should contain 3 rows:
+ -- CRE06, [Date post was created], a
+ -- Untitled post 1, [Date post was created], a,b
+ -- Untitled post 2, [Date post was created], a,b,c.
+
+SEL03 / S1
+ Select Date posted column heading link
+ -- Verify that posts re-order into reverse order, Date posted should now have an 'up' symbol
+ Select Title column heading link
+ -- Verify that post re-order alphabetically, Title should now have an 'up' symbol
+
+SEL04 / S1
+ Select link on any tag 'a' in the Tag column of the table
+ -- Verify page reloads - information should remain the same. A "[cross] a" link should appear in Tags column header
+ Select link on any tag 'b' in the Tag column of the table
+ -- Verify page reloads - only the two posts with tag b should now show in the table,
+ -- "[cross] a" and "[cross] b" links should appear in Tags column header
+ Select link on tag 'c' in the tag column of the table
+ -- Verify page reloads - only the post with tag c should now show in the table,
+ -- "[cross] a", "[cross] b" and "[cross] c" links should appear in Tags column header
+ Select the icon next to 'c' in Tags column header
+ -- Verify page reloads - the two posts with tag b should now show in the table,
+ -- "[cross] a" and "[cross] b" links should appear in Tags column header.
+
+SEL05 / S1 (JavaScript enabled only)
+ Select 'Select all' link in 'Include in import' column header
+ -- Verify all posts shown have 'Include in import' checked
+ Select 'Select none' link in 'Include in import' column header
+ -- Verify all posts shown have 'Include in import' not checked.
+
+SEL06 / S1
+ Ensure no posts have 'Include in import' checkbox checked
+ Select 'Import posts' button
+ -- Verify page changes and 'No posts selected for import' message displayed
+ Select 'Continue' button
+ -- Verify returned to post selection table.
+
+SEL07 / S1
+ Select 'Cancel' button
+ -- Verify return to blog selection screen.
+
+IMP Import blog pages
+=====================
+
+IMP01/ S1
+ Enter TC2 and select blog IB04, then select 'Import pages' button
+ Select link to IB01 (3 posts)
+ Select 'Include in import' checkbox for all three posts shown
+ Select 'Import posts'
+ -- Verify page changes and 'Importing posts:' is displayed along with a progress bar
+ -- Verify progress bar reaches 100% and message 'Imported 3 posts' is displayed.
+
+IMP02 / S1
+ Select the 'Continue' button
+ -- Verify IB04 main blog view page displayed
+ -- Verify 3 posts now display, check content, tags and attachments against original
+ Select 'Permalink' for post CRE06
+ -- Verify 1 comment is displayed (by user s1), check content.
+
+IMP03 / S1
+ Repeat IMP01
+ -- Verify 'Imported 0 posts' displayed
+ -- Verify message '3 posts to import were identified as conflicts with existing posts.' displayed
+ Select 'Cancel'
+ -- Verify IB04 main blog view page displayed, with 3 posts listed.
+
+IMP04 / S1
+ Repeat IMP01
+ Select 'Import conflicting posts' button
+ -- Verify page changes and 'Importing posts:' is displayed along with a progress bar
+ -- Verify progress bar reaches 100% and message 'Imported 3 posts' is displayed.
+ Repeat IMP02
+ -- Verify as per IMP02, but there are now exact duplicates of all three posts
+
+LPB Import using local Personal blog
+====================================
+
+LPB01 / S1
+ Enter TC2 and select blog IB04, then select 'Import pages' button
+ -- Verify user's personal blog is displayed in blog list according to following rules:
+ -- User has not visited their personal blog - Not displayed
+ -- User has no posts in their personal blog - Displayed, but with no link
+ -- User has posts in their personal blog - Displayed, with link
+ If no personal blog posts available visit the personal blog (/mod/oublog/view.php)
+ Add 1 new post (any content, private visibility) to the personal blog
+ Repeat this test step.
+
+LPB02 / S1
+ Select user S1's personal blog from the Import pages blog list
+ Select any post available to import and start the importing process
+ -- Verify the post imported process completed correctly
+ Select Continue button
+ -- Verify you are returned to user S1's personal blog.
+
+LPB03 / S1
+ Enter the personal blog for user S1 (/mod/oublog/view.php)
+ -- Verify 'Import posts' button is not available.
+
+LPB04 / admin (change)
+ Enter the personal blog for user admin (/mod/oublog/view.php)
+ Select Edit settings under OU blog administration (Administration block)
+ Check 'Enable post import' checkbox
+ Select Save and display
+ -- Verify 'Import posts' button is now shown next to 'New blog post' button.
+
+LPB05/ S1 (change)
+ Enter the personal blog for user S1 (/mod/oublog/view.php), then select 'Import pages' button
+ Select link to IB01
+ Select 'Include in import' checkbox for one post - CRE06
+ Select 'Import posts'
+ -- Verify page changes and 'Importing posts:' is displayed along with a progress bar
+ -- Verify progress bar reaches 100% and message 'Imported 1 posts' is displayed.
+
+LPB06 / S1
+ Select the 'Continue' button
+ -- Verify personal blog view page displayed for user S1
+ -- Verify CRE06 post now displays as a private post, check content, tags and attachments against original
+ Select 'Permalink' for post CRE06
+ -- Verify 1 comment is displayed (by user s1), check content.
+
+RPB Import using remote personal blog
+=====================================
+
+Note that this test requires a separate test server with personal blog enabled(referred to as remote in this test).
+Both servers will need to be configured to enable page importing between them prior to testing.
+The S1 test user must have identical usernames on both servers.
+
+RPB01 / admin
+ Access the remote server
+ Enter the personal blog for user admin (/mod/oublog/view.php)
+ Select Edit settings under OU blog administration (Administration block)
+ Check 'Enable post import' checkbox
+ Select Save and display
+ -- Verify 'Import posts' button is now shown next to 'New blog post' button.
+
+RPB02 / S1 (change)
+ Access the remote server
+ Enter the personal blog for user S1 (/mod/oublog/view.php)
+ Select the 'Blog options' link
+ Alter the blog name to identify that the blog is on the remote server, Save changes
+ Select 'Import posts' button
+ -- Verify a list of courses and blogs is displayed that correspond to the original test server
+ -- Verify course TC1, blog IB01 is displayed.
+
+RPB03 / S1
+ Select blog IB01 from the import posts page
+ -- Verify page changes, and shows:
+ -- Import from: [TC1 shortname and full name] : IB01
+ -- A table with 'Title', 'Date posted', 'Tags' and 'Include in import' columns
+ -- Table should contain 3 rows:
+ -- CRE06, [Date post was created], a
+ -- Untitled post 1, [Date post was created], a,b
+ -- Untitled post 2, [Date post was created], a,b,c.
+
+RPB04 / S1
+ Select 'Include in import' checkbox for all three posts shown
+ Select 'Import posts'
+ -- Verify page changes and 'Importing posts:' is displayed along with a progress bar
+ -- Verify progress bar reaches 100% and message 'Imported 3 posts' is displayed
+ Select the 'Continue' button
+ -- Verify S1 user personal blog view page displayed
+ -- Verify 3 posts now display, check content, tags and attachments against original
+ Select 'Permalink' for post CRE06
+ -- Verify 1 comment is displayed (by user s1), check content.
+
+RPB04 / S1
+ Access original server used in earlier tests
+ Enter TC2 and select blog IB04, then select 'Import pages' button
+ -- Very user S1's personal blog is displayed twice, one name should match name set in RPB02
+
+RPB05 / S1
+ Select link for personal blog on remote server from the import posts page
+ -- Verify a table of posts is displayed; this should include the 3 posts imported in RPB04
+ Select 'Include in import' checkbox for all three posts imported from IB01 in RPB04
+ Select 'Import posts'
+ -- Verify 'Imported 0 posts' displayed
+ -- Verify message '3 posts to import were identified as conflicts with existing posts.' displayed
+ Select 'Import conflicting posts' button
+ -- Verify page changes and 'Importing posts:' is displayed along with a progress bar
+ -- Verify progress bar reaches 100% and message 'Imported 3 posts' is displayed
+ Select the 'Continue' button
+ -- Verify IB04 blog view page displayed
+ -- Verify the 3 posts now display (these have highest post number when looking at permalink url),
+ check content, tags and attachments against original
+ Select 'Permalink' for post CRE06
+ -- Verify 1 comment is displayed (by user s1), check content.
diff --git a/internaldoc/testcase.participation.txt b/internaldoc/testcase.participation.txt
index c9202f4..0b27343 100644
--- a/internaldoc/testcase.participation.txt
+++ b/internaldoc/testcase.participation.txt
@@ -4,6 +4,7 @@ perspective. It is intended to cover most of the UI and features.
NOTE: In this test case, the word 'blog' always refers to the OU blog.
The test steps in this script follow on from each other and aren't independent.
+They may also be used in conjunction with testcase.usagestats, which should be ran second.
Initial setup
@@ -14,6 +15,8 @@ This test case requires:
- a course which has at least two groups defined (G1 and G2).
- two test student users (U S1, who is in group G1, and U S2, in group G2).
- one test teacher (U T1) who is in group G1.
+- (admin must have permissions to create/configure activities)
+- All users should have an avatar (user picture) set for their profile
The test server must have debugging set to DEVELOPER level and to display
errors; during all parts of the test script, there should be no debugging
@@ -22,13 +25,13 @@ warnings.
The completion system must be enabled for (a) the site, and (b) the test
course.
+Show blog usage extra statistics must also be enabled
CRE Creating blogs and data
===========================
CRE01 / admin
- In your test course, create a blog called CRE01 which is set to separate
- groups.
+ In your test course, create a blog called CRE01 which is set to separate groups.
Go to the Permissions page for this blog and set it (if necessary) so
that the Teacher role DOES have the accessallgroups capability in this
blog.
@@ -68,22 +71,59 @@ CRE06 / U T [change]
BSC Basic usage
===============
-BSC01 / U T
+BSC01a / U T
Go to blog CRE01.
- - Verify that there is a button 'Participation by user' alongside the
- 'New blog post' button.
- Click the button. The participation list page should load.
+ - Verify that when either 'Seperate groups' G1 or G2 are selected, there is a button
+ 'New blog post' alongside the 'Participation by user' button.
+ - Verify that the "Blog usage" 'block' on the right, contains two 'blocks';
+ 'My participation summary' and 'Most commented posts'.
+ - Verify that the 'My participation summary' block resembles the following;
+
+ My participation summary
+ ------------------------
+ This user made no posts in this blog.
+ 1 comments
+ U T CRE06
+ avatar -----
+ Tuesday, 17 December 2013, 15:30
+ View my participation
+ ---------------------
+
+ - Verify that clicking the 'CRE06' link opens the viewpost page for the post which contains comment CRE06.
+ Return to the blog view.
+ - Verify that clicking the 'View my participation' link opens the 'User participation' page for
+ the current user, the teacher user.
+ - Confirm that the page contains a time filter selection form, a message box stating;
+ Posts: No posts made during this period.
+ Comments: 1
+ A download button, with post and comment areas beneath.
+
+ Return to the blog view.
+
+BSC01b / U T
+ Click the 'Participation by user' button. The participation list page should load.
- Verify that there is a group dropdown.
Choose group G1 if necessary.
- - Verify that the list of users shows U S1 and U T (everyone who is in
- group G1).
+ - Verify that the list of users shows U S1 and U T (everyone who is in group G1).
- The counts should be:
Posts | Comments
U S1 1 | 0
U T 0 | 1
+BSC01c / U T
+ Click the details link beside the teacher user.
+ - Verify that the time filter form defaults to "Contribution - All time".
+ - Confirm that the comment box beneath states that the user has made no posts in this period,
+ but that one comment has been made.
+ - Verify that the comment area below contains the single comment CRE06 on post
+ CRE04-1 with the text 'Ten'.
+
+BSC01c / U T
+ Click to enable the To date in the time filter form, select the previous days date, and click update.
+ - Verify that there are now neither posts nor comments displayed by the page.
+
BSC02 / U T
- Go to blog CRE02. Click the participation list button.
+ Go to blog CRE02. Click the participation by user button.
- U T should be included on the list even though they did not do anything in
this blog.
- The counts should be:
@@ -101,39 +141,54 @@ BSC03 / U T
U T 0 | 0
BSC04 / U T
- Return to blog CRE02. Click on the 'Detail' link next to U S2.
+ Return to blog CRE02. Click the participation by user button. Click on the 'Detail' link next to U S2.
- Verify that you are taken to a page showing details of all the changes
made by U S2.
- - The page should appear similar to the following:
+ - Verify that the page has a default title 'Contribution - All time' with a date selector form
+ showing date selectors, enabling check boxes and an update button.
+ - The User participation page should appear similar to the following:
+
+ Contribution - All time
+ -----------------------
+ From [?] day month year [] Enable
+ To day month year [] Enable
+ [Update]
+ Posts: 2
+ Comments: 2
Posts by U S2
-------------
+ _29 March 2011, 10:55_
+ Six
+
_CRE05-2_
- 29 March 2011, 10:52
+ 29 March 2011, 10:50
Five
- _29 March 2011, 10:53_
- Six
-
Comments by U S2
----------------
Comment on _CRE04-2_ by _U S1_
CRE05-3
+ 29 March 2011, 10:59
+ Eight
+
+ Comment on _CRE04-2_ by _U S1_
29 March 2011, 10:58
Seven
- Comment on _CRE04-2_ by _U S1_
- 29 March 2011, 10:59
- Eight
+BSC04 / U T
+ Click to enable the 'To' date in the time filter form, select a previous days date, and click update.
+ - Verify that there are now neither posts nor comments displayed by the page.
FIL File download
=================
FIL01 / admin [change]
- Go to the blog CRE01. Select group G1.
+ Go to the blog CRE01. Select group G1. Click the 'Participation by user' button, to enter the
+ User participation page.
- Verify that there is a file download option and CSV is one of the available
formats (or possibly the only available format).
Do a CSV download of the data.
@@ -146,27 +201,31 @@ FIL01 / admin [change]
U T,0,1
FIL02 / admin
- Go to the blog CRE02. Select Details for user U S2.
+ Go to the blog CRE02. Click the 'Participation by user' button. Select Details for user U S2.
+ - Verify that the page has a default title 'Contribution - All time' with a date selector form
+ showing date selectors, enabling check boxes and an update button
- Verify there is a download option with CSV.
Do the CSV download.
- - Verify that download is something like the following, with possible
- differences as noted:
+ - Verify that download is something like the following, with possible differences as noted:
+Note: If opened in Excel the appearance will be tabulated with no commas.
MY-COURSE-SHORTNAME,CRE02,,U S2
Posts
- Date,Time,Title,Content
- 12 May 2011,11:36,CRE05-2,
Five
- 12 May 2011,11:37,,
Six
+ Date, Time, Title, Content, Attachments
+ 12 Dec 2013,11:37,,
Six
+ 12 Dec 2013,11:36,CRE05-2,
Five
+
Comments
- Date,Time,Title,Content,Post author,Post date,Post time,Post title
- 12 May 2011,11:37,CRE05-3,
Seven
,U S1,12 May 2011,11:37,CRE04-2
- 12 May 2011,11:37,,
Eight
,U S1,12 May 2011,11:37,CRE04-2
+ Date, Time, Title, Content, Post author,Post date, Post time, Post title
+ 12 Dec 2013, 11:37, ,
Eight
, U S1, 12 Dec 2013, 11:38, CRE04-2
+ 12 Dec 2013, 11:37, CRE05-3,
Seven
, U S1, 12 Dec 2013, 11:37, CRE04-2
+
FIL03 / admin
Create a new blog (no groups) with title (exactly as shown including
- commas and quotes):
+ commas and quotes): also enable show blog extra usage stats.
Look, another blog"'\
@@ -182,8 +241,7 @@ FIL04 / U S1
Look, yet another text"'\
FIL05 / admin
- Go back to the new blog and download (a) the list page, (b) the details
- page for U S1.
+ Go back to the new blog and download (a) the list page, (b) the details page for U S1.
- Verify that all CSV files are correctly escaped so that the text appears.
@@ -191,20 +249,19 @@ GRD Grading
===========
GRD01 / admin
- Edit the blog CRE01 settings and set grading option to the 'Separate or
- Connected' scale. Save and display.
- Go to participation list.
+ Edit the blog CRE01 settings and set grading option to the 'Separate and Connected ways off knowing' scale.
+ Save and display.
+ Go to the 'Participation by user' page.
- Verify that a Grade column now shows in the table.
- - Verify that it shows existing grade as unset for everyone.
- - Verify that the dropdowns have options as per the scale ('Separate' or
- 'Connected', I think).
+ - Verify that it shows existing grade as unset for everyone, ie 'No grade'.
+ - Verify that the dropdowns have options as per the scale ('Separate' or 'Connected', knowing).
Edit blog settings again and set grading option to the 0..10 numeric scale.
- Save and display. Go to participation list.
- - Verify that grade dropdowns now have options 0..10.
+ Save and display.
+ Go to participation list.
+ - Verify that grade dropdowns now have options 0/10..10/10.
GRD02 / admin
- Edit the blog CRE01 settings and set the completion option to automatic
- completion.
+ Edit the blog CRE01 settings and set the completion option to automatic completion.
In the form, temporarily turn off the grading option.
- Verify that the 'Require grade' checkbox is greyed out.
Turn the grading option back on (to 0..10 numeric scale again).
@@ -212,12 +269,12 @@ GRD02 / admin
Tick the 'Require grade' checkbox and save changes.
GRD03 / U T [change]
- Go to the blog CRE01, group G1, participation list.
- - Verify that Grade column displays and shows existing grade as unset.
+ Go to the blog CRE01, group G1, 'Participation by user' list page.
+ - Verify that Grade column displays and shows existing grade as unset, (ie No grade.)
Change grade for U S1 to 5/10 and U T to 10/10. Click Save grades button.
- Verify that the page reloads and now displays the new grades 5/10, 10/10.
- Change grade for U T back to 'not set'. Click Save grades button.
- - Verify that page reloads and shows U T as 'not set'.
+ Change grade for U T back to 'No grade', (ie 'not set'). Click Save grades button.
+ - Verify that page reloads and shows U T as 'No grade'.
GRD04 / U T
Go to the course gradebook.
@@ -229,8 +286,7 @@ GRD05 / U T
Go to course page.
- Verify that automatic tickbox icon next to the blog is not ticked (this
may mean it's invisible, depending on the icon in use).
- Go to CRE01, group G1, participation list. Click into the details page for
- U T.
+ Go to CRE01, group G1, participation list. Click into the details page for U T.
- Verify that the Grade dropdown is shown at the bottom of the details page
and is currently showing unset.
Change the grade for U T to 7/10 and save.
diff --git a/internaldoc/testcase.usagestats.txt b/internaldoc/testcase.usagestats.txt
new file mode 100644
index 0000000..bf98d50
--- /dev/null
+++ b/internaldoc/testcase.usagestats.txt
@@ -0,0 +1,289 @@
+This script describes steps to test the OU Blog facility that displays blog usage statistics
+from a user perspective. It is intended to cover most of the UI and features.
+
+Note that this feature is intended to display statistics based on blog usage and content,
+and as it is only practical to create a small data set in these tests it is recommended
+to further test the functionality on a system with real data independently.
+
+NOTE: In this test case, the word 'blog' always refers to the OU blog.
+
+The test steps in this script follow on from each other and aren't independent.
+
+
+Initial setup
+=============
+
+This test case requires:
+
+- Two user accounts (admin & student - admin must have permissions to create/configure activities)
+- Both users should have an avatar (user picture) set for their profile
+- A test course in which activities can be added, both test users should be enrolled on this course
+- Two groups [G1 and G2], both test users should be members of G1. admin should be member of G2 also
+- Personal blogs setup on the test system
+- Numerous blog activities with various configurations for testing (see CRE)
+- Numerous blog, posts and comments for testing (see CRE)
+
+The test server must have debugging set to DEVELOPER level and to display
+errors; during all parts of the test script, there should be no debugging
+warnings.
+
+CRE Creating blog and data
+===========================
+
+CRE01 / admin.
+
+ Create a new blog activity 'CRE01' with Intro text "Course-wide blog"
+ Ensure 'Allow comments' set to 'Yes, from logged in users'
+ Ensure Individual blogs set to 'No (blog together on in groups)'
+ Enable 'Show blog usage extra statistics' checkbox
+ Ensure group mode is 'No groups'
+ Save and return to website.
+
+CRE02 / admin.
+
+ Create a new blog activity 'CRE02' with Intro text "Group blog"
+ Ensure 'Allow comments' set to 'Yes, from logged in users'
+ Ensure 'Individual blogs' set to 'No (blog together on in groups)'
+ Tick 'Show blog usage extra statistics' checkbox
+ Set group mode to 'Visible groups'
+ Save and return to course.
+
+CRE03 / admin.
+
+ Create a new blog activity 'CRE03' with Intro text "Individual blog"
+ Ensure 'Allow comments' set to 'Yes, from logged in users'
+ Ensure 'Individual blogs' set to 'Visible individual blogs'
+ Tick Show blog usage extra statistics checkbox
+ Ensure group mode is 'No groups'
+ Save and return to course.
+
+CRE04 / admin
+
+ Enter blog CRE01
+ Select 'New blog post' and add a new blog post, setting title to 'Admin-Post01'
+ Add any message text you like and set Allow comments to 'Yes, from logged in users'
+ Repeat adding another post, this time leaving Title field empty
+ Select 'Add your comment' against Admin-Post01 and add a new comment (no title, any text).
+
+CRE05 / student [change]
+
+ Enter blog CRE01
+ Add a comment against Post01 (no title, any text)
+ Repeat (so you have added two comments to Admin-Post01, there are now three in total)
+ Select 'Add your comment' against the untitled post and add a new comment (no title, any text).
+
+CRE06 / admin
+
+ Repeat steps in CRE04 using blog CRE02, ensuring G1 group is selected as the current blog.
+
+CRE07 / admin
+
+ In blog CRE02 switch to the G2 group blog
+ Select 'New blog post' and add a new blog post, setting title to 'Admin-Post02'
+ Add any message text you like and set Allow comments to 'No'.
+
+CRE08 / student [change]
+
+ Repeat steps in CRE05 using blog CRE02, ensuring G1 group is selected as the current blog.
+
+CRE09 / admin [change]
+
+ From course home page select CRE03 blog
+ Ensure current user is displayed as the Visible individual
+ Repeat steps in CRE04 using this blog.
+
+CRE10 / student [change]
+
+ From course home page select CRE03 blog
+ Select the Admin user from the Visible individual drop-down
+ Repeat steps in CRE05 using this blog.
+
+CRE10 / student
+
+ In CRE03 blog select current user from the Visible individual drop-down
+ Select 'New blog post' and add a new blog post, setting title to 'Student-Post01'
+ Add any message text you like and set Allow comments to 'No comments'.
+
+
+CRS Checking usage 'block' on course-wide blog
+==============================================
+
+CRS01a / admin [change]
+
+ From the course home page access the CRE01 blog
+ -- A 'Blog usage' 'block' should show to the right
+ -- The 'block' should contain only the 'My participation summary' expanded block and 'Most commented posts'
+ as a collapsed button tab.
+ -- There should be three entries in the 'My participation summary' block tab: 2 Posts and 1 Comment.
+ -- (These should display latest first)
+ -- The Untitled post should be at the top.
+ -- Post01 should be after this.
+ -- The Admin user avatar should be to the left of the three entries.
+ -- The post time when created should be displayed below the post titles.
+ -- The post title should link to the post or comment.
+
+CRS01b / admin
+ Click the block title 'Most commented posts'.
+ The 'My participation summary' block should collapse whilst this block expands.
+ The block contains a collapseable time filter, with designated 'Time period' [+]
+ When expanded this gives the option to select three time periods.
+ -- Beneath this there should be two entries in this block tab:
+ -- Post01 should be at the top, showing 2 comments (post creator comments are not counted).
+ -- Untitled post should be after this, showing 1 comment.
+ -- The Admin user's avatar should be to the left of the entries.
+ -- The post time when created should be displayed below the post title.
+ -- The post title should link to the post.
+ -- The 'bar' for Post01 comments should take the full width available in the block.
+ -- The 'bar' for the other post should be half the available width between label and edge of block.
+
+CRS02 / admin
+
+ Still in CRE01 'Blog usage' 'block':
+ Select [+] || [-] link by the current time period heading.
+ -- This should expand/collapse the time filter form.
+ Select Time period 'All time' from drop-down and select Update button
+ (assuming the current filter is not 'All time', select a different time period in this case)
+ Click the 'Update button'.
+ -- A 'spinner' should be shown beside the 'Update' button.
+ -- The time period title should be updated (e.g. to 'All time').
+ -- The description should be updated (e.g. to 'Posts with the most number of comments').
+ -- The list of posts with comments should remain the same, with the small amount of data created.
+ Revisit (refresh) the blog page.
+ -- The previously selected Time period and expand/collapse state should be remembered.
+
+GRP Checking usage 'block' on group blog
+========================================
+
+GRP01 / admin
+
+ From the course home page access the CRE02 blog,
+ Select the Visible group G1.
+ -- A 'Blog usage' 'block' should show to the right.
+ -- The 'block' should contain 'My participation summary', 'Most commented posts' 'Most posts', and 'Most comments' tabs.
+ -- You should be able to expand/collapse each tab by selecting its heading (1 open at a time).
+ -- There should be four entries in the 'My participation summary' tab,
+ -- 3 posts and 1 comment.
+ -- Post 2 should be at the top followed by an Untitled post and then post1.
+ -- There should be 1 untitled comment beneath these posts.
+ -- The user avatar should be to the left of the entries post title and date time,
+ -- each title being a link to the post or comment.
+ -- Beneath the comments should be a link 'View my participation' to the user participation page.
+ -- There should be two entries in the 'Most commented posts' tab - Post01 (2 comments) Untitled post (1 comment).
+ -- There should be two entries in the 'Most posts' tab,
+ -- One for each group, with 2 posts for G1's blog above 1 for G2's.
+ -- The default avatar should be to the left of the entries (unless a group picture is set).
+ -- The blog 'name' should be a link to the group's blog within the activity.
+ -- There should be one entry in the 'Most comments' tab - for G1's blog (3 comments).
+ -- The admin avatar should show against the posts and the title link to the post.
+
+GRP02 / admin
+
+ From the course home page access the CRE02 blog,
+ Select the Visible group 'All participants'.
+ 'Most commented posts' should now list posts with most comments across all group blogs.
+ 'Most posts' and 'Most comments' tabs should be as per GRP01.
+ -- Post01 and Untitled post should be listed as per GRP01, but with addition of link to G1's blog below.
+
+IND Checking usage 'block' on individual blog
+=============================================
+
+IND01 / admin
+
+ From the course home page access the CRE03 blog,
+ Select the Visible individual Admin user.
+ -- A 'Blog usage' 'block' should show to the right.
+ -- The 'block' should contain 'My participation summary', 'Most commented posts' 'Most posts', and 'Most comments' tabs.
+ -- You should be able to expand/collapse each tab by selecting it's heading (1 open at a time).
+ -- There should be three entries in the 'My participation summary' tab,
+ -- 2 posts and 1 comment.
+ -- An Untitled post should be at the top followed by Post01.
+ -- There should be 1 untitled comment beneath these posts.
+ -- The user avatar should be to the left of the entries post title and date time,
+ -- each title being a link to the post.
+ -- Beneath the comments should be a link to the user participation page, 'View my participation'.
+ -- There should be two entries in the 'Most commented posts' tab - Post01 (2 comments) Untitled post (1 comment).
+ -- There should be two entries in the 'Most posts' tab,
+ -- One for each user, with 2 posts for Admin's blog above 1 for the Student's.
+ -- The user's avatar should be to the left of the entries.
+ -- The blog 'name' should be a link to the user's blog within the activity.
+ -- There should be one entry in the 'Most comments' tab - for Admin's blog (3 comments).
+ -- The admin avatar should show against the posts and the title link to the post.
+
+IND02 / admin
+
+ From the course home page access the CRE03 blog,
+ Select the Visible individual 'View all users'.
+ 'My participation summary', 'Most posts' and 'Most comments' tabs should be as per IND01.
+ 'Most commented posts' should now list posts with most comments across all user blogs.
+ -- Post01 and Untitled post should be listed as per IND01, but with addition of link to admin's blog below.
+
+OFF Checking usage 'block' displays appropriately
+=================================================
+
+OFF01 / admin
+
+ From the course home page access blog CRE02,
+ Select Edit settings from the Administration block.
+ Un-tick Show blog usage statistics block - Save and display the activity.
+ -- Only 'My participation summary' and 'Most commented posts' should now be showing in the Blog usage block.
+ Select Edit settings from the Administration block again.
+ Tick Show blog usage extra statistics (turn back on).
+ Update group mode from 'Visible groups' to 'Separate groups',
+ Save and display.
+ -- Only 'My participation summary' and 'Most commented posts' should now be showing in the Blog usage block.
+
+OFF02 / admin
+
+ From the course home page access blog CRE03,
+ Select Edit settings from the Administration block.
+ Update Allow comments to 'Comments not allowed',
+ Save and display.
+ -- Only 'My participation summary' and 'Most posts' should now be showing in the Blog usage block,
+ Select Edit settings from the Administration block.
+ Update 'Individual blogs' to 'Separate individual blogs',
+ Save and display.
+ -- Blog usage block should be showing only 'My participation summary'.
+
+PER Checking personal blog usage
+=================================
+
+PER01 / admin
+
+ Access the user's personal blog via /mod/oublog/view.php
+ Select Edit settings from the Administration block
+ Tick Show blog usage extra statistics
+ Select 'New blog post' and add a new blog post, setting title to 'Post01'
+ Set visibility to 'Visible to anyone in the world'
+ Add any message text you like and set Allow comments to 'Yes, from logged in users'
+ Repeat, adding an untitled post, set visibility to 'Visible to everyone logged in to the system'
+ Select 'Add your comment' against Post01 and add a new comment (no title, any text)
+ Copy the URL to admin student's blog page for use in next step.
+
+PER02 / student
+
+ Access admin's personal blog via /mod/oublog/view.php?user=XXX.
+ Add a new comment against Post01 and add a new comment (no title, any text).
+ Select 'Add your comment' against the untitled post and add a new comment (no title, any text).
+ Return to admin users personal blog main page.
+ Within the Blog usage 'block' select 'Most commented posts'.
+ -- Post01 should be displayed in the list with 1 comment.
+ -- 'Untitled post' should be displayed in the list with 1 comment.
+Note: Depending upon recent use of this blog there may be many comments which would stop these test
+comments appearing, they should show up if the time period is reset to 'Past month'.
+
+PER03 / guest
+
+ In a different browser access admin's personal blog via /mod/oublog/view.php?user=XXX.
+ Within the Blog usage 'block' select 'Most commented posts'.
+ -- Post01 should be displayed in the list with 1 comment.
+ -- Admin user's avatar should not be displayed (default should be shown).
+Note: This is controlled through server settings and works correctly on live systems.
+
+ PER04 / student
+
+ Access admin's personal blog via /mod/oublog/view.php?user=XXX.
+ Select the 'View site entries' link (right block).
+ -- On the Personal blogs page the Blog usage block should be displayed.
+ -- The 'block' should contain 'Most commented posts', 'Most visited', 'Most posts', and 'Most comments' tabs.
+ -- Ensure each tab expands correctly.
+ -- Items in the 'Most commented posts' tab should have links to the user's blog page below.
diff --git a/lang/en/oublog.php b/lang/en/oublog.php
index 7b0b231..114b0d5 100644
--- a/lang/en/oublog.php
+++ b/lang/en/oublog.php
@@ -1,4 +1,19 @@
.
+
$string['attachments'] = "Attachments";
$string['oublog'] = 'OU blog';
$string['modulename'] = 'OU blog';
@@ -12,6 +27,7 @@
$string['oublog:view'] = 'View posts';
$string['oublog:addinstance'] = 'Add a new OU blog';
$string['oublog:viewpersonal'] = 'View posts in personal blogs';
+$string['oublog:viewprivate'] = 'View private posts in personal blogs';
$string['oublog:contributepersonal'] = 'Post and comment in personal blogs';
$string['oublog:post'] = 'Create a new post';
$string['oublog:comment'] = 'Comment on a post';
@@ -24,7 +40,7 @@
$string['oublog:exportpost'] = 'Export post';
$string['oublog:exportposts'] = 'Export posts';
$string['mustprovidepost'] = 'Must provide postid';
-$string['newpost'] = 'New blog post';
+$string['newpost'] = 'New {$a} post';
$string['removeblogs'] = 'Remove all blog entries';
$string['title'] = 'Title';
$string['message'] = 'Message';
@@ -43,17 +59,36 @@
$string['visibility'] = 'Who can read this?';
$string['visibility_help'] = '
Visible to participants on this course – to view the post you must
-have been granted access to the blog, usually by being enrolled on the course that contains it.
+have been granted access to the activity, usually by being enrolled on the course that contains it.
Visible to everyone who is logged in to the system – everyone who is
logged in can view the post, even if they\'re not enrolled on a specific course.
Visible to anyone in the world – any Internet user can see this post
-if you give them the blog\'s address.
';
+if you give them the address.';
$string['maxvisibility'] = 'Maximum visibility';
$string['yes'] = 'Yes';
$string['no'] = 'No';
$string['blogname'] = 'Blog name';
$string['summary'] = 'Summary';
+$string['statblockon'] = 'Show blog usage extra statistics';
+$string['statblockon_help'] = 'Enable extra statistics display in the Blog usage \'block\'.
+Personal (global), Visible Individual and Visible Group blogs only.';
+$string['oublogallpostslogin'] = 'Force login on all posts page';
+$string['oublogallpostslogin_desc'] = 'Enable to force login to the personal blog site entries page.
+When enabled only logged-in users will see the link to this page.';
+
+$string['globalusageexclude'] = 'Exclude from global usage stats';
+$string['globalusageexclude_desc'] = 'Comma-separated list of user ids to exclude users from the top usage stats list for global blog';
+
+$string['introonpost'] = 'Show intro when posting';
+
+$string['displayname_default'] = 'blog';
+$string['displayname'] = 'Alternate activity name (blank uses default)';
+$string['displayname_help'] = 'Set an alternate activity type name within the interface.
+
+Leaving blank/empty will mean the default (\'blog\') is used.
+
+The alternate name should start with a lower-case letter, this will be capitalised where needed.';
$string['visibleyou'] = 'Visible only to the blog owner (private)';
$string['visiblecourseusers'] = 'Visible to participants on this course';
@@ -62,8 +97,8 @@
$string['visiblepublic'] = 'Visible to anyone in the world';
$string['invalidpostid'] = 'Invalid Postid';
-$string['addpost'] = 'Add blog post';
-$string['editpost'] = 'Update blog post';
+$string['addpost'] = 'Add post';
+$string['editpost'] = 'Update post';
$string['editsummary'] = 'Edited by {$a->editby}, {$a->editdate}';
$string['editonsummary'] = 'Edited {$a->editdate}';
@@ -86,20 +121,20 @@
$string['lastcomment'] = '(latest by {$a->fullname}, {$a->timeposted})';
$string['addcomment'] = 'Add comment';
-$string['confirmdeletepost'] = 'Are you sure you want to delete this blog post?';
+$string['confirmdeletepost'] = 'Are you sure you want to delete this post?';
$string['confirmdeletecomment'] = 'Are you sure you want to delete this comment?';
$string['confirmdeletelink'] = 'Are you sure you want to delete this link?';
$string['viewedit'] = 'View edit';
-$string['views'] = 'Total visits to this blog:';
+$string['views'] = 'Total visits to this {$a}:';
$string['addlink'] = 'Add link';
$string['editlink'] = 'Edit link';
$string['links'] = 'Related links';
-$string['subscribefeed'] = 'Subscribe to a feed (requires appropriate software) to receive notification when this blog is updated.';
+$string['subscribefeed'] = 'Subscribe to a feed (requires appropriate software) to receive notification when this {$a} is updated.';
$string['feeds'] = 'Feeds';
-$string['blogfeed'] = 'Blog feeds';
+$string['blogfeed'] = '{$a} feeds';
$string['commentsfeed'] = 'Comments only';
$string['atom'] = 'Atom';
$string['rss'] = 'RSS';
@@ -111,7 +146,7 @@
$string['blogsummary'] = 'Blog summary';
$string['posts'] = 'Posts';
-$string['defaultpersonalblogname'] = '{$a}\'s blog';
+$string['defaultpersonalblogname'] = '{$a->name}\'s {$a->displayname}';
$string['numposts'] = '{$a} posts';
@@ -125,11 +160,12 @@
$string['deletedby'] = 'Deleted by {$a->fullname}, {$a->timedeleted}';
-$string['newcomment'] = 'New blog comment';
+$string['newcomment'] = 'New comment';
+$string['postmessage'] = 'Post';
-$string['searchthisblog'] = 'Search this blog';
-$string['searchblogs'] = 'Search blogs';
-$string['searchthisblog_help'] = 'Type your search term and press Enter or click the button.
+$string['searchthisblog'] = 'Search this {$a}';
+$string['searchblogs'] = 'Search';
+$string['searchblogs_help'] = 'Type your search term and press Enter or click the button.
To search for exact phrases use quote marks.
@@ -142,9 +178,10 @@
$string['bloginfo']='blog information';
$string['feedhelp']='Feeds';
-$string['feedhelp_help']='If you use feeds you can add Atom or RSS links in order to keep up to date with this blog. Most feed readers support Atom and RSS.
+$string['feedhelp_help']='If you use feeds you can add these Atom or RSS links in order to keep up to date with posts.
+Most feed readers support Atom and RSS.
-If the blog allows comments there are feeds for ‘Comments only’.';
+If comments are enabled there are also feeds for ‘Comments only’.';
$string['unsupportedbrowser']='
Your browser cannot display Atom or RSS feeds directly.
Feeds are most useful in separate computer programs or websites. If you want
to use this feed in such a program, copy and paste the address from your browser\'s
@@ -161,14 +198,14 @@
$string['computingguideurl']='Computing guide URL';
$string['computingguideurlexplained']='Enter the URL for the OU blogs omputing guide';
-$string['maybehiddenposts']='This blog might contain posts that are only
+$string['maybehiddenposts']='This {$a->name} might contain posts that are only
visible to logged-in users, or where only logged-in users can comment. If you
-have an account on the system, please log in for full blog access.';
+have an account on the system, please link}\'>log in for full access.';
$string['guestblog']='If you have an account on the system, please
-log in for full blog access.';
-$string['noposts']='There are no visible posts in this blog.';
+log in for full access.';
+$string['noposts']='There are no visible posts in this {$a}.';
-//Errors
+// Errors.
$string['accessdenied']='Sorry: you do not have access to view this page.';
$string['invalidpost'] = 'Invalid Post Id';
$string['invalidcomment'] = 'Invalid Comment Id';
@@ -191,10 +228,6 @@
$string['invalidvisbilitylevel'] = 'Invalid visibility level {$a}';
$string['invalidblogdetails'] = 'Can\'t find details for blog post {$a}';
-
-
-
-
$string['siteentries'] = 'View site entries';
$string['overviewnumentrylog1'] = 'entry since last log in';
$string['overviewnumentrylog'] = 'entries since last log in';
@@ -319,8 +352,8 @@
$string['pluginadministration'] = 'OU Blog administration';
$string['pluginname'] = 'OU Blog';
-//help strings
-$string['allowcomments_help'] = '‘Yes, from signed-on users’ allows comments from users who have access to the blog.
+// Help strings.
+$string['allowcomments_help'] = '‘Yes, from signed-on users’ allows comments from users who have access to the post.
‘Yes, from everybody’ allows comments from users and from the general public. You will receive emails to approve or reject comments from users who are not signed in.
@@ -350,18 +383,18 @@
option is set on the whole blog, that becomes a maximum. For example, if
the whole blog is set to the first level, you cannot change the
level of an individual post at all.
';
-$string['tags_help'] = 'Tags are labels that help you find and categorise blog posts.';
-// Used at OU only
+$string['tags_help'] = 'Tags are labels that help you find and categorise posts.';
+// Used at OU only.
$string['externaldashboardadd'] = 'Add blog to dashboard';
$string['externaldashboardremove'] = 'Remove blog from dashboard';
$string['viewblogdetails'] = 'View blog details';
$string['viewblogposts'] = 'Return to blog';
-// User participation
+// User participation.
$string['oublog:grade'] = 'Grade OU Blog user participation';
$string['oublog:viewparticipation'] = 'View OU Blog user participation';
$string['userparticipation'] = 'User participation';
-$string['myparticipation'] = 'My participation';
+$string['myparticipation'] = 'My participation summary';
$string['savegrades'] = 'Save grades';
$string['participation'] = 'Participation';
$string['participationbyuser'] = 'Participation by user';
@@ -370,21 +403,21 @@
$string['postsby'] = 'Posts by {$a}';
$string['commentsby'] = 'Comments by {$a}';
$string['commentonby'] = 'Comment on {$a->title} by {$a->author}';
-$string['nouserposts'] = 'This user made no posts in this blog.';
-$string['nousercomments'] = 'This user added no comments in this blog.';
+$string['nouserposts'] = 'No posts made.';
+$string['nousercomments'] = 'No comments made.';
$string['savegrades'] = 'Save grades';
$string['gradesupdated'] = 'Grades updated';
$string['usergrade'] = 'User grade';
-// Participation download strings
+// Participation download strings.
$string['downloadas'] = 'Download data as';
$string['postauthor'] = 'Post author';
$string['postdate'] = 'Post date';
$string['posttime'] = 'Post time';
$string['posttitle'] = 'Post title';
-// Export
-$string['exportedpost'] = 'Exported blog post';
+// Export.
+$string['exportedpost'] = 'Exported post';
$string['exportpostscomments'] = ' all currently visible posts and their comments.';
$string['exportuntitledpost'] = 'An untitled post ';
@@ -394,9 +427,15 @@
$string['maxattachmentsize'] = 'Maximum attachment size';
$string['maxattachments'] = 'Maximum number of attachments';
$string['maxattachments_help'] = 'This setting specifies the maximum number of files that can be attached to a blog post.';
-$string['maxattachmentsize_help'] = 'This setting specifies the largest size of file that can be attached to a blog post.';
+$string['maxattachmentsize_help'] = 'This setting specifies the largest size of image/file that can be used in a blog post.';
$string['attachments_help'] = 'You can optionally attach one or more files to a blog post. If you attach an image, it will be displayed after the message.';
+$string['remoteserver'] = 'Import from remote server';
+$string['configremoteserver'] = 'Root address (wwwroot) of remote server to be used for post imports.
+Blogs on this server will be shown in addition to those on local site when importing posts.';
+$string['remotetoken'] = 'Import remote server token';
+$string['configremotetoken'] = 'Web service user token for oublog webservices on import remote server.';
+
$string['reportingemail'] = 'Reporting email addresses';
$string['reportingemail_help'] = 'This setting specifies the email addresses of those who will be informed
about issues with posts or comments within the OUBlog.
@@ -406,3 +445,103 @@
$string['oublog_managealerts'] = 'Manage reported post/comment alerts';
$string['untitledpost'] = 'Untitled post';
$string['untitledcomment'] = 'Untitled comment';
+
+// Discovery block.
+$string['discovery'] = '{$a} usage';
+$string['timefilter_alltime'] = 'All time';
+$string['timefilter_thismonth'] = 'Past month';
+$string['timefilter_thisyear'] = 'Past year';
+$string['timefilter_label'] = 'Time period';
+$string['timefilter_submit'] = 'Update';
+$string['timefilter_open'] = 'Show options';
+$string['timefilter_close'] = 'Hide options';
+$string['visits'] = 'Most visited';
+$string['activeblogs'] = 'Active';
+$string['numberviews'] = '{$a} views';
+$string['visits_info_alltime'] = '{$a}s with the most number of visits';
+$string['visits_info_active'] = 'Active {$a}s (contain a post in the past month) with the most number of visits';
+$string['mostposts'] = 'Most posts';
+$string['numberposts'] = '{$a} posts';
+$string['posts_info_alltime'] = '{$a}s with the most number of posts';
+$string['posts_info_thisyear'] = '{$a}s with the most number of posts in the past year';
+$string['posts_info_thismonth'] = '{$a}s with the most number of posts in the past month';
+$string['mostcomments'] = 'Most comments';
+$string['numbercomments'] = '{$a} comments';
+$string['comments_info_alltime'] = '{$a}s with the most number of comments';
+$string['comments_info_thisyear'] = '{$a}s with the most number of comments added in the past year';
+$string['comments_info_thismonth'] = '{$a}s with the most number of comments added in the past month';
+$string['commentposts'] = 'Most commented posts';
+$string['commentposts_info_alltime'] = 'Posts with the most number of comments';
+$string['commentposts_info_thisyear'] = 'Posts with the most number of comments added in the past year';
+$string['commentposts_info_thismonth'] = 'Posts with the most number of comments added in the past month';
+
+// Delete and Email.
+$string['emailcontenthtml'] = 'This is a notification to advise you that your {$a->activityname} post with the
+following details has been deleted by \'{$a->firstname} {$a->lastname}\':
+
+Subject: {$a->subject}
+{$a->activityname}: {$a->blog}
+Course: {$a->course}
+
+deleteurl} title="view deleted post">View the deleted post';
+$string['deleteemailpostbutton'] = 'Delete and email';
+$string['deleteandemail'] = 'Delete and email';
+$string['emailmessage'] = 'Message';
+$string['cancel'] = 'Cancel';
+$string['deleteemailpostdescription'] = 'Select to delete the post or delete and send a customisable email notification.';
+$string['copytoself'] = 'Send a copy to yourself';
+$string['includepost'] = 'Include post';
+$string['deletedblogpost'] = 'Untitled post.';
+$string['emailerror'] = 'There was an error sending the email';
+$string['sendanddelete'] = 'Send and delete';
+$string['extra_emails'] = 'Email address of other recipients';
+$string['extra_emails_help'] = 'Enter one or more email address(es) separated by spaces or semicolons.';
+
+// Import pages.
+$string['allowimport'] = 'Enable post import';
+$string['allowimport_help'] = 'Allow any user to import pages from other blog activities they have access to.';
+$string['allowimport_invalid'] = 'Posts can only be imported when activity is set to individual mode.';
+$string['import'] = 'Import posts';
+$string['import_notallowed'] = 'Importing posts is disabled for this {$a}.';
+$string['import_step0_nonefound'] = 'You do not have access to any activities where posts can be imported from.';
+$string['import_step0_inst'] = 'Select an activity to import posts from:';
+$string['import_step0_numposts'] = '({$a} posts)';
+$string['import_step1_inst'] = 'Select posts to import:';
+$string['import_step1_from'] = 'Import from:';
+$string['import_step1_table_title'] = 'Title';
+$string['import_step1_table_posted'] = 'Date posted';
+$string['import_step1_table_tags'] = 'Tags';
+$string['import_step1_table_include'] = 'Include in import';
+$string['import_step1_addtag'] = 'Filter by tag - {$a}';
+$string['import_step1_removetag'] = 'Remove tag filter - {$a}';
+$string['import_step1_include_label'] = 'Import post - {$a}';
+$string['import_step1_submit'] = 'Import posts';
+$string['import_step1_all'] = 'Select all';
+$string['import_step1_none'] = 'Select none';
+$string['import_step2_inst'] = 'Importing posts:';
+$string['import_step2_none'] = 'No posts selected for import.';
+$string['import_step2_prog'] = 'Importing in progress';
+$string['import_step2_total'] = 'Imported {$a} posts.';
+$string['import_step2_conflicts'] = '{$a} posts to import were identified as conflicts with existing posts.';
+$string['import_step2_conflicts_submit'] = 'Import conflicting posts';
+
+// My Participation.
+$string['contribution'] = 'Contribution';
+$string['contribution_all'] = 'Contribution - All time';
+$string['contribution_from'] = 'Contribution - From {$a}';
+$string['contribution_to'] = 'Contribution - To {$a}';
+$string['contribution_fromto'] = 'Contribution - From {$a->start} To {$a->end}';
+$string['start'] = 'From';
+$string['end'] = 'To';
+$string['displayperiod'] = 'Contribution selector From date - To date.';
+$string['info'] = 'Participation within the selected period.';
+$string['displayperiod_help'] = '
The default selects all entries.
+
You can select \'From\' a date until todays entries.
+
You can select all entries between a \'From\' date and a \'To\' date.
+
Or you can select from the first entry \'To\' a date
';
+$string['nouserpostsfound'] = 'No posts made during this period.';
+$string['nousercommentsfound'] = 'No comments made during this period.';
+$string['numberpostsmore'] = 'Plus {$a} more posts';
+$string['numbercommentsmore'] = 'Plus {$a} more comments';
+$string['viewmyparticipation'] = 'View my participation';
+$string['timestartenderror'] = 'Selection end date cannot be earlier than the start date';
diff --git a/lib.php b/lib.php
index 3833c33..c6da468 100644
--- a/lib.php
+++ b/lib.php
@@ -256,10 +256,10 @@ function oublog_print_recent_activity($course, $isteacher, $timestart) {
if (!$cm->uservisible) {
continue;
}
- if (!has_capability('mod/oublog:view', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+ if (!has_capability('mod/oublog:view', context_module::instance($cm->id))) {
continue;
}
- if (!has_capability('mod/oublog:view', get_context_instance(CONTEXT_USER, $blog->userid))) {
+ if (!has_capability('mod/oublog:view', context_user::instance($blog->userid))) {
continue;
}
@@ -336,10 +336,10 @@ function oublog_get_recent_mod_activity(&$activities, &$index, $timestart, $cour
if (!$cm->uservisible) {
continue;
}
- if (!has_capability('mod/oublog:view', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+ if (!has_capability('mod/oublog:view', context_module::instance($cm->id))) {
continue;
}
- if (!has_capability('mod/oublog:view', get_context_instance(CONTEXT_USER, $blog->userid))) {
+ if (!has_capability('mod/oublog:view', context_user::instance($blog->userid))) {
continue;
}
@@ -442,55 +442,6 @@ function oublog_cron() {
return true;
}
-
-
-/**
- * Execute post-install custom actions for the module
- *
- * @return boolean true if success, false on error
- */
-function oublog_post_install() {
- global $DB, $CFG;
- require_once('locallib.php');
-
- // Setup the global blog.
- $oublog = new stdClass;
- $oublog->course = SITEID;
- $oublog->name = 'Personal Blogs';
- $oublog->intro = '';
- $oublog->introformat = FORMAT_HTML;
- $oublog->accesstoken = md5(uniqid(rand(), true));
- $oublog->maxvisibility = OUBLOG_VISIBILITY_PUBLIC;
- $oublog->global = 1;
- $oublog->allowcomments = OUBLOG_COMMENTS_ALLOWPUBLIC;
-
- if (!$oublog->id = $DB->insert_record('oublog', $oublog)) {
- return(false);
- }
-
- $mod = new stdClass;
- $mod->course = SITEID;
- $mod->module = $DB->get_field('modules', 'id', array('name'=>'oublog'));
- $mod->instance = $oublog->id;
- $mod->visible = 1;
- $mod->visibleold = 0;
- $mod->section = 1;
-
- if (!$cm = add_course_module($mod)) {
- return(true);
- }
- $mod->id = $cm;
- $mod->coursemodule = $cm;
-
- $mod->section = course_add_cm_to_section($mod->course, $mod->coursemodule, 1);
-
- $DB->update_record('course_modules', $mod);
-
- set_config('oublogsetup', true);
-
- return(true);
-}
-
/**
* Obtains a search document given the ousearch parameters.
* @param object $document Object containing fields from the ousearch documents table
@@ -841,8 +792,9 @@ function oublog_pluginfile($course, $cm, $context, $filearea, $args, $forcedownl
}
// Make sure we're allowed to see it...
-
- if ($filearea != 'summary' && !oublog_can_view_post($post, $USER, $context, $oublog->global)) {
+ // Check if coming from webservice - if so always allow.
+ $ajax = constant('AJAX_SCRIPT') ? true : false;
+ if ($filearea != 'summary' && !$ajax && !oublog_can_view_post($post, $USER, $context, $oublog->global)) {
return false;
}
if ($filearea == 'attachment') {
@@ -933,7 +885,7 @@ function oublog_cm_info_dynamic(cm_info $cm) {
}
if (!has_capability($capability,
context_module::instance($cm->id))) {
- $cm->uservisible = false;
+ $cm->set_user_visible(false);
$cm->set_available(false);
}
}
@@ -1168,7 +1120,7 @@ function oublog_extend_settings_navigation(settings_navigation $settings, naviga
include_once($CFG->dirroot.'/mod/oublog/locallib.php');
if (oublog_oualerts_enabled() && oublog_get_reportingemail($oublog)) {
if (has_capability('report/oualerts:managealerts',
- get_context_instance(CONTEXT_MODULE, $PAGE->cm->id))) {
+ context_module::instance($PAGE->cm->id))) {
$node->add(get_string('oublog_managealerts', 'oublog'),
new moodle_url('/report/oualerts/manage.php', array('cmid' => $PAGE->cm->id,
'coursename' => $PAGE->course->id, 'contextcourseid' => $PAGE->course->id)),
diff --git a/locallib.php b/locallib.php
index 115b7a2..6f60ee3 100644
--- a/locallib.php
+++ b/locallib.php
@@ -27,12 +27,6 @@
* @package oublog
*/
-// OU shared APIs which (for OU system) are present in local, elsewhere
-// are incorporated in module
-@include_once(dirname(__FILE__).'/../../local/transaction_wrapper.php');
-if (!class_exists('transaction_wrapper')) {
- require_once(dirname(__FILE__).'/null_transaction_wrapper.php');
-}
require_once($CFG->libdir . '/portfolio/caller.php');
require_once($CFG->libdir . '/gradelib.php');
require_once($CFG->libdir . '/filelib.php');
@@ -81,6 +75,11 @@
define('OUBLOG_PARTICIPATION_PERPAGE', 100);
/**#@-*/
+// Constants defining stats time filter.
+define('OUBLOG_STATS_TIMEFILTER_ALL', 0);
+define('OUBLOG_STATS_TIMEFILTER_MONTH', 1);
+define('OUBLOG_STATS_TIMEFILTER_YEAR', 2);
+
/**
* Get a blog from a user id
*
@@ -96,7 +95,8 @@ function oublog_get_personal_blog($userid) {
if (!$oubloginstance = $DB->get_record('oublog_instances', array('oublogid'=>$blog->id, 'userid'=>$userid))) {
$user = $DB->get_record('user', array('id'=>$userid));
- oublog_add_bloginstance($blog->id, $userid, get_string('defaultpersonalblogname', 'oublog', fullname($user)));
+ $a = (object) array('name' => fullname($user), 'displayname' => oublog_get_displayname($blog));
+ oublog_add_bloginstance($blog->id, $userid, get_string('defaultpersonalblogname', 'oublog', $a));
if (!$oubloginstance = $DB->get_record('oublog_instances', array('oublogid'=>$blog->id, 'userid'=>$user->id))) {
print_error('invalidblog', 'oublog');
}
@@ -198,11 +198,11 @@ function oublog_can_post($oublog, $bloguserid=0, $cm=null) {
// permission at system level
return $bloguserid==$USER->id &&
has_capability('mod/oublog:contributepersonal',
- get_context_instance(CONTEXT_SYSTEM));
+ context_system::instance());
} else {
// Need specific post permission in this blog
return has_capability('mod/oublog:post',
- get_context_instance(CONTEXT_MODULE, $cm->id));
+ context_module::instance($cm->id));
}
}
@@ -227,9 +227,9 @@ function oublog_can_comment($cm, $oublog, $post) {
$blogok =
(!isloggedin() && $oublog->allowcomments == OUBLOG_COMMENTS_ALLOWPUBLIC) ||
has_capability('mod/oublog:contributepersonal',
- get_context_instance(CONTEXT_SYSTEM));
+ context_system::instance());
} else {
- $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $modcontext = context_module::instance($cm->id);
// Three ways you can comment to a course blog:
$blogok =
@@ -266,38 +266,22 @@ function oublog_can_comment($cm, $oublog, $post) {
}
/**
- * Wrapper around oublog_get_activity_group for increased performance.
+ * Wrapper around groups_get_activity_group.
* @param object $cm Moodle course-module (possibly with extra cache fields)
* @param boolean $update True to update from URL (must be first call on page)
*/
function oublog_get_activity_group($cm, $update=false) {
- if (!isset($cm->activitygroup) || $update) {
- if (isset($cm->activitygroup)) {
- debugging('Update parameter should be used only in first call to ' .
- 'oublog_get_activity_group; please fix this to improve ' .
- 'performance slightly', DEBUG_DEVELOPER);
- }
- $cm->activitygroup = groups_get_activity_group($cm, $update);
- }
- return $cm->activitygroup;
+ return groups_get_activity_group($cm, $update);
}
/**
- * Wrapper around oublog_get_activity_groupmode for increased performance.
+ * Wrapper around groups_get_activity_groupmode.
* @param object $cm Moodle course-module (possibly with extra cache fields)
* @param object $course Optional course parameter; should be included in
* first call in page
*/
function oublog_get_activity_groupmode($cm, $course=null) {
- if (!isset($cm->activitygroupmode)) {
- if (!$course) {
- debugging('Course parameter should be provided in first call to ' .
- 'oublog_get_activity_groupmode; please fix this to improve ' .
- 'performance slightly', DEBUG_DEVELOPER);
- }
- $cm->activitygroupmode = groups_get_activity_groupmode($cm, $course);
- }
- return $cm->activitygroupmode;
+ return groups_get_activity_groupmode($cm, $course);
}
/**
@@ -308,7 +292,14 @@ function oublog_get_activity_groupmode($cm, $course=null) {
* @param object $cm Moodle course-module
*/
function oublog_is_writable_group($cm) {
- $groupmode = oublog_get_activity_groupmode($cm);
+ static $writablecm;
+ if (!isset($writablecm)) {
+ $writablecm = array();
+ }
+ if (!isset($writablecm[$cm->id])) {
+ $writablecm[$cm->id] = array();
+ }
+ $groupmode = oublog_get_activity_groupmode($cm, $cm->course);
if ($groupmode != VISIBLEGROUPS) {
// If no groups, then they must be allowed to access this;
// if separate groups, then because this is defined to only work
@@ -317,16 +308,13 @@ function oublog_is_writable_group($cm) {
return true;
}
$groupid = oublog_get_activity_group($cm);
- if (!isset($cm->writablegroups)) {
- $cm->writablegroups = array();
+ if (isset($writablecm[$cm->id][$groupid])) {
+ return $writablecm[$cm->id][$groupid];
}
- if (isset($cm->writablegroups[$groupid])) {
- return $cm->writablegroups[$groupid];
- }
- $cm->writablegroups[$groupid] = groups_is_member($groupid) ||
+ $writablecm[$cm->id][$groupid] = groups_is_member($groupid) ||
has_capability('moodle/site:accessallgroups',
- get_context_instance(CONTEXT_MODULE, $cm->id));
- return $cm->writablegroups[$groupid];
+ context_module::instance($cm->id));
+ return $writablecm[$cm->id][$groupid];
}
/**
@@ -340,7 +328,7 @@ function oublog_is_writable_group($cm) {
* @return bool
*/
function oublog_can_view_post($post, $user, $context, $personalblog) {
- if ($personalblog && empty($post->userid)) {
+ if (empty($post->userid)) {
// Not sent userid from pluginfile etc so get it.
global $DB;
if ($instance = $DB->get_record('oublog_instances',
@@ -348,15 +336,14 @@ function oublog_can_view_post($post, $user, $context, $personalblog) {
$post->userid = $instance->userid;
}
}
+ // If you dont have capabilities and its not yours, you cant see it.
+ if ($post->deletedby && !has_capability('mod/oublog:manageposts', $context, $user->id) &&
+ ($post->userid !== $user->id)) {
+ return false;
+ }
// Public visibility means everyone
if ($post->visibility == OUBLOG_VISIBILITY_PUBLIC) {
- if (!$post->deletedby || ($post->userid == $user->id ||
- has_capability('mod/oublog:manageposts', $context, $user->id))) {
- // If not deleted, or is and author or has manage cap then show.
- return true;
- } else {
- return false;
- }
+ return true;
}
// Logged-in user visibility means everyone logged in, but no guests
if ($post->visibility==OUBLOG_VISIBILITY_LOGGEDINUSER &&
@@ -372,7 +359,11 @@ function oublog_can_view_post($post, $user, $context, $personalblog) {
// Otherwise this is set to course visibility
if ($personalblog) {
- return $post->userid==$user->id;
+ // Private posts - only same user or has capability viewprivate can see.
+ if (has_capability('mod/oublog:viewprivate', context_system::instance(), $user->id)) {
+ return true;
+ }
+ return $post->userid == $user->id;
} else {
// Check oublog:view capability at module level
// This might not have been checked yet because if the blog is
@@ -396,7 +387,7 @@ function oublog_add_post($post, $cm, $oublog, $course) {
require_once($CFG->libdir . '/completionlib.php');
$post->itemid = $post->message['itemid'];
$post->message = $post->message['text'];
- $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $modcontext = context_module::instance($cm->id);
if (!isset($post->oubloginstancesid)) {
if (!$post->oubloginstancesid = $DB->get_field('oublog_instances', 'id', array('oublogid'=>$post->oublogid, 'userid'=>$post->userid))) {
@@ -410,10 +401,9 @@ function oublog_add_post($post, $cm, $oublog, $course) {
}
// Begin transaction
- $tw=new transaction_wrapper();
+ $tw = $DB->start_delegated_transaction();
if (!$postid = $DB->insert_record('oublog_posts', $post)) {
- $tw->rollback();
return(false);
}
// Now do filestuff.
@@ -429,7 +419,6 @@ function oublog_add_post($post, $cm, $oublog, $course) {
$post->id=$postid; // Needed by the below
if (!oublog_search_update($post, $cm)) {
- $tw->rollback();
return(false);
}
@@ -439,7 +428,7 @@ function oublog_add_post($post, $cm, $oublog, $course) {
$completion->update_state($cm, COMPLETION_COMPLETE);
}
- $tw->commit();
+ $tw->allow_commit();
return($postid);
}
@@ -457,7 +446,7 @@ function oublog_edit_post($post, $cm) {
global $USER, $DB;
$post->itemid = $post->message['itemid'];
$post->message = $post->message['text'];
- $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $modcontext = context_module::instance($cm->id);
if (!isset($post->id) || !$oldpost = $DB->get_record('oublog_posts', array('id'=>$post->id))) {
return(false);
}
@@ -467,7 +456,7 @@ function oublog_edit_post($post, $cm) {
}
// Begin transaction
- $tw=new transaction_wrapper();
+ $tw = $DB->start_delegated_transaction();
// insert edit history
$edit = new stdClass();
@@ -478,7 +467,6 @@ function oublog_edit_post($post, $cm) {
$edit->oldmessage = $oldpost->message;
if (!$editid = $DB->insert_record('oublog_edits', $edit)) {
- $tw->rollback();
return(false);
}
// Get list of files attached to this post and attach them to the edit.
@@ -497,7 +485,6 @@ function oublog_edit_post($post, $cm) {
// Update tags
if (!oublog_update_item_tags($post->oubloginstancesid, $post->id, $post->tags, $post->visibility)) {
- $tw->rollback();
return(false);
}
@@ -510,16 +497,14 @@ function oublog_edit_post($post, $cm) {
}
if (!$DB->update_record('oublog_posts', $post)) {
- $tw->rollback();
return(false);
}
if (!oublog_search_update($post, $cm)) {
- $tw->rollback();
return(false);
}
- $tw->commit();
+ $tw->allow_commit();
return(true);
}
@@ -533,9 +518,11 @@ function oublog_edit_post($post, $cm) {
* @param object $oublog
* @param int $offset
* @param int $userid
+ * @param bool $ignoreprivate set true to not return private posts (global blog only)
* @return mixed all data to print a list of blog posts
*/
-function oublog_get_posts($oublog, $context, $offset=0, $cm, $groupid, $individualid=-1, $userid=null, $tag='', $canaudit=false) {
+function oublog_get_posts($oublog, $context, $offset = 0, $cm, $groupid, $individualid = -1,
+ $userid = null, $tag = '', $canaudit = false, $ignoreprivate = null) {
global $CFG, $USER, $DB;
$params = array();
$sqlwhere = "bi.oublogid = ?";
@@ -558,7 +545,8 @@ function oublog_get_posts($oublog, $context, $offset=0, $cm, $groupid, $individu
}
}
if (!$canaudit) {
- $sqlwhere .= " AND p.deletedby IS NULL ";
+ $sqlwhere .= " AND (p.deletedby IS NULL or bi.userid = ?)";
+ $params[] = $USER->id;
}
if ($tag) {
$sqlwhere .= " AND t.tag = ? ";
@@ -574,7 +562,9 @@ function oublog_get_posts($oublog, $context, $offset=0, $cm, $groupid, $individu
if ($oublog->global) {
// Unless the current user has manageposts capability,
// they cannot view 'private' posts except their own.
- if (!has_capability('mod/oublog:manageposts', context_system::instance())) {
+ if ($ignoreprivate) {
+ $sqlwhere .= ' AND (p.visibility > ' . OUBLOG_VISIBILITY_COURSEUSER . ')';
+ } else if (!has_capability('mod/oublog:manageposts', context_system::instance())) {
$sqlwhere .= " AND (p.visibility >" . OUBLOG_VISIBILITY_COURSEUSER .
" OR (p.visibility = " . OUBLOG_VISIBILITY_COURSEUSER . " AND u.id = ?))";
$params[] = $USER->id;
@@ -588,11 +578,14 @@ function oublog_get_posts($oublog, $context, $offset=0, $cm, $groupid, $individu
}
}
}
+ $usernamefields = get_all_user_name_fields(true, 'u');
+ $delusernamefields = get_all_user_name_fields(true, 'ud', null, 'del');
+ $editusernamefields = get_all_user_name_fields(true, 'ue', null, 'ed');
// Get posts
- $fieldlist = "p.*, bi.oublogid, u.firstname, u.lastname, bi.userid, u.idnumber, u.picture, u.imagealt, u.email, u.username,
- ud.firstname AS delfirstname, ud.lastname AS dellastname,
- ue.firstname AS edfirstname, ue.lastname AS edlastname";
+ $fieldlist = "p.*, bi.oublogid, $usernamefields, bi.userid, u.idnumber, u.picture, u.imagealt, u.email, u.username,
+ $delusernamefields,
+ $editusernamefields";
$from = "FROM {oublog_posts} p
INNER JOIN {oublog_instances} bi ON p.oubloginstancesid = bi.id
INNER JOIN {user} u ON bi.userid = u.id
@@ -653,7 +646,7 @@ function oublog_get_posts($oublog, $context, $offset=0, $cm, $groupid, $individu
$rs->close();
// Get comments for post on the page
- $sql = "SELECT c.id, c.postid, c.timeposted, c.authorname, c.authorip, c.timeapproved, c.userid, u.firstname, u.lastname, u.picture, u.imagealt, u.email, u.idnumber
+ $sql = "SELECT c.id, c.postid, c.timeposted, c.authorname, c.authorip, c.timeapproved, c.userid, $usernamefields, u.picture, u.imagealt, u.email, u.idnumber
FROM {oublog_comments} c
LEFT JOIN {user} u ON c.userid = u.id
WHERE c.postid IN (".implode(",", $postids).") AND c.deletedby IS NULL
@@ -704,11 +697,14 @@ function oublog_get_posts($oublog, $context, $offset=0, $cm, $groupid, $individu
*/
function oublog_get_post($postid, $canaudit=false) {
global $DB;
+ $usernamefields = get_all_user_name_fields(true, 'u');
+ $delusernamefields = get_all_user_name_fields(true, 'ud', null, 'del');
+ $editusernamefields = get_all_user_name_fields(true, 'ue', null, 'ed');
// Get post
- $sql = "SELECT p.*, bi.oublogid, u.firstname, u.lastname, u.picture, u.imagealt, bi.userid, u.idnumber, u.email, u.username,
- ud.firstname AS delfirstname, ud.lastname AS dellastname,
- ue.firstname AS edfirstname, ue.lastname AS edlastname
+ $sql = "SELECT p.*, bi.oublogid, $usernamefields, u.picture, u.imagealt, bi.userid, u.idnumber, u.email, u.username,
+ $delusernamefields,
+ $editusernamefields
FROM {oublog_posts} p
INNER JOIN {oublog_instances} bi ON p.oubloginstancesid = bi.id
INNER JOIN {user} u ON bi.userid = u.id
@@ -736,8 +732,8 @@ function oublog_get_post($postid, $canaudit=false) {
// Get comments for post on the page
if ($post->allowcomments) {
- $sql = "SELECT c.*, u.firstname, u.lastname, u.picture, u.imagealt, u.email, u.idnumber,
- ud.firstname AS delfirstname, ud.lastname AS dellastname
+ $sql = "SELECT c.*, $usernamefields, u.picture, u.imagealt, u.email, u.idnumber,
+ $delusernamefields
FROM {oublog_comments} c
LEFT JOIN {user} u ON c.userid = u.id
LEFT JOIN {user} ud ON c.deletedby = ud.id
@@ -757,7 +753,7 @@ function oublog_get_post($postid, $canaudit=false) {
}
// Get edits for this post
- $sql = "SELECT e.id, e.timeupdated, e.oldtitle, e.userid, u.firstname, u.lastname, u.picture, u.imagealt, u.email, u.idnumber
+ $sql = "SELECT e.id, e.timeupdated, e.oldtitle, e.userid, $usernamefields, u.picture, u.imagealt, u.email, u.idnumber
FROM {oublog_edits} e
INNER JOIN {user} u ON e.userid = u.id
WHERE e.postid = ?
@@ -973,7 +969,9 @@ function oublog_get_tags($oublog, $groupid, $cm, $oubloginstanceid=null, $indivi
foreach ($tags as $idx => $tag) {
$tags[$idx]->weight = round(($tag->count-$min)/$delta*4);
}
- sort($tags);
+ uasort($tags, function($a, $b) {
+ return strcmp ($a->tag, $b->tag);
+ });
}
return($tags);
}
@@ -1057,7 +1055,7 @@ function oublog_add_comment($course, $cm, $oublog, $comment) {
$comment->timeposted = time();
}
// Begin transaction.
- $tw = new transaction_wrapper();
+ $tw = $DB->start_delegated_transaction();
// Prepare comment id for draft area.
$comment->message = '';
$id = $DB->insert_record('oublog_comments', $comment);
@@ -1077,7 +1075,7 @@ function oublog_add_comment($course, $cm, $oublog, $comment) {
}
}
// Commit transaction and return id.
- $tw->commit();
+ $tw->allow_commit();
return $id;
}
@@ -1367,9 +1365,12 @@ function oublog_feed_last_changed($blogid, $bloginstancesid, $postid, $comments)
* @param int $allowedvisibility
* @param int $groupid
* @param object $cm
+ * @param object $oublog
+ * @param int $individualid
* @return array
*/
-function oublog_get_feed_comments($blogid, $bloginstancesid, $postid, $user, $allowedvisibility, $groupid, $cm) {
+function oublog_get_feed_comments($blogid, $bloginstancesid, $postid, $user, $allowedvisibility,
+ $groupid, $cm, $oublog, $individualid = -1) {
global $CFG, $DB;
$params = array();
$items = array();
@@ -1384,24 +1385,28 @@ function oublog_get_feed_comments($blogid, $bloginstancesid, $postid, $user, $al
$sqlwhere = "AND i.oublogid = ? ";
$params[] = $blogid;
}
-
- if (isset($groupid) && $groupid) {
- $sqlwhere .= " AND p.groupid = ? ";
- $params[] = $groupid;
- }
- if (!empty($cm->groupingid)) {
- if ($groups = $DB->get_records('groupings_groups',
- array('groupingid'=>$cm->groupingid), null, 'groupid')) {
- $sqlwhere .= " AND p.groupid ";
- list ($grpssql, $grpsparams) = $DB->get_in_or_equal(array_keys($groups));
- $params = array_merge($params, $grpsparams);
- $sqlwhere .= $grpssql;
+ if ($individualid > 0 || $oublog->individual > OUBLOG_NO_INDIVIDUAL_BLOGS) {
+ $capable = oublog_individual_has_permissions($cm, $oublog, $groupid, $individualid, $user->id);
+ oublog_individual_add_to_sqlwhere($sqlwhere, $params, 'i.userid', $oublog->id, $groupid, $individualid, $capable);
+ } else {
+ if (isset($groupid) && $groupid) {
+ $sqlwhere .= " AND p.groupid = ? ";
+ $params[] = $groupid;
+ } else if (!empty($cm->groupingid)) {
+ if ($groups = $DB->get_records('groupings_groups',
+ array('groupingid' => $cm->groupingid), null, 'groupid')) {
+ $sqlwhere .= " AND p.groupid ";
+ list ($grpssql, $grpsparams) = $DB->get_in_or_equal(array_keys($groups));
+ $params = array_merge($params, $grpsparams);
+ $sqlwhere .= $grpssql;
+ }
}
}
+ $usernamefields = get_all_user_name_fields(true, 'u');
$sql = "SELECT p.title AS posttitle, p.message AS postmessage, c.id, c.postid, c.title,
c.message AS description, c.timeposted AS pubdate, c.authorname, c.authorip,
- c.timeapproved, i.userid, u.firstname, u.lastname, u.picture, u.imagealt,
+ c.timeapproved, i.userid, $usernamefields, u.picture, u.imagealt,
u.email, u.idnumber
FROM {oublog_comments} c
INNER JOIN {oublog_posts} p ON c.postid = p.id
@@ -1412,7 +1417,7 @@ function oublog_get_feed_comments($blogid, $bloginstancesid, $postid, $user, $al
ORDER BY GREATEST(c.timeapproved, c.timeposted) DESC ";
$rs = $DB->get_recordset_sql($sql, $params, 0, OUBLOG_MAX_FEED_ITEMS);
- $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $modcontext = context_module::instance($cm->id);
foreach ($rs as $item) {
$item->link = $CFG->wwwroot.'/mod/oublog/viewpost.php?post='.$item->postid;
@@ -1480,16 +1485,15 @@ function oublog_get_feed_posts($blogid, $bloginstance, $user, $allowedvisibility
$params[] = $blogid;
}
// If individual blog.
- if ($individualid > -1) {
- $capable = oublog_individual_has_permissions($cm, $oublog, $groupid, $individualid);
+ if ($individualid > 0 || $oublog->individual > OUBLOG_NO_INDIVIDUAL_BLOGS) {
+ $capable = oublog_individual_has_permissions($cm, $oublog, $groupid, $individualid, $user->id);
oublog_individual_add_to_sqlwhere($sqlwhere, $params, 'i.userid', $oublog->id, $groupid, $individualid, $capable);
} else {// No individual blog.
if ($groupid) {
$sqlwhere .= " AND p.groupid = ? ";
$params[] = $groupid;
- }
- if (!empty($cm->groupingid)) {
- if ($groups = $DB->get_records('groupings_groups', array('groupingid'=>$cm->groupingid), null, 'groupid')) {
+ } else if (!empty($cm->groupingid)) {
+ if ($groups = $DB->get_records('groupings_groups', array('groupingid' => $cm->groupingid), null, 'groupid')) {
$sqlwhere .= "AND p.groupid IN (".implode(',', array_keys($groups)).") ";
}
}
@@ -1509,9 +1513,10 @@ function oublog_get_feed_posts($blogid, $bloginstance, $user, $allowedvisibility
}
$scheme .= '&tag=';
}
+ $usernamefields = get_all_user_name_fields(true, 'u');
// Get posts
- $sql = "SELECT p.id, p.title, p.message AS description, p.timeposted AS pubdate, i.userid, u.firstname, u.lastname, u.email, u.picture, u.imagealt, u.idnumber
+ $sql = "SELECT p.id, p.title, p.message AS description, p.timeposted AS pubdate, i.userid, $usernamefields, u.email, u.picture, u.imagealt, u.idnumber
FROM {oublog_posts} p
INNER JOIN {oublog_instances} i ON p.oubloginstancesid = i.id
INNER JOIN {user} u ON i.userid = u.id
@@ -1519,7 +1524,7 @@ function oublog_get_feed_posts($blogid, $bloginstance, $user, $allowedvisibility
ORDER BY p.timeposted DESC ";
$rs = $DB->get_recordset_sql($sql, $params, 0, OUBLOG_MAX_FEED_ITEMS);
- $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $modcontext = context_module::instance($cm->id);
foreach ($rs as $item) {
$item->link = $CFG->wwwroot.'/mod/oublog/viewpost.php?post='.$item->id;
$item->author = fullname($item);
@@ -1643,10 +1648,11 @@ function oublog_get_feedblock($oublog, $bloginstance, $groupid, $postid, $cm, $i
$commentsurlrss = oublog_get_feedurl('rss', $oublog, $bloginstance, $groupid, true, $postid, $cm, $individualid);
}
- $html = '
';
-
+if (!$hideunusedblog && $oublog->global) {
+ // Renderer hook so extra info can be added to global blog pages in theme.
+ echo $oublogoutput->render_viewpage_prepost();
+}
// Print the main part of the page.
echo '