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

Compatibility with Moodle 3.3+ #22

Open
wants to merge 2 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
3 changes: 2 additions & 1 deletion format.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
// Make sure all sections are created.
$course = course_get_format($course)->get_course();

course_create_sections_if_missing($course, range(0, $course->numsections));
// Make sure section 0 is created.
course_create_sections_if_missing($course, 0);

if (!empty(course_get_format($course)->msg)) {
echo $OUTPUT->notification(get_string(course_get_format($course)->msg, 'format_socialwall'));
Expand Down
26 changes: 0 additions & 26 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
*/
class format_socialwall extends format_topics {

public static $numsections = 3;

/**
* Custom action after section has been moved in AJAX mode
*
Expand All @@ -49,19 +47,6 @@ public function ajax_section_move() {
return null;
}

/**
* Returns the list of blocks to be automatically added for the newly created course
*
* @return array of default blocks, must contain two keys BLOCK_POS_LEFT and BLOCK_POS_RIGHT
* each of values is an array of block names (for left and right side columns)
*/
public function get_default_blocks() {
return array(
BLOCK_POS_LEFT => array(),
BLOCK_POS_RIGHT => array()
);
}

/**
* The URL to use for the specified course (with section)
*
Expand All @@ -88,7 +73,6 @@ public function get_view_url($section, $options = array()) {
*
* socialwall format uses the following options:
* - coursedisplay
* - numsections
* - hiddensections
*
* @param bool $foreditform
Expand Down Expand Up @@ -124,10 +108,6 @@ public function course_format_options($foreditform = false) {
'default' => $courseconfig->tlnumreplies,
'type' => PARAM_INT,
),
'numsections' => array(
'default' => self::$numsections,
'type' => PARAM_INT,
),
'deleteafterunenrol' => array(
'default' => $courseconfig->deleteafterunenrol,
'type' => PARAM_BOOL
Expand Down Expand Up @@ -195,12 +175,6 @@ public function course_format_options($foreditform = false) {
'element_type' => 'selectyesno',
'help' => 'deletemodspermanently',
'help_component' => 'format_socialwall'
),
'numsections' => array(
// Hidden element needs label value for correct setting of value, because label value is the 3rd parameter for addElement() method.
'label' => self::$numsections,
'element_type' => 'hidden'

)
);
$courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit);
Expand Down
14 changes: 9 additions & 5 deletions pages/post_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ protected function definition() {
if ($action == 'updatepost') {
$buttongroup[] = $mform->createElement('cancel');
}
$mform->addGroup($buttongroup);
$group = $mform->addGroup($buttongroup);
$group->setAttributes(array('class' => 'fgroup_id_group_1'));

// ... htmleditor/texarea to post text.
$canposthtml = has_capability('format/socialwall:posthtml', $context);
Expand Down Expand Up @@ -148,7 +149,9 @@ protected function definition() {
}

if (count($postoptions) > 0) {
$mform->addGroup($postoptions);
$group = $mform->addGroup($postoptions);
$group->setAttributes(array('class' => 'fgroup_id_group_2'));

}

// ... display the activites prepared for the next post only by a teacher.
Expand All @@ -172,7 +175,7 @@ protected function definition() {

if ($canpostfile) {

$uploadfileicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('icon', 'resource')));
$uploadfileicon = $OUTPUT->pix_icon('icon', get_string('uploadafile', 'format_socialwall'), 'resource');
$linktext = $uploadfileicon . get_string('uploadafile', 'format_socialwall');

$url = new moodle_url('/course/view.php', array('id' => $courseid, 'loadfilemanager' => 1));
Expand All @@ -184,13 +187,14 @@ protected function definition() {
$canposturl = (has_capability('format/socialwall:posturl', $context) && (!empty($course->enablestudentupload)));

if ($canposturl) {
$addlinkicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('icon', 'url')));
$addlinkicon = $OUTPUT->pix_icon('icon', get_string('addalink', 'format_socialwall'), 'url');
$at = html_writer::link('#', $addlinkicon . get_string('addalink', 'format_socialwall'), array('id' => 'addalink'));
$attachgroup[] = $mform->createElement('static', 'addalink', '', $at);
}

if (!empty($attachgroup)) {
$mform->addGroup($attachgroup);
$group = $mform->addGroup($attachgroup);
$group->setAttributes(array('class' => 'fgroup_id_group_3'));
}

$loadfilemanager = optional_param('loadfilemanager', 0, PARAM_INT);
Expand Down
3 changes: 1 addition & 2 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ private function get_timeline_author($userid, $authors) {
$postauthor = (object) array('firstname' => '', 'lastname' => get_string('unknownuser', 'format_socialwall'),
'firstnamephonetic' => '', 'lastnamephonetic' => '', 'middlename' => '', 'alternatename' => '');

$attributes = array('src' => $this->output->pix_url('u/user35'));
$o = html_writer::empty_tag('img', $attributes);
$o = $this->output->pix_icon('u/user35', get_string('unknownuser', 'format_socialwall'));
}

$o = html_writer::tag('div', $o, array('class' => 'tl-author'));
Expand Down
12 changes: 8 additions & 4 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
.course-content ul.socialwall li.section .right img.icon { padding: 0 0 4px 0;}
.course-content ul.socialwall li.section .left .section-handle img.icon { padding:0; vertical-align: baseline; }

.format-socialwall #postform {
width: 90%;
}

.format-socialwall #postform .fitem div.fitemtitle {
float: none;
Expand All @@ -29,23 +32,24 @@
margin-right: 5px;
}

.format-socialwall #postform .sw-texarea, #posttext {
.format-socialwall #postform textarea.sw-texarea, #posttext {
width:100%;
}

.format-socialwall #postform #fitem_posttext {
.format-socialwall #postform #fitem_posttext,
.format-socialwall #postform div.sw-texarea {
margin-bottom: 0px;
margin-right: 100px;
}

.format-socialwall #postform #fgroup_id_group_1 {
.format-socialwall #postform .fgroup_id_group_1 {
margin-top:30px;
float:right;
width:100px;
text-align: right;
}

.format-socialwall #postform #fgroup_id_group_2 {
.format-socialwall #postform .fgroup_id_group_2 {
float:left;
}

Expand Down
8 changes: 4 additions & 4 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

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

$plugin->version = 2016022200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2014050800; // Requires this Moodle version.
$plugin->version = 2018030700; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'format_socialwall'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = array('format_topics' => 2014051200);
$plugin->dependencies = array('format_topics' => 2017051500);
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '3.0';
$plugin->release = '3.3';
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,33 @@ M.format_socialwall.addactivityinit = function (data) {

var id = node.get('id').split('_') [1];
var selectedElement = Y.one('#id_recentactivitiesheader .felement label[for="module_' + id + '"]');
var withboost = false;

if (selectedElement === null) {
// Compatibility with boost theme based.
selectedElement = Y.one('#id_recentactivitiesheader .fitem span[data-itemid="' + id + '"]');
withboost = true;

if (selectedElement === null) {
if (M.cfg.developerdebug) {
Y.log("Error: Incompatible theme.");
}
return false;
}
}

var li = Y.Node.create('<li></li>');
var clone = selectedElement.cloneNode(true);
li.append(clone);
var label;

if (withboost) {
label = Y.Node.create('<label for="module_' + id + '"></li>');
li.append(label);
label.append(clone);
} else {
li.append(clone);
}

selectedactivities.append(li);

attachrecentactivitiyids.push(id);
Expand Down Expand Up @@ -124,12 +148,13 @@ M.format_socialwall.addactivityinit = function (data) {

function onClickFilterByType() {

var recentactivities = Y.all('#id_recentactivitiesheader div[id^="fitem_module_"]');
var recentactivities = Y.all('#id_recentactivitiesheader div.fitem');

if (recentactivities) {
recentactivities.hide();
}

var checkedfilterelements = Y.all('#fgroup_id_filterbytype input[id^="type_"]');
var checkedfilterelements = Y.all('#id_filtersheader input[id^="type_"]');

if (checkedfilterelements) {

Expand All @@ -140,6 +165,7 @@ M.format_socialwall.addactivityinit = function (data) {
var type = node.get('id').split('_') [1];

var shownactivities = Y.all('#id_recentactivitiesheader input[name^="module_' + type + '"]');

if (shownactivities) {
shownactivities.each(function (node) {
node.ancestor('.fitem').show();
Expand Down Expand Up @@ -170,7 +196,7 @@ M.format_socialwall.addactivityinit = function (data) {
function onChangeSearchName(searchfield) {

var searchtext = searchfield.get('value');
var recentactivities = Y.all('#id_recentactivitiesheader div[id^="fitem_module_"]');
var recentactivities = Y.all('#id_recentactivitiesheader div.fitem');

if (searchtext.length < 3) {

Expand Down Expand Up @@ -223,7 +249,8 @@ M.format_socialwall.addactivityinit = function (data) {

initDialog();

var typefilter = Y.one('#fgroup_id_filterbytype');
var typefilter = Y.one('#id_filtersheader');

if (typefilter) {
typefilter.delegate('click', function (e) {
onClickFilterByType();
Expand Down Expand Up @@ -251,8 +278,12 @@ M.format_socialwall.addactivityinit = function (data) {

Y.one('window').on('resize', function (e) {
onResizeDialog();
}
);
});

Y.one('#tl-addrecentactivity-form').on('submit', function(e) {
e.preventDefault();
return false;
});
}

initialize();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading