mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'wip-MDL-51239-master' of git://github.com/abgreeve/moodle
This commit is contained in:
commit
3e0540b6ec
@ -132,8 +132,12 @@ if ($action === 'delete') {
|
||||
redirect($returnurl);
|
||||
}
|
||||
} else if (blog_user_can_edit_entry($entry)) {
|
||||
$optionsyes = array('entryid'=>$id, 'action'=>'delete', 'confirm'=>1, 'sesskey'=>sesskey(), 'courseid'=>$courseid);
|
||||
$optionsno = array('userid'=>$entry->userid, 'courseid'=>$courseid);
|
||||
$optionsyes = array('entryid' => $id,
|
||||
'action' => 'delete',
|
||||
'confirm' => 1,
|
||||
'sesskey' => sesskey(),
|
||||
'courseid' => $courseid);
|
||||
$optionsno = array('userid' => $entry->userid, 'courseid' => $courseid);
|
||||
$PAGE->set_title("$SITE->shortname: $strblogs");
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
echo $OUTPUT->header();
|
||||
@ -182,9 +186,9 @@ if (!empty($entry->id)) {
|
||||
}
|
||||
|
||||
require_once('edit_form.php');
|
||||
$summaryoptions = array('maxfiles'=> 99, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>true, 'context'=>$sitecontext,
|
||||
'subdirs'=>file_area_contains_subdirs($sitecontext, 'blog', 'post', $entry->id));
|
||||
$attachmentoptions = array('subdirs'=>false, 'maxfiles'=> 99, 'maxbytes'=>$CFG->maxbytes);
|
||||
$summaryoptions = array('maxfiles' => 99, 'maxbytes' => $CFG->maxbytes, 'trusttext' => true, 'context' => $sitecontext,
|
||||
'subdirs' => file_area_contains_subdirs($sitecontext, 'blog', 'post', $entry->id));
|
||||
$attachmentoptions = array('subdirs' => false, 'maxfiles' => 99, 'maxbytes' => $CFG->maxbytes);
|
||||
|
||||
$blogeditform = new blog_edit_form(null, compact('entry',
|
||||
'summaryoptions',
|
||||
|
@ -94,7 +94,7 @@ if (!empty($blogs)) {
|
||||
$editurl = new moodle_url('/blog/external_blog_edit.php', array('id' => $blog->id));
|
||||
$editicon = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('editexternalblog', 'blog')));
|
||||
|
||||
$deletelink = new moodle_url('/blog/external_blogs.php', array('delete' => $blog->id, 'sesskey'=>sesskey()));
|
||||
$deletelink = new moodle_url('/blog/external_blogs.php', array('delete' => $blog->id, 'sesskey' => sesskey()));
|
||||
$deleteicon = $OUTPUT->action_icon($deletelink, new pix_icon('t/delete', get_string('deleteexternalblog', 'blog')));
|
||||
|
||||
$table->data[] = new html_table_row(array($blog->name,
|
||||
|
@ -40,13 +40,13 @@ $search = optional_param('search', null, PARAM_RAW);
|
||||
|
||||
comment::init();
|
||||
|
||||
$url_params = compact('id', 'start', 'tag', 'userid', 'tagid', 'modid', 'entryid', 'groupid', 'courseid', 'search');
|
||||
foreach ($url_params as $var => $val) {
|
||||
$urlparams = compact('id', 'start', 'tag', 'userid', 'tagid', 'modid', 'entryid', 'groupid', 'courseid', 'search');
|
||||
foreach ($urlparams as $var => $val) {
|
||||
if (empty($val)) {
|
||||
unset($url_params[$var]);
|
||||
unset($urlparams[$var]);
|
||||
}
|
||||
}
|
||||
$PAGE->set_url('/blog/index.php', $url_params);
|
||||
$PAGE->set_url('/blog/index.php', $urlparams);
|
||||
|
||||
// Correct tagid if a text tag is provided as a param.
|
||||
if (!empty($tag)) {
|
||||
@ -121,7 +121,7 @@ if (!empty($groupid) && empty($courseid)) {
|
||||
|
||||
if (!$userid && has_capability('moodle/blog:view', $sitecontext) && $CFG->bloglevel > BLOG_USER_LEVEL) {
|
||||
if ($entryid) {
|
||||
if (!$entryobject = $DB->get_record('post', array('id'=>$entryid))) {
|
||||
if (!$entryobject = $DB->get_record('post', array('id' => $entryid))) {
|
||||
print_error('nosuchentry', 'blog');
|
||||
}
|
||||
$userid = $entryobject->userid;
|
||||
@ -148,12 +148,12 @@ if ((empty($courseid) ? true : $courseid == SITEID) && empty($userid)) {
|
||||
print_error('cannotviewsiteblog', 'blog');
|
||||
}
|
||||
|
||||
$COURSE = $DB->get_record('course', array('format'=>'site'));
|
||||
$COURSE = $DB->get_record('course', array('format' => 'site'));
|
||||
$courseid = $COURSE->id;
|
||||
}
|
||||
|
||||
if (!empty($courseid)) {
|
||||
if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ if (!empty($groupid)) {
|
||||
print_error(get_string('invalidgroupid', 'blog'));
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$group->courseid))) {
|
||||
if (!$course = $DB->get_record('course', array('id' => $group->courseid))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ if (!empty($userid)) {
|
||||
print_error('blogdisable', 'blog');
|
||||
}
|
||||
|
||||
if (!$user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
if (!$user = $DB->get_record('user', array('id' => $userid))) {
|
||||
print_error('invaliduserid');
|
||||
}
|
||||
|
||||
|
52
blog/lib.php
52
blog/lib.php
@ -332,9 +332,9 @@ function blog_get_all_options(moodle_page $page, stdClass $userid = null) {
|
||||
$userid = $page->context->instanceid;
|
||||
}
|
||||
// Check the userid var.
|
||||
if (!is_null($userid) && $userid!==$USER->id) {
|
||||
if (!is_null($userid) && $userid !== $USER->id) {
|
||||
// Load the user from the userid... it MUST EXIST throw a wobbly if it doesn't!
|
||||
$user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
|
||||
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
|
||||
} else {
|
||||
$user = null;
|
||||
}
|
||||
@ -350,7 +350,7 @@ function blog_get_all_options(moodle_page $page, stdClass $userid = null) {
|
||||
// Get the options for the user.
|
||||
if ($user !== null and !isguestuser($user)) {
|
||||
// Load for the requested user.
|
||||
$options[CONTEXT_USER+1] = blog_get_options_for_user($user);
|
||||
$options[CONTEXT_USER + 1] = blog_get_options_for_user($user);
|
||||
}
|
||||
// Load for the current user.
|
||||
if (isloggedin() and !isguestuser()) {
|
||||
@ -413,7 +413,7 @@ function blog_get_options_for_user(stdClass $user=null) {
|
||||
// Not the current user, but we can view and its blogs are enabled for SITE or GLOBAL.
|
||||
$options['userentries'] = array(
|
||||
'string' => get_string('viewuserentries', 'blog', fullname($user)),
|
||||
'link' => new moodle_url('/blog/index.php', array('userid'=>$user->id))
|
||||
'link' => new moodle_url('/blog/index.php', array('userid' => $user->id))
|
||||
);
|
||||
} else {
|
||||
// It's the current user.
|
||||
@ -421,14 +421,14 @@ function blog_get_options_for_user(stdClass $user=null) {
|
||||
// We can view our own blogs .... BIG surprise.
|
||||
$options['view'] = array(
|
||||
'string' => get_string('blogentries', 'blog'),
|
||||
'link' => new moodle_url('/blog/index.php', array('userid'=>$USER->id))
|
||||
'link' => new moodle_url('/blog/index.php', array('userid' => $USER->id))
|
||||
);
|
||||
}
|
||||
if (has_capability('moodle/blog:create', $sitecontext)) {
|
||||
// We can add to our own blog.
|
||||
$options['add'] = array(
|
||||
'string' => get_string('addnewentry', 'blog'),
|
||||
'link' => new moodle_url('/blog/edit.php', array('action'=>'add'))
|
||||
'link' => new moodle_url('/blog/edit.php', array('action' => 'add'))
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -560,13 +560,13 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
$a->type = $modulename;
|
||||
$options['moduleview'] = array(
|
||||
'string' => get_string('viewallmodentries', 'blog', $a),
|
||||
'link' => new moodle_url('/blog/index.php', array('modid'=>$module->id))
|
||||
'link' => new moodle_url('/blog/index.php', array('modid' => $module->id))
|
||||
);
|
||||
}
|
||||
// View MY entries about this module.
|
||||
$options['moduleviewmine'] = array(
|
||||
'string' => get_string('viewmyentriesaboutmodule', 'blog', $modulename),
|
||||
'link' => new moodle_url('/blog/index.php', array('modid'=>$module->id, 'userid'=>$USER->id))
|
||||
'link' => new moodle_url('/blog/index.php', array('modid' => $module->id, 'userid' => $USER->id))
|
||||
);
|
||||
if (!empty($user) && ($CFG->bloglevel >= BLOG_SITE_LEVEL)) {
|
||||
// View the given users entries about this module.
|
||||
@ -575,7 +575,7 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
$a->user = fullname($user);
|
||||
$options['moduleviewuser'] = array(
|
||||
'string' => get_string('blogentriesbyuseraboutmodule', 'blog', $a),
|
||||
'link' => new moodle_url('/blog/index.php', array('modid'=>$module->id, 'userid'=>$user->id))
|
||||
'link' => new moodle_url('/blog/index.php', array('modid' => $module->id, 'userid' => $user->id))
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -584,7 +584,7 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
// The user can blog about this module.
|
||||
$options['moduleadd'] = array(
|
||||
'string' => get_string('blogaboutthismodule', 'blog', $modulename),
|
||||
'link' => new moodle_url('/blog/edit.php', array('action'=>'add', 'modid'=>$module->id))
|
||||
'link' => new moodle_url('/blog/edit.php', array('action' => 'add', 'modid' => $module->id))
|
||||
);
|
||||
}
|
||||
// Cache the options.
|
||||
@ -673,7 +673,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
$headers['filters']['module'] = $modid;
|
||||
// A groupid param may conflict with this coursemod's courseid. Ignore groupid in that case.
|
||||
$courseid = $DB->get_field('course_modules', 'course', array('id'=>$modid));
|
||||
$courseid = $DB->get_field('course_modules', 'course', array('id' => $modid));
|
||||
$course = $DB->get_record('course', array('id' => $courseid));
|
||||
$cm = $DB->get_record('course_modules', array('id' => $modid));
|
||||
$cm->modname = $DB->get_field('modules', 'name', array('id' => $cm->module));
|
||||
@ -861,7 +861,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
if (!empty($tagid)) {
|
||||
$headers['filters']['tag'] = $tagid;
|
||||
$blogurl->param('tagid', $tagid);
|
||||
$tagrec = $DB->get_record('tag', array('id'=>$tagid));
|
||||
$tagrec = $DB->get_record('tag', array('id' => $tagid));
|
||||
$PAGE->navbar->add($tagrec->name, $blogurl);
|
||||
} else if (!empty($tag)) {
|
||||
if ($tagrec = $DB->get_record('tag', array('name' => $tag))) {
|
||||
@ -921,7 +921,7 @@ function blog_get_associated_count($courseid, $cmid=null) {
|
||||
* @package core_blog
|
||||
* @category comment
|
||||
*
|
||||
* @param stdClass $comment_param {
|
||||
* @param stdClass $commentparam {
|
||||
* context => context the context object
|
||||
* courseid => int course id
|
||||
* cm => stdClass course module object
|
||||
@ -930,11 +930,11 @@ function blog_get_associated_count($courseid, $cmid=null) {
|
||||
* }
|
||||
* @return array
|
||||
*/
|
||||
function blog_comment_permissions($comment_param) {
|
||||
function blog_comment_permissions($commentparam) {
|
||||
global $DB;
|
||||
|
||||
// If blog is public and current user is guest, then don't let him post comments.
|
||||
$blogentry = $DB->get_record('post', array('id' => $comment_param->itemid), 'publishstate', MUST_EXIST);
|
||||
$blogentry = $DB->get_record('post', array('id' => $commentparam->itemid), 'publishstate', MUST_EXIST);
|
||||
|
||||
if ($blogentry->publishstate != 'public') {
|
||||
if (!isloggedin() || isguestuser()) {
|
||||
@ -959,7 +959,7 @@ function blog_comment_permissions($comment_param) {
|
||||
* }
|
||||
* @return boolean
|
||||
*/
|
||||
function blog_comment_validate($comment_param) {
|
||||
function blog_comment_validate($commentparam) {
|
||||
global $CFG, $DB, $USER;
|
||||
|
||||
// Check if blogs are enabled user can comment.
|
||||
@ -968,22 +968,22 @@ function blog_comment_validate($comment_param) {
|
||||
}
|
||||
|
||||
// Validate comment area.
|
||||
if ($comment_param->commentarea != 'format_blog') {
|
||||
if ($commentparam->commentarea != 'format_blog') {
|
||||
throw new comment_exception('invalidcommentarea');
|
||||
}
|
||||
|
||||
$blogentry = $DB->get_record('post', array('id' => $comment_param->itemid), '*', MUST_EXIST);
|
||||
$blogentry = $DB->get_record('post', array('id' => $commentparam->itemid), '*', MUST_EXIST);
|
||||
|
||||
// Validation for comment deletion.
|
||||
if (!empty($comment_param->commentid)) {
|
||||
if ($record = $DB->get_record('comments', array('id'=>$comment_param->commentid))) {
|
||||
if (!empty($commentparam->commentid)) {
|
||||
if ($record = $DB->get_record('comments', array('id' => $commentparam->commentid))) {
|
||||
if ($record->commentarea != 'format_blog') {
|
||||
throw new comment_exception('invalidcommentarea');
|
||||
}
|
||||
if ($record->contextid != $comment_param->context->id) {
|
||||
if ($record->contextid != $commentparam->context->id) {
|
||||
throw new comment_exception('invalidcontext');
|
||||
}
|
||||
if ($record->itemid != $comment_param->itemid) {
|
||||
if ($record->itemid != $commentparam->itemid) {
|
||||
throw new comment_exception('invalidcommentitemid');
|
||||
}
|
||||
} else {
|
||||
@ -1005,10 +1005,10 @@ function blog_comment_validate($comment_param) {
|
||||
*/
|
||||
function blog_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
return array(
|
||||
'*'=>get_string('page-x', 'pagetype'),
|
||||
'blog-*'=>get_string('page-blog-x', 'blog'),
|
||||
'blog-index'=>get_string('page-blog-index', 'blog'),
|
||||
'blog-edit'=>get_string('page-blog-edit', 'blog')
|
||||
'*' => get_string('page-x', 'pagetype'),
|
||||
'blog-*' => get_string('page-blog-x', 'blog'),
|
||||
'blog-index' => get_string('page-blog-index', 'blog'),
|
||||
'blog-edit' => get_string('page-blog-edit', 'blog')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ class blog_entry implements renderable {
|
||||
|
||||
$this->renderable = new StdClass();
|
||||
|
||||
$this->renderable->user = $DB->get_record('user', array('id'=>$this->userid));
|
||||
$this->renderable->user = $DB->get_record('user', array('id' => $this->userid));
|
||||
|
||||
// Entry comments.
|
||||
if (!empty($CFG->usecomments) and $CFG->blogusecomments) {
|
||||
@ -163,7 +163,7 @@ class blog_entry implements renderable {
|
||||
$associations[$key]->contextlevel = $context->contextlevel;
|
||||
|
||||
// Course associations.
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
// TODO: performance!!!!
|
||||
$instancename = $DB->get_field('course', 'shortname', array('id' => $context->instanceid));
|
||||
|
||||
@ -174,7 +174,7 @@ class blog_entry implements renderable {
|
||||
}
|
||||
|
||||
// Mod associations.
|
||||
if ($context->contextlevel == CONTEXT_MODULE) {
|
||||
if ($context->contextlevel == CONTEXT_MODULE) {
|
||||
|
||||
// Getting the activity type and the activity instance id.
|
||||
$sql = 'SELECT cm.instance, m.name FROM {course_modules} cm
|
||||
@ -653,7 +653,7 @@ class blog_listing {
|
||||
$assocexists = $DB->record_exists('blog_association', array());
|
||||
|
||||
// Begin permission sql clause.
|
||||
$permissionsql = '(p.userid = ? ';
|
||||
$permissionsql = '(p.userid = ? ';
|
||||
$params[] = $userid;
|
||||
|
||||
if ($CFG->bloglevel >= BLOG_SITE_LEVEL) { // Add permission to view site-level entries.
|
||||
|
@ -141,10 +141,10 @@ class core_blog_renderer extends plugin_renderer_base {
|
||||
if ($officialtags) {
|
||||
$o .= get_string('tags', 'tag') .': '. $this->output->container($officialtags, 'officialblogtags');
|
||||
if ($defaulttags) {
|
||||
$o .= ', ';
|
||||
$o .= ', ';
|
||||
}
|
||||
}
|
||||
$o .= $defaulttags;
|
||||
$o .= $defaulttags;
|
||||
$o .= $this->output->container_end();
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ class core_blog_renderer extends plugin_renderer_base {
|
||||
$assocstr = '';
|
||||
$coursesarray = array();
|
||||
foreach ($entry->renderable->blogassociations as $assocrec) {
|
||||
if ($assocrec->contextlevel == CONTEXT_COURSE) {
|
||||
if ($assocrec->contextlevel == CONTEXT_COURSE) {
|
||||
$coursesarray[] = $this->output->action_icon($assocrec->url, $assocrec->icon, null, array(), true);
|
||||
}
|
||||
}
|
||||
@ -166,7 +166,7 @@ class core_blog_renderer extends plugin_renderer_base {
|
||||
// Now show mod association.
|
||||
$modulesarray = array();
|
||||
foreach ($entry->renderable->blogassociations as $assocrec) {
|
||||
if ($assocrec->contextlevel == CONTEXT_MODULE) {
|
||||
if ($assocrec->contextlevel == CONTEXT_MODULE) {
|
||||
$str = get_string('associated', 'blog', $assocrec->type) . ': ';
|
||||
$str .= $this->output->action_icon($assocrec->url, $assocrec->icon, null, array(), true);
|
||||
$modulesarray[] = $str;
|
||||
|
@ -35,7 +35,7 @@ require_once($CFG->dirroot .'/blog/lib.php');
|
||||
* @param int $tagid The id of the row in the tag table that identifies the RSS Feed
|
||||
* @return string
|
||||
*/
|
||||
function blog_rss_get_url($contextid, $userid, $filtertype, $filterselect=0, $tagid=0) {
|
||||
function blog_rss_get_url($contextid, $userid, $filtertype, $filterselect = 0, $tagid = 0) {
|
||||
$componentname = 'blog';
|
||||
|
||||
$additionalargs = null;
|
||||
@ -70,7 +70,7 @@ function blog_rss_get_url($contextid, $userid, $filtertype, $filterselect=0, $ta
|
||||
* @param int $tagid The id of the row in the tag table that identifies the RSS Feed
|
||||
* @param string $tooltiptext The tooltip to be displayed with the link
|
||||
*/
|
||||
function blog_rss_print_link($context, $filtertype, $filterselect=0, $tagid=0, $tooltiptext='') {
|
||||
function blog_rss_print_link($context, $filtertype, $filterselect = 0, $tagid = 0, $tooltiptext = '') {
|
||||
global $CFG, $USER, $OUTPUT;
|
||||
|
||||
if (!isloggedin()) {
|
||||
@ -93,7 +93,7 @@ function blog_rss_print_link($context, $filtertype, $filterselect=0, $tagid=0, $
|
||||
* @param int $filterselect The id of the item defined by $filtertype
|
||||
* @param int $tagid The id of the row in the tag table that identifies the RSS Feed
|
||||
*/
|
||||
function blog_rss_add_http_header($context, $title, $filtertype, $filterselect=0, $tagid=0) {
|
||||
function blog_rss_add_http_header($context, $title, $filtertype, $filterselect = 0, $tagid = 0) {
|
||||
global $PAGE, $USER, $CFG;
|
||||
|
||||
if (!isloggedin()) {
|
||||
@ -168,7 +168,7 @@ function blog_rss_get_feed($context, $args) {
|
||||
$type = clean_param($args[3], PARAM_ALPHA);
|
||||
$id = clean_param($args[4], PARAM_INT); // Could be groupid / courseid / userid depending on $type.
|
||||
|
||||
$tagid=0;
|
||||
$tagid = 0;
|
||||
if ($args[5] != 'rss.xml') {
|
||||
$tagid = clean_param($args[5], PARAM_INT);
|
||||
} else {
|
||||
@ -234,10 +234,10 @@ function blog_rss_get_feed($context, $args) {
|
||||
|
||||
switch ($type) {
|
||||
case 'user':
|
||||
$info = fullname($DB->get_record('user', array('id'=>$id), 'firstname,lastname'));
|
||||
$info = fullname($DB->get_record('user', array('id' => $id), 'firstname,lastname'));
|
||||
break;
|
||||
case 'course':
|
||||
$info = $DB->get_field('course', 'fullname', array('id'=>$id));
|
||||
$info = $DB->get_field('course', 'fullname', array('id' => $id));
|
||||
$info = format_string($info, true, array('context' => context_course::instance($id)));
|
||||
break;
|
||||
case 'site':
|
||||
@ -245,7 +245,7 @@ function blog_rss_get_feed($context, $args) {
|
||||
break;
|
||||
case 'group':
|
||||
$group = groups_get_group($id);
|
||||
$info = $group->name; // TODO: $DB->get_field('groups', 'name', array('id'=>$id)).
|
||||
$info = $group->name; // TODO: $DB->get_field('groups', 'name', array('id' => $id)).
|
||||
break;
|
||||
default:
|
||||
$info = '';
|
||||
@ -253,7 +253,7 @@ function blog_rss_get_feed($context, $args) {
|
||||
}
|
||||
|
||||
if ($tagid) {
|
||||
$info .= ': '.$DB->get_field('tags', 'text', array('id'=>$tagid));
|
||||
$info .= ': '.$DB->get_field('tags', 'text', array('id' => $tagid));
|
||||
}
|
||||
|
||||
$header = rss_standard_header(get_string($type.'blog', 'blog', $info),
|
||||
@ -279,7 +279,7 @@ function blog_rss_get_feed($context, $args) {
|
||||
* @param int $tagid The id of the row in the tag table that identifies the RSS Feed
|
||||
* @return string
|
||||
*/
|
||||
function blog_rss_file_name($type, $id, $tagid=0) {
|
||||
function blog_rss_file_name($type, $id, $tagid = 0) {
|
||||
global $CFG;
|
||||
|
||||
if ($tagid) {
|
||||
@ -298,7 +298,7 @@ function blog_rss_file_name($type, $id, $tagid=0) {
|
||||
* @param string $contents The contents of the RSS Feed file
|
||||
* @return bool whether the save was successful or not
|
||||
*/
|
||||
function blog_rss_save_file($type, $id, $tagid=0, $contents='') {
|
||||
function blog_rss_save_file($type, $id, $tagid = 0, $contents = '') {
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
@ -46,9 +46,9 @@ class core_bloglib_testcase extends advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Create default course.
|
||||
$course = $this->getDataGenerator()->create_course(array('category'=>1, 'shortname'=>'ANON'));
|
||||
$course = $this->getDataGenerator()->create_course(array('category' => 1, 'shortname' => 'ANON'));
|
||||
$this->assertNotEmpty($course);
|
||||
$page = $this->getDataGenerator()->create_module('page', array('course'=>$course->id));
|
||||
$page = $this->getDataGenerator()->create_module('page', array('course' => $course->id));
|
||||
$this->assertNotEmpty($page);
|
||||
|
||||
// Create default group.
|
||||
@ -58,7 +58,11 @@ class core_bloglib_testcase extends advanced_testcase {
|
||||
$group->id = $DB->insert_record('groups', $group);
|
||||
|
||||
// Create default user.
|
||||
$user = $this->getDataGenerator()->create_user(array('username'=>'testuser', 'firstname'=>'Jimmy', 'lastname'=>'Kinnon'));
|
||||
$user = $this->getDataGenerator()->create_user(array(
|
||||
'username' => 'testuser',
|
||||
'firstname' => 'Jimmy',
|
||||
'lastname' => 'Kinnon'
|
||||
));
|
||||
|
||||
// Create default tag.
|
||||
$tag = new stdClass();
|
||||
@ -91,35 +95,35 @@ class core_bloglib_testcase extends advanced_testcase {
|
||||
// Try all the filters at once: Only the entry filter is active.
|
||||
$filters = array('site' => $SITE->id, 'course' => $this->courseid, 'module' => $this->cmid,
|
||||
'group' => $this->groupid, 'user' => $this->userid, 'tag' => $this->tagid, 'entry' => $this->postid);
|
||||
$blog_listing = new blog_listing($filters);
|
||||
$this->assertFalse(array_key_exists('site', $blog_listing->filters));
|
||||
$this->assertFalse(array_key_exists('course', $blog_listing->filters));
|
||||
$this->assertFalse(array_key_exists('module', $blog_listing->filters));
|
||||
$this->assertFalse(array_key_exists('group', $blog_listing->filters));
|
||||
$this->assertFalse(array_key_exists('user', $blog_listing->filters));
|
||||
$this->assertFalse(array_key_exists('tag', $blog_listing->filters));
|
||||
$this->assertTrue(array_key_exists('entry', $blog_listing->filters));
|
||||
$bloglisting = new blog_listing($filters);
|
||||
$this->assertFalse(array_key_exists('site', $bloglisting->filters));
|
||||
$this->assertFalse(array_key_exists('course', $bloglisting->filters));
|
||||
$this->assertFalse(array_key_exists('module', $bloglisting->filters));
|
||||
$this->assertFalse(array_key_exists('group', $bloglisting->filters));
|
||||
$this->assertFalse(array_key_exists('user', $bloglisting->filters));
|
||||
$this->assertFalse(array_key_exists('tag', $bloglisting->filters));
|
||||
$this->assertTrue(array_key_exists('entry', $bloglisting->filters));
|
||||
|
||||
// Again, but without the entry filter: This time, the tag, user and module filters are active.
|
||||
$filters = array('site' => $SITE->id, 'course' => $this->courseid, 'module' => $this->cmid,
|
||||
'group' => $this->groupid, 'user' => $this->userid, 'tag' => $this->postid);
|
||||
$blog_listing = new blog_listing($filters);
|
||||
$this->assertFalse(array_key_exists('site', $blog_listing->filters));
|
||||
$this->assertFalse(array_key_exists('course', $blog_listing->filters));
|
||||
$this->assertFalse(array_key_exists('group', $blog_listing->filters));
|
||||
$this->assertTrue(array_key_exists('module', $blog_listing->filters));
|
||||
$this->assertTrue(array_key_exists('user', $blog_listing->filters));
|
||||
$this->assertTrue(array_key_exists('tag', $blog_listing->filters));
|
||||
$bloglisting = new blog_listing($filters);
|
||||
$this->assertFalse(array_key_exists('site', $bloglisting->filters));
|
||||
$this->assertFalse(array_key_exists('course', $bloglisting->filters));
|
||||
$this->assertFalse(array_key_exists('group', $bloglisting->filters));
|
||||
$this->assertTrue(array_key_exists('module', $bloglisting->filters));
|
||||
$this->assertTrue(array_key_exists('user', $bloglisting->filters));
|
||||
$this->assertTrue(array_key_exists('tag', $bloglisting->filters));
|
||||
|
||||
// We should get the same result by removing the 3 inactive filters: site, course and group.
|
||||
$filters = array('module' => $this->cmid, 'user' => $this->userid, 'tag' => $this->tagid);
|
||||
$blog_listing = new blog_listing($filters);
|
||||
$this->assertFalse(array_key_exists('site', $blog_listing->filters));
|
||||
$this->assertFalse(array_key_exists('course', $blog_listing->filters));
|
||||
$this->assertFalse(array_key_exists('group', $blog_listing->filters));
|
||||
$this->assertTrue(array_key_exists('module', $blog_listing->filters));
|
||||
$this->assertTrue(array_key_exists('user', $blog_listing->filters));
|
||||
$this->assertTrue(array_key_exists('tag', $blog_listing->filters));
|
||||
$bloglisting = new blog_listing($filters);
|
||||
$this->assertFalse(array_key_exists('site', $bloglisting->filters));
|
||||
$this->assertFalse(array_key_exists('course', $bloglisting->filters));
|
||||
$this->assertFalse(array_key_exists('group', $bloglisting->filters));
|
||||
$this->assertTrue(array_key_exists('module', $bloglisting->filters));
|
||||
$this->assertTrue(array_key_exists('user', $bloglisting->filters));
|
||||
$this->assertTrue(array_key_exists('tag', $bloglisting->filters));
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user