See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 401 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Social activities block. 19 * 20 * @package block_social_activities 21 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 class block_social_activities extends block_list { 26 function init(){ 27 $this->title = get_string('pluginname', 'block_social_activities'); 28 } 29 30 function applicable_formats() { 31 return array('course-view-social' => true); 32 } 33 34 function get_content() { 35 global $USER, $CFG, $DB, $OUTPUT; 36 37 if ($this->content !== NULL) { 38 return $this->content; 39 } 40 41 $this->content = new stdClass(); 42 $this->content->items = array(); 43 $this->content->icons = array(); 44 $this->content->footer = ''; 45 46 if (empty($this->instance)) { 47 return $this->content; 48 } 49 50 $course = $this->page->course; 51 $format = course_get_format($course); 52 $courserenderer = $format->get_renderer($this->page); 53 54 require_once($CFG->dirroot.'/course/lib.php'); 55 56 $context = context_course::instance($course->id); 57 $isediting = $this->page->user_is_editing() && has_capability('moodle/course:manageactivities', $context); 58 $modinfo = get_fast_modinfo($course); 59 60 // Output classes. 61 $cmnameclass = $format->get_output_classname('content\\cm\\cmname'); 62 $controlmenuclass = $format->get_output_classname('content\\cm\\controlmenu'); 63 64 // Extra fast view mode. 65 if (!$isediting) { 66 if (!empty($modinfo->sections[0])) { 67 foreach($modinfo->sections[0] as $cmid) { 68 $cm = $modinfo->cms[$cmid]; 69 if (!$cm->uservisible || !$cm->is_visible_on_course_page()) { 70 continue; 71 } 72 73 $badges = ''; 74 if (!$cm->visible) { 75 $badges = html_writer::tag( 76 'span', 77 get_string('hiddenfromstudents'), 78 ['class' => 'badge badge-pill badge-warning mt-2'] 79 ); 80 } 81 82 if ($cm->is_stealth()) { 83 $badges = html_writer::tag( 84 'span', 85 get_string('hiddenoncoursepage'), 86 ['class' => 'badge badge-pill badge-warning mt-2'] 87 ); 88 } 89 90 if (!$cm->url) { 91 $activitybasis = html_writer::div( 92 $cm->get_formatted_content(['overflowdiv' => true, 'noclean' => true]), 93 'activity-basis d-flex align-items-center' 94 ); 95 $content = html_writer::div( 96 $activitybasis . $badges, 97 'contentwithoutlink activity-item activity' 98 ); 99 $this->content->items[] = $content; 100 $this->content->icons[] = ''; 101 } else { 102 $cmname = new $cmnameclass($format, $cm->get_section_info(), $cm); 103 $activitybasis = html_writer::div( 104 $courserenderer->render($cmname), 105 'activity-basis d-flex align-items-center'); 106 $content = html_writer::div( 107 $activitybasis . $badges, 108 'activity-item activity' 109 ); 110 $this->content->items[] = $content; 111 } 112 } 113 } 114 return $this->content; 115 } 116 117 // Slow & hacky editing mode. 118 $ismoving = ismoving($course->id); 119 $section = $modinfo->get_section_info(0); 120 121 if ($ismoving) { 122 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'")); 123 $strcancel= get_string('cancel'); 124 } else { 125 $strmove = get_string('move'); 126 } 127 128 if ($ismoving) { 129 $this->content->icons[] = ' ' . $OUTPUT->pix_icon('t/move', get_string('move')); 130 $cancelurl = new moodle_url('/course/mod.php', array('cancelcopy' => 'true', 'sesskey' => sesskey())); 131 $this->content->items[] = $USER->activitycopyname . ' (<a href="' . $cancelurl . '">' . $strcancel . '</a>)'; 132 } 133 134 if (!empty($modinfo->sections[0])) { 135 foreach ($modinfo->sections[0] as $modnumber) { 136 $mod = $modinfo->cms[$modnumber]; 137 if (!$mod->uservisible || !$mod->is_visible_on_course_page()) { 138 continue; 139 } 140 if (!$ismoving) { 141 142 $controlmenu = new $controlmenuclass( 143 $format, 144 $mod->get_section_info(), 145 $mod, 146 ['disableindentation' => true] 147 ); 148 149 $menu = $controlmenu->get_action_menu($OUTPUT); 150 151 // Add a move primary action. 152 $moveaction = html_writer::link( 153 new moodle_url('/course/mod.php', ['sesskey' => sesskey(), 'copy' => $mod->id]), 154 $OUTPUT->pix_icon('i/dragdrop', $strmove), 155 ['class' => 'editing_move_activity'] 156 ); 157 158 $editbuttons = html_writer::tag('div', 159 $courserenderer->render($controlmenu), 160 ['class' => 'buttons activity-actions ml-auto'] 161 ); 162 } else { 163 $editbuttons = ''; 164 $moveaction = ''; 165 } 166 if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $mod->context)) { 167 if ($ismoving) { 168 if ($mod->id == $USER->activitycopy) { 169 continue; 170 } 171 $movingurl = new moodle_url('/course/mod.php', array('moveto' => $mod->id, 'sesskey' => sesskey())); 172 $this->content->items[] = html_writer::link($movingurl, '', array('title' => $strmovefull, 173 'class' => 'movehere')); 174 $this->content->icons[] = ''; 175 } 176 177 $badges = ''; 178 if (!$mod->visible) { 179 $badges = html_writer::tag( 180 'span', 181 get_string('hiddenfromstudents'), 182 ['class' => 'badge badge-pill badge-warning mt-2'] 183 ); 184 } 185 186 if ($mod->is_stealth()) { 187 $badges = html_writer::tag( 188 'span', 189 get_string('hiddenoncoursepage'), 190 ['class' => 'badge badge-pill badge-warning mt-2'] 191 ); 192 } 193 194 if (!$mod->url) { 195 $activitybasis = html_writer::div( 196 $mod->get_formatted_content(['overflowdiv' => true, 'noclean' => true]) . 197 $editbuttons, 198 'activity-basis d-flex align-items-center'); 199 $content = html_writer::div( 200 $moveaction . 201 $activitybasis . 202 $badges, 203 'contentwithoutlink activity-item activity' 204 ); 205 $this->content->items[] = $content; 206 $this->content->icons[] = ''; 207 } else { 208 $cmname = new $cmnameclass($format, $mod->get_section_info(), $mod); 209 $activitybasis = html_writer::div( 210 $courserenderer->render($cmname) . 211 $editbuttons, 212 'activity-basis d-flex align-items-center'); 213 $content = html_writer::div( 214 $moveaction . 215 $activitybasis . 216 $badges, 217 'activity-item activity' 218 ); 219 $this->content->items[] = $content; 220 } 221 } 222 } 223 } 224 225 if ($ismoving) { 226 $movingurl = new moodle_url('/course/mod.php', array('movetosection' => $section->id, 'sesskey' => sesskey())); 227 $this->content->items[] = html_writer::link($movingurl, '', array('title' => $strmovefull, 'class' => 'movehere')); 228 $this->content->icons[] = ''; 229 } 230 231 $this->content->footer = $courserenderer->course_section_add_cm_control($course, 232 0, null, array('inblock' => true)); 233 234 return $this->content; 235 } 236 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body