Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added possibility for users to subscribe to blogs #26

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .sams
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ OPTIONAL_SAMS
<Files feed.php>
OPTIONAL_SAMS
</Files>
<Files stats_update.php>
OPTIONAL_SAMS
</Files>
<Files pluginfile.php>
DISABLE_SAMS
</Files>
<Files *.js>
DISABLE_SAMS
</Files>
40 changes: 34 additions & 6 deletions allposts.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@
$url = new moodle_url('/mod/oublog/allposts.php', array('offset' => $offset, 'tag'=>$tag));
$PAGE->set_url($url);

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
oublog_check_view_permissions($oublog, $context, $cm);
$context = context_module::instance($cm->id);
if (!empty($CFG->oublogallpostslogin) && $oublog->maxvisibility == OUBLOG_VISIBILITY_PUBLIC) {
// Set blog visibility temporarily to loggedin user to force login to this page.
$oublog->maxvisibility = OUBLOG_VISIBILITY_LOGGEDINUSER;
oublog_check_view_permissions($oublog, $context, $cm);
$oublog->maxvisibility = OUBLOG_VISIBILITY_PUBLIC;
} else {
oublog_check_view_permissions($oublog, $context, $cm);
}

$oublogoutput = $PAGE->get_renderer('mod_oublog');

Expand Down Expand Up @@ -71,7 +78,7 @@

// Get Posts.
list($posts, $recordcount) = oublog_get_posts($oublog, $context, $offset, $cm, null, -1, null,
$tag, $canaudit);
$tag, $canaudit, true);

$PAGE->set_title(format_string($oublog->name));
$PAGE->set_heading(format_string($course->fullname));
Expand Down Expand Up @@ -118,6 +125,24 @@
$PAGE->blocks->add_fake_block($bc, BLOCK_POS_RIGHT);
}

if ($oublog->statblockon) {
// 'Discovery' block.
$stats = array();
$stats[] = oublog_stats_output_commentpoststats($oublog, $cm, $oublogoutput, false, true);
$stats[] = oublog_stats_output_visitstats($oublog, $cm, $oublogoutput);
$stats[] = oublog_stats_output_poststats($oublog, $cm, $oublogoutput);
$stats[] = oublog_stats_output_commentstats($oublog, $cm, $oublogoutput);
$stats = $oublogoutput->render_stats_container('allposts', $stats);
$bc = new block_contents();
$bc->attributes['id'] = 'oublog-discover';
$bc->attributes['class'] = 'oublog-sideblock block';
$bc->title = get_string('discovery', 'oublog', oublog_get_displayname($oublog, true));
$bc->content = $stats;
if (!empty($stats)) {
$PAGE->blocks->add_fake_block($bc, BLOCK_POS_RIGHT);
}
}

if ($feeds = oublog_get_feedblock($oublog, 'all', '', false, $cm)) {
$bc = new block_contents();
$bc->attributes['id'] = 'oublog-feeds';
Expand All @@ -131,7 +156,10 @@
// Start main column.
print '<div id="middle-column" class="has-right-column">';

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) {
Expand Down Expand Up @@ -162,9 +190,9 @@
// them know if there are no posts in the blog.
if (!isloggedin() || isguestuser()) {
print '<p class="oublog_loginnote">' . get_string('maybehiddenposts', 'oublog',
'bloglogin.php') . '</p>';
(object) array('link' => 'bloglogin.php', 'name' => oublog_get_displayname($oublog))) . '</p>';
} else if (!$posts) {
print '<p class="oublog_noposts">' . get_string('noposts', 'oublog') . '</p>';
print '<p class="oublog_noposts">' . get_string('noposts', 'oublog', oublog_get_displayname($oublog)) . '</p>';
}
print '</div>';
// Finish the page.
Expand Down
2 changes: 1 addition & 1 deletion approve.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

// Require login, it to be your own post, and commenting permission
require_login($course, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
oublog_check_view_permissions($oublog, $context, $cm);
if ($USER->id !== $post->userid ||
!oublog_can_view_post($post, $USER, $context, $oublog->global) ||
Expand Down
3 changes: 2 additions & 1 deletion backup/moodle2/backup_oublog_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ protected function define_structure() {
$oublog = new backup_nested_element('oublog', array('id'), array('name', 'course',
'accesstoken', 'intro', 'introformat', 'allowcomments', 'individual',
'maxbytes', 'maxattachments', 'maxvisibility', 'global', 'views',
'completionposts', 'completioncomments', 'reportingemail'));
'completionposts', 'completioncomments', 'reportingemail', 'displayname',
'statblockon', 'allowimport', 'introonpost'));

$instances = new backup_nested_element('instances');

Expand Down
8 changes: 8 additions & 0 deletions comment_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ public function definition() {
$blogid = $this->_customdata['blogid'];
$postid = $this->_customdata['postid'];
$maxbytes = $this->_customdata['maxbytes'];
$postrender = $this->_customdata['postrender'];

$mform =& $this->_form;

if (!$edit) {
$mform->addElement('header', 'posttext', get_string('postmessage', 'oublog'));
$mform->setExpanded('posttext', false);
$mform->addElement('html', $postrender);
}

$mform->addElement('header', 'general', '');
$mform->setExpanded('general', true);

if ($moderated) {
$mform->addElement('static', '', '',
Expand Down
6 changes: 6 additions & 0 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
'user' => CAP_ALLOW
)
),
'mod/oublog:viewprivate' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'legacy' => array()
),

'mod/oublog:post' => array(

Expand Down
62 changes: 62 additions & 0 deletions db/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Creates personal blog instance (on site front page) after install
*
* @package mod
* @subpackage oublog
* @copyright 2013 The open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

function xmldb_oublog_install() {
global $DB, $CFG;

require_once($CFG->dirroot . '/course/lib.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 = 300;// OUBLOG_VISIBILITY_PUBLIC.
$oublog->global = 1;
$oublog->allowcomments = 2;// 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;
}
set_config('oublogsetup', null);

return true;
}
Loading