function get_content() { global $CFG, $OUTPUT, $USER; $coursecontext = context::instance_by_id($this->instance->parentcontextid); if (!has_capability('moodle/community:add', $coursecontext) or $this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); $this->content->footer = ''; if (!isloggedin()) { return $this->content; } $icon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/group'), 'class' => 'icon', 'alt' => "")); $addcourseurl = new moodle_url('/blocks/community/communitycourse.php', array('add' => true, 'courseid' => $this->page->course->id)); $searchlink = html_writer::tag('a', $icon . get_string('addcourse', 'block_community'), array('href' => $addcourseurl->out(false))); $this->content->items[] = $searchlink; require_once $CFG->dirroot . '/blocks/community/locallib.php'; $communitymanager = new block_community_manager(); $courses = $communitymanager->block_community_get_courses($USER->id); if ($courses) { $this->content->items[] = html_writer::empty_tag('hr'); $this->content->icons[] = ''; $this->content->items[] = get_string('mycommunities', 'block_community'); $this->content->icons[] = ''; foreach ($courses as $course) { //delete link $deleteicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/delete'), 'alt' => get_string('removecommunitycourse', 'block_community'))); $deleteurl = new moodle_url('/blocks/community/communitycourse.php', array('remove' => true, 'courseid' => $this->page->course->id, 'communityid' => $course->id, 'sesskey' => sesskey())); $deleteatag = html_writer::tag('a', $deleteicon, array('href' => $deleteurl)); $courselink = html_writer::tag('a', $course->coursename, array('href' => $course->courseurl)); $this->content->items[] = $courselink . ' ' . $deleteatag; $this->content->icons[] = ''; } } return $this->content; }
if (empty($usercansearch)) { $notificationerror = get_string('cannotsearchcommunity', 'hub'); } else { if (!extension_loaded('xmlrpc')) { $notificationerror = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', ''); $notificationerror .= get_string('xmlrpcdisabledcommunity', 'hub'); } } if (!empty($notificationerror)) { echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('searchcommunitycourse', 'block_community'), 3, 'main'); echo $OUTPUT->notification($notificationerror); echo $OUTPUT->footer(); die; } $communitymanager = new block_community_manager(); $renderer = $PAGE->get_renderer('block_community'); /// Check if the page has been called with trust argument $add = optional_param('add', -1, PARAM_INT); $confirm = optional_param('confirmed', false, PARAM_INT); if ($add != -1 and $confirm and confirm_sesskey()) { $course = new stdClass(); $course->name = optional_param('coursefullname', '', PARAM_TEXT); $course->description = optional_param('coursedescription', '', PARAM_TEXT); $course->url = optional_param('courseurl', '', PARAM_URL); $course->imageurl = optional_param('courseimageurl', '', PARAM_URL); $communitymanager->block_community_add_course($course, $USER->id); echo $OUTPUT->header(); echo $renderer->save_link_success(new moodle_url('/course/view.php', array('id' => $courseid))); echo $OUTPUT->footer(); die;