mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 14:02:32 +02:00
MDL-33774 instead of checking that activity is label we check that it has view url
This commit is contained in:
parent
3008f86c3f
commit
9ecb50e6e3
@ -113,7 +113,8 @@ class block_recent_activity extends block_base {
|
||||
* Returns list of recent changes in course structure
|
||||
*
|
||||
* It includes adding, editing or deleting of the resources or activities
|
||||
* Excludes changes on labels, and also if activity was both added and deleted
|
||||
* Excludes changes on modules without a view link (i.e. labels), and also
|
||||
* if activity was both added and deleted
|
||||
*
|
||||
* @return array array of changes. Each element is an array containing attributes:
|
||||
* 'action' - one of: 'add mod', 'update mod', 'delete mod'
|
||||
@ -135,13 +136,6 @@ class block_recent_activity extends block_base {
|
||||
foreach ($logs as $key => $log) {
|
||||
$info = explode(' ', $log->info);
|
||||
|
||||
// note: in most cases I replaced hardcoding of label with use of
|
||||
// $cm->has_view() but it was not possible to do this here because
|
||||
// we don't necessarily have the $cm for it
|
||||
if ($info[0] == 'label') { // Labels are ignored in recent activity
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($info) != 2) {
|
||||
debugging("Incorrect log entry info: id = ".$log->id, DEBUG_DEVELOPER);
|
||||
continue;
|
||||
@ -151,6 +145,11 @@ class block_recent_activity extends block_base {
|
||||
$instanceid = $info[1];
|
||||
|
||||
if ($log->action == 'delete mod') {
|
||||
if (plugin_supports('mod', $modname, FEATURE_NO_VIEW_LINK, false)) {
|
||||
// we should better call cm_info::has_view() because it can be
|
||||
// dynamic. But there is no instance of cm_info now
|
||||
continue;
|
||||
}
|
||||
// unfortunately we do not know if the mod was visible
|
||||
if (!array_key_exists($log->info, $newgones)) {
|
||||
$changelist[$log->info] = array('action' => $log->action,
|
||||
@ -168,7 +167,7 @@ class block_recent_activity extends block_base {
|
||||
continue;
|
||||
}
|
||||
$cm = $modinfo->instances[$modname][$instanceid];
|
||||
if ($cm->uservisible && empty($changelist[$log->info])) {
|
||||
if ($cm->has_view() && $cm->uservisible && empty($changelist[$log->info])) {
|
||||
$changelist[$log->info] = array('action' => $log->action, 'module' => $cm);
|
||||
}
|
||||
}
|
||||
|
@ -2531,7 +2531,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
|
||||
$actions = array();
|
||||
|
||||
// AJAX edit title
|
||||
if ($mod->modname !== 'label' && $hasmanageactivities &&
|
||||
if ($mod->has_view() && $hasmanageactivities &&
|
||||
(($mod->course == $COURSE->id && course_ajax_enabled($COURSE)) ||
|
||||
($mod->course == SITEID && course_ajax_enabled($SITE)))) {
|
||||
// we will not display link if we are on some other-course page (where we should not see this module anyway)
|
||||
|
37
course/yui/toolboxes/toolboxes.js
vendored
37
course/yui/toolboxes/toolboxes.js
vendored
@ -15,7 +15,6 @@ YUI.add('moodle-course-toolboxes', function(Y) {
|
||||
GROUPSNONE : 'a.editing_groupsnone',
|
||||
GROUPSSEPARATE : 'a.editing_groupsseparate',
|
||||
GROUPSVISIBLE : 'a.editing_groupsvisible',
|
||||
HASLABEL : 'label',
|
||||
HIDE : 'a.editing_hide',
|
||||
HIGHLIGHT : 'a.editing_highlight',
|
||||
INSTANCENAME : 'span.instancename',
|
||||
@ -62,7 +61,7 @@ YUI.add('moodle-course-toolboxes', function(Y) {
|
||||
|
||||
var dimarea;
|
||||
var toggle_class;
|
||||
if (this.is_label(element)) {
|
||||
if (this.get_instance_name(element) == null) {
|
||||
toggle_class = CSS.DIMMEDTEXT;
|
||||
dimarea = element.all(CSS.MODINDENTDIV + ' > div').item(1);
|
||||
} else {
|
||||
@ -172,8 +171,19 @@ YUI.add('moodle-course-toolboxes', function(Y) {
|
||||
Y.io(uri, config);
|
||||
return responsetext;
|
||||
},
|
||||
is_label : function(target) {
|
||||
return target.hasClass(CSS.HASLABEL);
|
||||
/**
|
||||
* Return the name of the activity instance
|
||||
*
|
||||
* If activity has no name (for example label) null is returned
|
||||
*
|
||||
* @param element The <li> element to determine a name for
|
||||
* @return string|null Instance name
|
||||
*/
|
||||
get_instance_name : function(target) {
|
||||
if (target.one(CSS.INSTANCENAME)) {
|
||||
return target.one(CSS.INSTANCENAME).get('firstChild').get('data');
|
||||
}
|
||||
return null;
|
||||
},
|
||||
/**
|
||||
* Return the module ID for the specified element
|
||||
@ -330,19 +340,16 @@ YUI.add('moodle-course-toolboxes', function(Y) {
|
||||
// Get the element we're working on
|
||||
var element = e.target.ancestor(CSS.ACTIVITYLI);
|
||||
|
||||
// Create confirm string (different if element has or does not have name)
|
||||
var confirmstring = '';
|
||||
if (this.is_label(element)) {
|
||||
// Labels are slightly different to other activities
|
||||
var plugindata = {
|
||||
type : M.util.get_string('pluginname', 'label')
|
||||
}
|
||||
confirmstring = M.util.get_string('deletechecktype', 'moodle', plugindata)
|
||||
} else {
|
||||
var plugindata = {
|
||||
type : M.util.get_string('pluginname', element.getAttribute('class').match(/modtype_([^\s]*)/)[1]),
|
||||
name : element.one(CSS.INSTANCENAME).get('firstChild').get('data')
|
||||
}
|
||||
var plugindata = {
|
||||
type : M.util.get_string('pluginname', element.getAttribute('class').match(/modtype_([^\s]*)/)[1])
|
||||
}
|
||||
if (this.get_instance_name(element) != null) {
|
||||
plugindata.name = this.get_instance_name(element)
|
||||
confirmstring = M.util.get_string('deletechecktypename', 'moodle', plugindata);
|
||||
} else {
|
||||
confirmstring = M.util.get_string('deletechecktype', 'moodle', plugindata)
|
||||
}
|
||||
|
||||
// Confirm element removal
|
||||
|
@ -223,28 +223,28 @@ function report_log_print_mnet_selector_form($hostid, $course, $selecteduser=0,
|
||||
$activities = array();
|
||||
$selectedactivity = "";
|
||||
|
||||
/// Casting $course->modinfo to string prevents one notice when the field is null
|
||||
if ($modinfo = unserialize((string)$course->modinfo)) {
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
if (!empty($modinfo->cms)) {
|
||||
$section = 0;
|
||||
foreach ($modinfo as $mod) {
|
||||
if ($mod->mod == "label") {
|
||||
foreach ($modinfo->cms as $cm) {
|
||||
if (!$cm->uservisible || !$cm->has_view()) {
|
||||
continue;
|
||||
}
|
||||
if ($mod->section > 0 and $section <> $mod->section) {
|
||||
$activities["section/$mod->section"] = '--- '.get_section_name($course, $mod->section).' ---';
|
||||
if ($cm->sectionnum > 0 and $section <> $cm->sectionnum) {
|
||||
$activities["section/$cm->sectionnum"] = '--- '.get_section_name($course, $cm->sectionnum).' ---';
|
||||
}
|
||||
$section = $mod->section;
|
||||
$mod->name = strip_tags(format_string($mod->name, true));
|
||||
if (textlib::strlen($mod->name) > 55) {
|
||||
$mod->name = textlib::substr($mod->name, 0, 50)."...";
|
||||
$section = $cm->sectionnum;
|
||||
$modname = strip_tags($cm->get_formatted_name());
|
||||
if (textlib::strlen($modname) > 55) {
|
||||
$modname = textlib::substr($modname, 0, 50)."...";
|
||||
}
|
||||
if (!$mod->visible) {
|
||||
$mod->name = "(".$mod->name.")";
|
||||
if (!$cm->visible) {
|
||||
$modname = "(".$modname.")";
|
||||
}
|
||||
$activities["$mod->cm"] = $mod->name;
|
||||
$activities["$cm->id"] = $modname;
|
||||
|
||||
if ($mod->cm == $modid) {
|
||||
$selectedactivity = "$mod->cm";
|
||||
if ($cm->id == $modid) {
|
||||
$selectedactivity = "$cm->id";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -475,28 +475,28 @@ function report_log_print_selector_form($course, $selecteduser=0, $selecteddate=
|
||||
$activities = array();
|
||||
$selectedactivity = "";
|
||||
|
||||
/// Casting $course->modinfo to string prevents one notice when the field is null
|
||||
if ($modinfo = unserialize((string)$course->modinfo)) {
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
if (!empty($modinfo->cms)) {
|
||||
$section = 0;
|
||||
foreach ($modinfo as $mod) {
|
||||
if ($mod->mod == "label") {
|
||||
foreach ($modinfo->cms as $cm) {
|
||||
if (!$cm->uservisible || !$cm->has_view()) {
|
||||
continue;
|
||||
}
|
||||
if ($mod->section > 0 and $section <> $mod->section) {
|
||||
$activities["section/$mod->section"] = '--- '.get_section_name($course, $mod->section).' ---';
|
||||
if ($cm->sectionnum > 0 and $section <> $cm->sectionnum) {
|
||||
$activities["section/$cm->sectionnum"] = '--- '.get_section_name($course, $cm->sectionnum).' ---';
|
||||
}
|
||||
$section = $mod->section;
|
||||
$mod->name = strip_tags(format_string($mod->name, true));
|
||||
if (textlib::strlen($mod->name) > 55) {
|
||||
$mod->name = textlib::substr($mod->name, 0, 50)."...";
|
||||
$section = $cm->sectionnum;
|
||||
$modname = strip_tags($cm->get_formatted_name());
|
||||
if (textlib::strlen($modname) > 55) {
|
||||
$modname = textlib::substr($modname, 0, 50)."...";
|
||||
}
|
||||
if (!$mod->visible) {
|
||||
$mod->name = "(".$mod->name.")";
|
||||
if (!$cm->visible) {
|
||||
$modname = "(".$modname.")";
|
||||
}
|
||||
$activities["$mod->cm"] = $mod->name;
|
||||
$activities["$cm->id"] = $modname;
|
||||
|
||||
if ($mod->cm == $modid) {
|
||||
$selectedactivity = "$mod->cm";
|
||||
if ($cm->id == $modid) {
|
||||
$selectedactivity = "$cm->id";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user