/** * Builds the XHTML to display the control * * @param string $data Unused * @param string $query * @return string */ public function output_html($data, $query = '') { global $CFG, $OUTPUT; require_once $CFG->libdir . '/licenselib.php'; $url = "licenses.php?sesskey=" . sesskey(); // display strings $txt = get_strings(array('administration', 'settings', 'name', 'enable', 'disable', 'none')); $licenses = license_manager::get_licenses(); $return = $OUTPUT->heading(get_string('availablelicenses', 'admin'), 3, 'main', true); $return .= $OUTPUT->box_start('generalbox editorsui'); $table = new html_table(); $table->head = array($txt->name, $txt->enable); $table->align = array('left', 'center'); $table->width = '100%'; $table->data = array(); foreach ($licenses as $value) { $displayname = html_writer::link($value->source, get_string($value->shortname, 'license'), array('target' => '_blank')); if ($value->enabled == 1) { $hideshow = html_writer::link($url . '&action=disable&license=' . $value->shortname, html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('i/hide'), 'class' => 'icon', 'alt' => 'disable'))); } else { $hideshow = html_writer::link($url . '&action=enable&license=' . $value->shortname, html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('i/show'), 'class' => 'icon', 'alt' => 'enable'))); } if ($value->shortname == $CFG->sitedefaultlicense) { $displayname .= ' ' . html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('i/lock'), 'class' => 'icon', 'alt' => get_string('default'), 'title' => get_string('default'))); $hideshow = ''; } $enabled = true; $table->data[] = array($displayname, $hideshow); } $return .= html_writer::table($table); $return .= $OUTPUT->box_end(); return highlight($query, $return); }
public function definition() { global $CFG, $USER, $OUTPUT; $strrequired = get_string('required'); $mform =& $this->_form; //set default value $search = $this->_customdata['search']; if (isset($this->_customdata['coverage'])) { $coverage = $this->_customdata['coverage']; } else { $coverage = 'all'; } if (isset($this->_customdata['licence'])) { $licence = $this->_customdata['licence']; } else { $licence = 'all'; } if (isset($this->_customdata['subject'])) { $subject = $this->_customdata['subject']; } else { $subject = 'all'; } if (isset($this->_customdata['audience'])) { $audience = $this->_customdata['audience']; } else { $audience = 'all'; } if (isset($this->_customdata['language'])) { $language = $this->_customdata['language']; } else { $language = current_language(); } if (isset($this->_customdata['educationallevel'])) { $educationallevel = $this->_customdata['educationallevel']; } else { $educationallevel = 'all'; } if (isset($this->_customdata['downloadable'])) { $downloadable = $this->_customdata['downloadable']; } else { $downloadable = 0; } if (isset($this->_customdata['orderby'])) { $orderby = $this->_customdata['orderby']; } else { $orderby = 'newest'; } if (isset($this->_customdata['huburl'])) { $huburl = $this->_customdata['huburl']; } else { $huburl = HUB_MOODLEORGHUBURL; } $mform->addElement('header', 'site', get_string('search', 'block_community')); //add the course id (of the context) $mform->addElement('hidden', 'courseid', $this->_customdata['courseid']); $mform->addElement('hidden', 'executesearch', 1); //retrieve the hub list on the hub directory by web service $function = 'hubdirectory_get_hubs'; $params = array(); $serverurl = HUB_HUBDIRECTORYURL . "/local/hubdirectory/webservice/webservices.php"; require_once $CFG->dirroot . "/webservice/xmlrpc/lib.php"; $xmlrpcclient = new webservice_xmlrpc_client($serverurl, 'publichubdirectory'); try { $hubs = $xmlrpcclient->call($function, $params); } catch (Exception $e) { $hubs = array(); $error = $OUTPUT->notification(get_string('errorhublisting', 'block_community', $e->getMessage())); $mform->addElement('static', 'errorhub', '', $error); } //display list of registered on hub $registrationmanager = new registration_manager(); $registeredhubs = $registrationmanager->get_registered_on_hubs(); //retrieve some additional hubs that we will add to //the hub list got from the hub directory $additionalhubs = array(); foreach ($registeredhubs as $registeredhub) { $inthepubliclist = false; foreach ($hubs as $hub) { if ($hub['url'] == $registeredhub->huburl) { $inthepubliclist = true; $hub['registeredon'] = true; } } if (!$inthepubliclist) { $additionalhub = array(); $additionalhub['name'] = $registeredhub->hubname; $additionalhub['url'] = $registeredhub->huburl; $additionalhubs[] = $additionalhub; } } if (!empty($additionalhubs)) { $hubs = array_merge($hubs, $additionalhubs); } if (!empty($hubs)) { //TODO: sort hubs by trusted/prioritize //Public hub list $options = array(); $firsthub = false; foreach ($hubs as $hub) { if (array_key_exists('id', $hub)) { $params = array('hubid' => $hub['id'], 'filetype' => HUB_HUBSCREENSHOT_FILE_TYPE); $imgurl = new moodle_url(HUB_HUBDIRECTORYURL . "/local/hubdirectory/webservice/download.php", $params); $ascreenshothtml = html_writer::empty_tag('img', array('src' => $imgurl, 'alt' => $hub['name'])); $hubdescription = html_writer::tag('a', $hub['name'], array('class' => 'hublink clearfix', 'href' => $hub['url'], 'onclick' => 'this.target="_blank"')); $hubdescription .= html_writer::tag('span', $ascreenshothtml, array('class' => 'hubscreenshot')); $hubdescriptiontext = html_writer::tag('span', format_text($hub['description'], FORMAT_PLAIN), array('class' => 'hubdescription')); if (isset($hub['enrollablecourses'])) { //check needed to avoid warnings for Moodle version < 2011081700 $additionaldesc = get_string('enrollablecourses', 'block_community') . ': ' . $hub['enrollablecourses'] . ' - ' . get_string('downloadablecourses', 'block_community') . ': ' . $hub['downloadablecourses']; $hubdescriptiontext .= html_writer::tag('span', $additionaldesc, array('class' => 'hubadditionaldesc')); } if ($hub['trusted']) { $hubtrusted = get_string('hubtrusted', 'block_community'); $hubdescriptiontext .= html_writer::tag('span', $hubtrusted . ' ' . $OUTPUT->doc_link('trusted_hubs'), array('class' => 'trusted')); } $hubdescriptiontext = html_writer::tag('span', $hubdescriptiontext, array('class' => 'hubdescriptiontext')); $hubdescription = html_writer::tag('span', $hubdescription . $hubdescriptiontext, array('class' => $hub['trusted'] ? 'hubtrusted' : 'hubnottrusted')); } else { $hubdescription = html_writer::tag('a', $hub['name'], array('class' => 'hublink hubtrusted', 'href' => $hub['url'])); } if (empty($firsthub)) { $mform->addElement('radio', 'huburl', get_string('selecthub', 'block_community'), $hubdescription, $hub['url']); $mform->setDefault('huburl', $huburl); $firsthub = true; } else { $mform->addElement('radio', 'huburl', '', $hubdescription, $hub['url']); } } //display enrol/download select box if the USER has the download capability on the course if (has_capability('moodle/community:download', context_course::instance($this->_customdata['courseid']))) { $options = array(0 => get_string('enrollable', 'block_community'), 1 => get_string('downloadable', 'block_community')); $mform->addElement('select', 'downloadable', get_string('enroldownload', 'block_community'), $options); $mform->addHelpButton('downloadable', 'enroldownload', 'block_community'); } else { $mform->addElement('hidden', 'downloadable', 0); } $options = array(); $options['all'] = get_string('any'); $options[HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub'); $options[HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub'); $options[HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub'); $mform->addElement('select', 'audience', get_string('audience', 'block_community'), $options); $mform->setDefault('audience', $audience); unset($options); $mform->addHelpButton('audience', 'audience', 'block_community'); $options = array(); $options['all'] = get_string('any'); $options[HUB_EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'hub'); $options[HUB_EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'hub'); $options[HUB_EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'hub'); $options[HUB_EDULEVEL_GOVERNMENT] = get_string('edulevelgovernment', 'hub'); $options[HUB_EDULEVEL_ASSOCIATION] = get_string('edulevelassociation', 'hub'); $options[HUB_EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'hub'); $options[HUB_EDULEVEL_OTHER] = get_string('edulevelother', 'hub'); $mform->addElement('select', 'educationallevel', get_string('educationallevel', 'block_community'), $options); $mform->setDefault('educationallevel', $educationallevel); unset($options); $mform->addHelpButton('educationallevel', 'educationallevel', 'block_community'); $publicationmanager = new course_publish_manager(); $options = $publicationmanager->get_sorted_subjects(); foreach ($options as $key => &$option) { $keylength = strlen($key); if ($keylength == 10) { $option = " " . $option; } else { if ($keylength == 12) { $option = " " . $option; } } } $options = array_merge(array('all' => get_string('any')), $options); $mform->addElement('select', 'subject', get_string('subject', 'block_community'), $options, array('id' => 'communitysubject')); $mform->setDefault('subject', $subject); unset($options); $mform->addHelpButton('subject', 'subject', 'block_community'); $this->init_javascript_enhancement('subject', 'smartselect', array('selectablecategories' => true, 'mode' => 'compact')); require_once $CFG->libdir . "/licenselib.php"; $licensemanager = new license_manager(); $licences = $licensemanager->get_licenses(); $options = array(); $options['all'] = get_string('any'); foreach ($licences as $license) { $options[$license->shortname] = get_string($license->shortname, 'license'); } $mform->addElement('select', 'licence', get_string('licence', 'block_community'), $options); unset($options); $mform->addHelpButton('licence', 'licence', 'block_community'); $mform->setDefault('licence', $licence); $languages = get_string_manager()->get_list_of_languages(); collatorlib::asort($languages); $languages = array_merge(array('all' => get_string('any')), $languages); $mform->addElement('select', 'language', get_string('language'), $languages); $mform->setDefault('language', $language); $mform->addHelpButton('language', 'language', 'block_community'); $mform->addElement('radio', 'orderby', get_string('orderby', 'block_community'), get_string('orderbynewest', 'block_community'), 'newest'); $mform->addElement('radio', 'orderby', null, get_string('orderbyeldest', 'block_community'), 'eldest'); $mform->addElement('radio', 'orderby', null, get_string('orderbyname', 'block_community'), 'fullname'); $mform->addElement('radio', 'orderby', null, get_string('orderbypublisher', 'block_community'), 'publisher'); $mform->addElement('radio', 'orderby', null, get_string('orderbyratingaverage', 'block_community'), 'ratingaverage'); $mform->setDefault('orderby', $orderby); $mform->setType('orderby', PARAM_ALPHA); $mform->addElement('text', 'search', get_string('keywords', 'block_community')); $mform->addHelpButton('search', 'keywords', 'block_community'); $mform->addElement('submit', 'submitbutton', get_string('search', 'block_community')); } }
/** * Display a list of courses * @param array $courses * @param boolean $withwriteaccess * @param int $contextcourseid context course id * @return string */ public function course_list($courses, $huburl, $contextcourseid) { global $CFG; $renderedhtml = ''; if (empty($courses)) { if (isset($courses)) { $renderedhtml .= get_string('nocourse', 'block_community'); } } else { $courseiteration = 0; foreach ($courses as $course) { $course = (object) $course; $courseiteration = $courseiteration + 1; //create visit link html if (!empty($course->courseurl)) { $courseurl = new moodle_url($course->courseurl); $linktext = get_string('visitsite', 'block_community'); } else { $courseurl = new moodle_url($course->demourl); $linktext = get_string('visitdemo', 'block_community'); } $visitlinkhtml = html_writer::tag('a', $linktext, array('href' => $courseurl, 'class' => 'hubcoursedownload', 'onclick' => 'this.target="_blank"')); //create title html $coursename = html_writer::tag('h3', $course->fullname, array('class' => 'hubcoursetitle')); $coursenamehtml = html_writer::tag('div', $coursename, array('class' => 'hubcoursetitlepanel')); // create screenshots html $screenshothtml = ''; if (!empty($course->screenshots)) { $baseurl = new moodle_url($huburl . '/local/hub/webservice/download.php', array('courseid' => $course->id, 'filetype' => HUB_SCREENSHOT_FILE_TYPE)); $screenshothtml = html_writer::empty_tag('img', array('src' => $baseurl, 'alt' => $course->fullname)); } $coursescreenshot = html_writer::tag('div', $screenshothtml, array('class' => 'coursescreenshot', 'id' => 'image-' . $course->id)); //create description html $deschtml = html_writer::tag('div', $course->description, array('class' => 'hubcoursedescription')); //create users related information html $courseuserinfo = get_string('userinfo', 'block_community', $course); if ($course->contributornames) { $courseuserinfo .= ' - ' . get_string('contributors', 'block_community', $course->contributornames); } $courseuserinfohtml = html_writer::tag('div', $courseuserinfo, array('class' => 'hubcourseuserinfo')); //create course content related information html $course->subject = get_string($course->subject, 'edufields'); $course->audience = get_string('audience' . $course->audience, 'hub'); $course->educationallevel = get_string('edulevel' . $course->educationallevel, 'hub'); $coursecontentinfo = ''; if (empty($course->coverage)) { $course->coverage = ''; } else { $coursecontentinfo .= get_string('coverage', 'block_community', $course->coverage); $coursecontentinfo .= ' - '; } $coursecontentinfo .= get_string('contentinfo', 'block_community', $course); $coursecontentinfohtml = html_writer::tag('div', $coursecontentinfo, array('class' => 'hubcoursecontentinfo')); ///create course file related information html //language if (!empty($course->language)) { $languages = get_string_manager()->get_list_of_languages(); $course->lang = $languages[$course->language]; } else { $course->lang = ''; } //licence require_once $CFG->libdir . "/licenselib.php"; $licensemanager = new license_manager(); $licenses = $licensemanager->get_licenses(); foreach ($licenses as $license) { if ($license->shortname == $course->licenceshortname) { $course->license = $license->fullname; } } $course->timeupdated = userdate($course->timemodified); $coursefileinfo = get_string('fileinfo', 'block_community', $course); $coursefileinfohtml = html_writer::tag('div', $coursefileinfo, array('class' => 'hubcoursefileinfo')); //Create course content html $blocks = get_plugin_list('block'); $activities = get_plugin_list('mod'); if (!empty($course->contents)) { $activitieshtml = ''; $blockhtml = ''; foreach ($course->contents as $content) { $content = (object) $content; if ($content->moduletype == 'block') { if (!empty($blockhtml)) { $blockhtml .= ' - '; } if (array_key_exists($content->modulename, $blocks)) { $blockname = get_string('pluginname', 'block_' . $content->modulename); } else { $blockname = $content->modulename; } $blockhtml .= $blockname . " (" . $content->contentcount . ")"; } else { if (!empty($activitieshtml)) { $activitieshtml .= ' - '; } if (array_key_exists($content->modulename, $activities)) { $activityname = get_string('modulename', $content->modulename); } else { $activityname = $content->modulename; } $activitieshtml .= $activityname . " (" . $content->contentcount . ")"; } } $blocksandactivities = html_writer::tag('div', get_string('activities', 'block_community') . " : " . $activitieshtml); //Uncomment following lines to display blocks information // $blocksandactivities .= html_writer::tag('span', // get_string('blocks', 'block_community') . " : " . $blockhtml); } //Create outcomes html $outcomes = ''; if (!empty($course->outcomes)) { foreach ($course->outcomes as $outcome) { if (!empty($outcomes)) { $outcomes .= ', '; } $outcomes .= $outcome['fullname']; } $outcomes = get_string('outcomes', 'block_community', $outcomes); } $outcomeshtml = html_writer::tag('div', $outcomes, array('class' => 'hubcourseoutcomes')); //create additional information html $additionaldesc = $courseuserinfohtml . $coursecontentinfohtml . $coursefileinfohtml . $blocksandactivities . $outcomeshtml; $additionaldeschtml = html_writer::tag('div', $additionaldesc, array('class' => 'additionaldesc')); //Create add button html $addbuttonhtml = ""; if ($course->enrollable) { $params = array('sesskey' => sesskey(), 'add' => 1, 'confirmed' => 1, 'coursefullname' => $course->fullname, 'courseurl' => $courseurl, 'coursedescription' => $course->description, 'courseid' => $contextcourseid); $addurl = new moodle_url("/blocks/community/communitycourse.php", $params); $addbuttonhtml = html_writer::tag('a', get_string('addtocommunityblock', 'block_community'), array('href' => $addurl, 'class' => 'centeredbutton, hubcoursedownload')); } //create download button html $downloadbuttonhtml = ""; if (!$course->enrollable) { $params = array('sesskey' => sesskey(), 'download' => 1, 'confirmed' => 1, 'remotemoodleurl' => $CFG->wwwroot, 'courseid' => $contextcourseid, 'downloadcourseid' => $course->id, 'huburl' => $huburl, 'coursefullname' => $course->fullname, 'backupsize' => $course->backupsize); $downloadurl = new moodle_url("/blocks/community/communitycourse.php", $params); $downloadbuttonhtml = html_writer::tag('a', get_string('download', 'block_community'), array('href' => $downloadurl, 'class' => 'centeredbutton, hubcoursedownload')); } //Create rating html $rating = html_writer::tag('div', get_string('noratings', 'block_community'), array('class' => 'norating')); if (!empty($course->rating)) { $course->rating = (object) $course->rating; if ($course->rating->count > 0) { //calculate size of the rating star $starimagesize = 20; //in px $numberofstars = 5; $size = $course->rating->aggregate / $course->rating->scaleid * $numberofstars * $starimagesize; $rating = html_writer::tag('li', '', array('class' => 'current-rating', 'style' => 'width:' . $size . 'px;')); $rating = html_writer::tag('ul', $rating, array('class' => 'star-rating clearfix')); $rating .= html_writer::tag('div', ' (' . $course->rating->count . ')', array('class' => 'ratingcount clearfix')); } } //Create comments html $coursecomments = html_writer::tag('div', get_string('nocomments', 'block_community'), array('class' => 'nocomments')); $commentcount = 0; if (!empty($course->comments)) { //display only if there is some comment if there is some comment $commentcount = count($course->comments); $coursecomments = html_writer::tag('div', get_string('comments', 'block_community', $commentcount), array('class' => 'commenttitle')); foreach ($course->comments as $comment) { $commentator = html_writer::tag('div', $comment['commentator'], array('class' => 'hubcommentator')); $commentdate = html_writer::tag('div', ' - ' . userdate($comment['date'], '%e/%m/%y'), array('class' => 'hubcommentdate clearfix')); $commenttext = html_writer::tag('div', $comment['comment'], array('class' => 'hubcommenttext')); $coursecomments .= html_writer::tag('div', $commentator . $commentdate . $commenttext, array('class' => 'hubcomment')); } $coursecommenticon = html_writer::tag('div', get_string('comments', 'block_community', $commentcount), array('class' => 'hubcoursecomments', 'id' => 'comments-' . $course->id)); $coursecomments = $coursecommenticon . html_writer::tag('div', $coursecomments, array('class' => 'yui3-overlay-loading', 'id' => 'commentoverlay-' . $course->id)); } //link rate and comment $rateandcomment = html_writer::tag('div', html_writer::tag('a', get_string('rateandcomment', 'block_community'), array('href' => new moodle_url($huburl, array('courseid' => $course->id, 'mustbelogged' => true)), 'onclick' => 'this.target="_blank"')), array('class' => 'hubrateandcomment')); //the main DIV tags $buttonsdiv = html_writer::tag('div', $addbuttonhtml . $downloadbuttonhtml . $visitlinkhtml, array('class' => 'courseoperations')); $screenshotbuttonsdiv = html_writer::tag('div', $coursescreenshot . $buttonsdiv, array('class' => 'courselinks')); $coursedescdiv = html_writer::tag('div', $deschtml . $additionaldeschtml . $rating . $coursecomments . $rateandcomment, array('class' => 'coursedescription')); $coursehtml = $coursenamehtml . html_writer::tag('div', $coursedescdiv . $screenshotbuttonsdiv, array('class' => 'hubcourseinfo clearfix')); $renderedhtml .= html_writer::tag('div', $coursehtml, array('class' => 'fullhubcourse clearfix')); } $renderedhtml = html_writer::tag('div', $renderedhtml, array('class' => 'hubcourseresult')); } return $renderedhtml; }
/** * Main post-install tasks to be executed after the BD schema is available * * This function is automatically executed after Moodle core DB has been * created at initial install. It's in charge of perform the initial tasks * not covered by the {@link install.xml} file, like create initial users, * roles, templates, moving stuff from other plugins... * * Note that the function is only invoked once, at install time, so if new tasks * are needed in the future, they will need to be added both here (for new sites) * and in the corresponding {@link upgrade.php} file (for existing sites). * * All plugins within Moodle (modules, blocks, reports...) support the existence of * their own install.php file, using the "Frankenstyle" component name as * defined at {@link http://docs.moodle.org/dev/Frankenstyle}, for example: * - {@link xmldb_page_install()}. (modules don't require the plugintype ("mod_") to be used. * - {@link xmldb_enrol_meta_install()}. * - {@link xmldb_workshopform_accumulative_install()}. * - .... * * Finally, note that it's also supported to have one uninstall.php file that is * executed also once, each time one plugin is uninstalled (before the DB schema is * deleted). Those uninstall files will contain one function, using the "Frankenstyle" * naming conventions, like {@link xmldb_enrol_meta_uninstall()} or {@link xmldb_workshop_uninstall()}. */ function xmldb_main_install() { global $CFG, $DB, $SITE, $OUTPUT; // Make sure system context exists $syscontext = context_system::instance(0, MUST_EXIST, false); if ($syscontext->id != SYSCONTEXTID) { throw new moodle_exception('generalexceptionmessage', 'error', '', 'Unexpected new system context id!'); } // Create site course if ($DB->record_exists('course', array())) { throw new moodle_exception('generalexceptionmessage', 'error', '', 'Can not create frontpage course, courses already exist.'); } $newsite = new stdClass(); $newsite->fullname = ''; $newsite->shortname = ''; $newsite->summary = NULL; $newsite->newsitems = 3; $newsite->numsections = 1; $newsite->category = 0; $newsite->format = 'site'; // Only for this course $newsite->timecreated = time(); $newsite->timemodified = $newsite->timecreated; if (defined('SITEID')) { $newsite->id = SITEID; $DB->import_record('course', $newsite); $DB->get_manager()->reset_sequence('course'); } else { $newsite->id = $DB->insert_record('course', $newsite); define('SITEID', $newsite->id); } // set the field 'numsections'. We can not use format_site::update_format_options() because // the file is not loaded $DB->insert_record('course_format_options', array('courseid' => SITEID, 'format' => 'site', 'sectionid' => 0, 'name' => 'numsections', 'value' => $newsite->numsections)); $SITE = get_site(); if ($newsite->id != $SITE->id) { throw new moodle_exception('generalexceptionmessage', 'error', '', 'Unexpected new site course id!'); } // Make sure site course context exists context_course::instance($SITE->id); // Update the global frontpage cache $SITE = $DB->get_record('course', array('id' => $newsite->id), '*', MUST_EXIST); // Create default course category if ($DB->record_exists('course_categories', array())) { throw new moodle_exception('generalexceptionmessage', 'error', '', 'Can not create default course category, categories already exist.'); } $cat = new stdClass(); $cat->name = get_string('miscellaneous'); $cat->depth = 1; $cat->sortorder = MAX_COURSES_IN_CATEGORY; $cat->timemodified = time(); $catid = $DB->insert_record('course_categories', $cat); $DB->set_field('course_categories', 'path', '/' . $catid, array('id' => $catid)); // Make sure category context exists context_coursecat::instance($catid); $defaults = array('rolesactive' => '0', 'auth' => 'email', 'auth_pop3mailbox' => 'INBOX', 'enrol_plugins_enabled' => 'manual,guest,self,cohort', 'theme' => theme_config::DEFAULT_THEME, 'filter_multilang_converted' => 1, 'siteidentifier' => random_string(32) . get_host_from_url($CFG->wwwroot), 'backup_version' => 2008111700, 'backup_release' => '2.0 dev', 'mnet_dispatcher_mode' => 'off', 'sessiontimeout' => 7200, 'stringfilters' => '', 'filterall' => 0, 'texteditors' => 'atto,tinymce,textarea', 'upgrade_minmaxgradestepignored' => 1, 'upgrade_extracreditweightsstepignored' => 1, 'upgrade_calculatedgradeitemsignored' => 1); foreach ($defaults as $key => $value) { set_config($key, $value); } // Bootstrap mnet $mnethost = new stdClass(); $mnethost->wwwroot = $CFG->wwwroot; $mnethost->name = ''; $mnethost->name = ''; $mnethost->public_key = ''; if (empty($_SERVER['SERVER_ADDR'])) { // SERVER_ADDR is only returned by Apache-like webservers preg_match("@^(?:http[s]?://)?([A-Z0-9\\-\\.]+).*@i", $CFG->wwwroot, $matches); $my_hostname = $matches[1]; $my_ip = gethostbyname($my_hostname); // Returns unmodified hostname on failure. DOH! if ($my_ip == $my_hostname) { $mnethost->ip_address = 'UNKNOWN'; } else { $mnethost->ip_address = $my_ip; } } else { $mnethost->ip_address = $_SERVER['SERVER_ADDR']; } $mnetid = $DB->insert_record('mnet_host', $mnethost); set_config('mnet_localhost_id', $mnetid); // Initial insert of mnet applications info $mnet_app = new stdClass(); $mnet_app->name = 'moodle'; $mnet_app->display_name = 'Moodle'; $mnet_app->xmlrpc_server_url = '/mnet/xmlrpc/server.php'; $mnet_app->sso_land_url = '/auth/mnet/land.php'; $mnet_app->sso_jump_url = '/auth/mnet/jump.php'; $moodleapplicationid = $DB->insert_record('mnet_application', $mnet_app); $mnet_app = new stdClass(); $mnet_app->name = 'mahara'; $mnet_app->display_name = 'Mahara'; $mnet_app->xmlrpc_server_url = '/api/xmlrpc/server.php'; $mnet_app->sso_land_url = '/auth/xmlrpc/land.php'; $mnet_app->sso_jump_url = '/auth/xmlrpc/jump.php'; $DB->insert_record('mnet_application', $mnet_app); // Set up the probably-to-be-removed-soon 'All hosts' record $mnetallhosts = new stdClass(); $mnetallhosts->wwwroot = ''; $mnetallhosts->ip_address = ''; $mnetallhosts->public_key = ''; $mnetallhosts->public_key_expires = 0; $mnetallhosts->last_connect_time = 0; $mnetallhosts->last_log_id = 0; $mnetallhosts->deleted = 0; $mnetallhosts->name = 'All Hosts'; $mnetallhosts->applicationid = $moodleapplicationid; $mnetallhosts->id = $DB->insert_record('mnet_host', $mnetallhosts, true); set_config('mnet_all_hosts_id', $mnetallhosts->id); // Create guest record - do not assign any role, guest user gets the default guest role automatically on the fly if ($DB->record_exists('user', array())) { throw new moodle_exception('generalexceptionmessage', 'error', '', 'Can not create default users, users already exist.'); } $guest = new stdClass(); $guest->auth = 'manual'; $guest->username = '******'; $guest->password = hash_internal_user_password('guest'); $guest->firstname = get_string('guestuser'); $guest->lastname = ' '; $guest->email = 'root@localhost'; $guest->description = get_string('guestuserinfo'); $guest->mnethostid = $CFG->mnet_localhost_id; $guest->confirmed = 1; $guest->lang = $CFG->lang; $guest->timemodified = time(); $guest->id = $DB->insert_record('user', $guest); if ($guest->id != 1) { echo $OUTPUT->notification('Unexpected id generated for the Guest account. Your database configuration or clustering setup may not be fully supported', 'notifyproblem'); } // Store guest id set_config('siteguest', $guest->id); // Make sure user context exists context_user::instance($guest->id); // Now create admin user $admin = new stdClass(); $admin->auth = 'manual'; $admin->firstname = get_string('admin'); $admin->lastname = get_string('user'); $admin->username = '******'; $admin->password = '******'; $admin->email = ''; $admin->confirmed = 1; $admin->mnethostid = $CFG->mnet_localhost_id; $admin->lang = $CFG->lang; $admin->maildisplay = 1; $admin->timemodified = time(); $admin->lastip = CLI_SCRIPT ? '0.0.0.0' : getremoteaddr(); // installation hijacking prevention $admin->id = $DB->insert_record('user', $admin); if ($admin->id != 2) { echo $OUTPUT->notification('Unexpected id generated for the Admin account. Your database configuration or clustering setup may not be fully supported', 'notifyproblem'); } if ($admin->id != $guest->id + 1) { echo $OUTPUT->notification('Nonconsecutive id generated for the Admin account. Your database configuration or clustering setup may not be fully supported.', 'notifyproblem'); } // Store list of admins set_config('siteadmins', $admin->id); // Make sure user context exists context_user::instance($admin->id); // Install the roles system. $managerrole = create_role('', 'manager', '', 'manager'); $coursecreatorrole = create_role('', 'coursecreator', '', 'coursecreator'); $editteacherrole = create_role('', 'editingteacher', '', 'editingteacher'); $noneditteacherrole = create_role('', 'teacher', '', 'teacher'); $studentrole = create_role('', 'student', '', 'student'); $guestrole = create_role('', 'guest', '', 'guest'); $userrole = create_role('', 'user', '', 'user'); $frontpagerole = create_role('', 'frontpage', '', 'frontpage'); // Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles update_capabilities('moodle'); // Default allow role matrices. foreach ($DB->get_records('role') as $role) { foreach (array('assign', 'override', 'switch') as $type) { $function = 'allow_' . $type; $allows = get_default_role_archetype_allows($type, $role->archetype); foreach ($allows as $allowid) { $function($role->id, $allowid); } } } // Set up the context levels where you can assign each role. set_role_contextlevels($managerrole, get_default_contextlevels('manager')); set_role_contextlevels($coursecreatorrole, get_default_contextlevels('coursecreator')); set_role_contextlevels($editteacherrole, get_default_contextlevels('editingteacher')); set_role_contextlevels($noneditteacherrole, get_default_contextlevels('teacher')); set_role_contextlevels($studentrole, get_default_contextlevels('student')); set_role_contextlevels($guestrole, get_default_contextlevels('guest')); set_role_contextlevels($userrole, get_default_contextlevels('user')); // Init theme and JS revisions set_config('themerev', time()); set_config('jsrev', time()); // No admin setting for this any more, GD is now required, remove in Moodle 2.6. set_config('gdversion', 2); // Install licenses require_once $CFG->libdir . '/licenselib.php'; license_manager::install_licenses(); // Init profile pages defaults if ($DB->record_exists('my_pages', array())) { throw new moodle_exception('generalexceptionmessage', 'error', '', 'Can not create default profile pages, records already exist.'); } $mypage = new stdClass(); $mypage->userid = NULL; $mypage->name = '__default'; $mypage->private = 0; $mypage->sortorder = 0; $DB->insert_record('my_pages', $mypage); $mypage->private = 1; $DB->insert_record('my_pages', $mypage); // Set a sensible default sort order for the most-used question types. set_config('multichoice_sortorder', 1, 'question'); set_config('truefalse_sortorder', 2, 'question'); set_config('match_sortorder', 3, 'question'); set_config('shortanswer_sortorder', 4, 'question'); set_config('numerical_sortorder', 5, 'question'); set_config('essay_sortorder', 6, 'question'); }
function xmldb_main_install() { global $CFG, $DB, $SITE, $OUTPUT; /// make sure system context exists $syscontext = get_system_context(false); if ($syscontext->id != 1) { throw new moodle_exception('generalexceptionmessage', 'error', '', 'Unexpected new system context id!'); } /// create site course $newsite = new stdClass(); $newsite->fullname = ''; $newsite->shortname = ''; $newsite->summary = NULL; $newsite->newsitems = 3; $newsite->numsections = 0; $newsite->category = 0; $newsite->format = 'site'; // Only for this course $newsite->timecreated = time(); $newsite->timemodified = $newsite->timecreated; $newsite->id = $DB->insert_record('course', $newsite); $SITE = get_site(); if ($newsite->id != 1 or $SITE->id != 1) { throw new moodle_exception('generalexceptionmessage', 'error', '', 'Unexpected new site course id!'); } /// make sure site course context exists get_context_instance(CONTEXT_COURSE, $SITE->id); /// create default course category $cat = get_course_category(); $defaults = array('rolesactive' => '0', 'auth' => 'email', 'auth_pop3mailbox' => 'INBOX', 'enrol_plugins_enabled' => 'manual,guest,self,cohort', 'theme' => theme_config::DEFAULT_THEME, 'filter_multilang_converted' => 1, 'siteidentifier' => random_string(32) . get_host_from_url($CFG->wwwroot), 'backup_version' => 2008111700, 'backup_release' => '2.0 dev', 'mnet_dispatcher_mode' => 'off', 'sessiontimeout' => 7200, 'stringfilters' => '', 'filterall' => 0, 'texteditors' => 'tinymce,textarea'); foreach ($defaults as $key => $value) { set_config($key, $value); } /// bootstrap mnet $mnethost = new stdClass(); $mnethost->wwwroot = $CFG->wwwroot; $mnethost->name = ''; $mnethost->name = ''; $mnethost->public_key = ''; if (empty($_SERVER['SERVER_ADDR'])) { // SERVER_ADDR is only returned by Apache-like webservers preg_match("@^(?:http[s]?://)?([A-Z0-9\\-\\.]+).*@i", $CFG->wwwroot, $matches); $my_hostname = $matches[1]; $my_ip = gethostbyname($my_hostname); // Returns unmodified hostname on failure. DOH! if ($my_ip == $my_hostname) { $mnethost->ip_address = 'UNKNOWN'; } else { $mnethost->ip_address = $my_ip; } } else { $mnethost->ip_address = $_SERVER['SERVER_ADDR']; } $mnetid = $DB->insert_record('mnet_host', $mnethost); set_config('mnet_localhost_id', $mnetid); // Initial insert of mnet applications info $mnet_app = new stdClass(); $mnet_app->name = 'moodle'; $mnet_app->display_name = 'Moodle'; $mnet_app->xmlrpc_server_url = '/mnet/xmlrpc/server.php'; $mnet_app->sso_land_url = '/auth/mnet/land.php'; $mnet_app->sso_jump_url = '/auth/mnet/jump.php'; $moodleapplicationid = $DB->insert_record('mnet_application', $mnet_app); $mnet_app = new stdClass(); $mnet_app->name = 'mahara'; $mnet_app->display_name = 'Mahara'; $mnet_app->xmlrpc_server_url = '/api/xmlrpc/server.php'; $mnet_app->sso_land_url = '/auth/xmlrpc/land.php'; $mnet_app->sso_jump_url = '/auth/xmlrpc/jump.php'; $DB->insert_record('mnet_application', $mnet_app); // Set up the probably-to-be-removed-soon 'All hosts' record $mnetallhosts = new stdClass(); $mnetallhosts->wwwroot = ''; $mnetallhosts->ip_address = ''; $mnetallhosts->public_key = ''; $mnetallhosts->public_key_expires = 0; $mnetallhosts->last_connect_time = 0; $mnetallhosts->last_log_id = 0; $mnetallhosts->deleted = 0; $mnetallhosts->name = 'All Hosts'; $mnetallhosts->applicationid = $moodleapplicationid; $mnetallhosts->id = $DB->insert_record('mnet_host', $mnetallhosts, true); set_config('mnet_all_hosts_id', $mnetallhosts->id); /// Create guest record - do not assign any role, guest user get's the default guest role automatically on the fly $guest = new stdClass(); $guest->auth = 'manual'; $guest->username = '******'; $guest->password = hash_internal_user_password('guest'); $guest->firstname = get_string('guestuser'); $guest->lastname = ' '; $guest->email = 'root@localhost'; $guest->description = get_string('guestuserinfo'); $guest->mnethostid = $CFG->mnet_localhost_id; $guest->confirmed = 1; $guest->lang = $CFG->lang; $guest->timemodified = time(); $guest->id = $DB->insert_record('user', $guest); if ($guest->id != 1) { echo $OUTPUT->notification('Unexpected id generated for the Guest account. Your database configuration or clustering setup may not be fully supported', 'notifyproblem'); } // Store guest id set_config('siteguest', $guest->id); /// Now create admin user $admin = new stdClass(); $admin->auth = 'manual'; $admin->firstname = get_string('admin'); $admin->lastname = get_string('user'); $admin->username = '******'; $admin->password = '******'; $admin->email = ''; $admin->confirmed = 1; $admin->mnethostid = $CFG->mnet_localhost_id; $admin->lang = $CFG->lang; $admin->maildisplay = 1; $admin->timemodified = time(); $admin->lastip = CLI_SCRIPT ? '0.0.0.0' : getremoteaddr(); // installation hijacking prevention $admin->id = $DB->insert_record('user', $admin); if ($admin->id != 2) { echo $OUTPUT->notification('Unexpected id generated for the Admin account. Your database configuration or clustering setup may not be fully supported', 'notifyproblem'); } if ($admin->id != $guest->id + 1) { echo $OUTPUT->notification('Nonconsecutive id generated for the Admin account. Your database configuration or clustering setup may not be fully supported.', 'notifyproblem'); } /// Store list of admins set_config('siteadmins', $admin->id); /// Install the roles system. $managerrole = create_role(get_string('manager', 'role'), 'manager', get_string('managerdescription', 'role'), 'manager'); $coursecreatorrole = create_role(get_string('coursecreators'), 'coursecreator', get_string('coursecreatorsdescription'), 'coursecreator'); $editteacherrole = create_role(get_string('defaultcourseteacher'), 'editingteacher', get_string('defaultcourseteacherdescription'), 'editingteacher'); $noneditteacherrole = create_role(get_string('noneditingteacher'), 'teacher', get_string('noneditingteacherdescription'), 'teacher'); $studentrole = create_role(get_string('defaultcoursestudent'), 'student', get_string('defaultcoursestudentdescription'), 'student'); $guestrole = create_role(get_string('guest'), 'guest', get_string('guestdescription'), 'guest'); $userrole = create_role(get_string('authenticateduser'), 'user', get_string('authenticateduserdescription'), 'user'); $frontpagerole = create_role(get_string('frontpageuser', 'role'), 'frontpage', get_string('frontpageuserdescription', 'role'), 'frontpage'); /// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles update_capabilities('moodle'); /// Default allow assign $defaultallowassigns = array(array($managerrole, $managerrole), array($managerrole, $coursecreatorrole), array($managerrole, $editteacherrole), array($managerrole, $noneditteacherrole), array($managerrole, $studentrole), array($editteacherrole, $noneditteacherrole), array($editteacherrole, $studentrole)); foreach ($defaultallowassigns as $allow) { list($fromroleid, $toroleid) = $allow; allow_assign($fromroleid, $toroleid); } /// Default allow override $defaultallowoverrides = array(array($managerrole, $managerrole), array($managerrole, $coursecreatorrole), array($managerrole, $editteacherrole), array($managerrole, $noneditteacherrole), array($managerrole, $studentrole), array($managerrole, $guestrole), array($managerrole, $userrole), array($managerrole, $frontpagerole), array($editteacherrole, $noneditteacherrole), array($editteacherrole, $studentrole), array($editteacherrole, $guestrole)); foreach ($defaultallowoverrides as $allow) { list($fromroleid, $toroleid) = $allow; allow_override($fromroleid, $toroleid); // There is a rant about this in MDL-15841. } /// Default allow switch. $defaultallowswitch = array(array($managerrole, $editteacherrole), array($managerrole, $noneditteacherrole), array($managerrole, $studentrole), array($managerrole, $guestrole), array($editteacherrole, $noneditteacherrole), array($editteacherrole, $studentrole), array($editteacherrole, $guestrole), array($noneditteacherrole, $studentrole), array($noneditteacherrole, $guestrole)); foreach ($defaultallowswitch as $allow) { list($fromroleid, $toroleid) = $allow; allow_switch($fromroleid, $toroleid); } /// Set up the context levels where you can assign each role. set_role_contextlevels($managerrole, get_default_contextlevels('manager')); set_role_contextlevels($coursecreatorrole, get_default_contextlevels('coursecreator')); set_role_contextlevels($editteacherrole, get_default_contextlevels('editingteacher')); set_role_contextlevels($noneditteacherrole, get_default_contextlevels('teacher')); set_role_contextlevels($studentrole, get_default_contextlevels('student')); set_role_contextlevels($guestrole, get_default_contextlevels('guest')); set_role_contextlevels($userrole, get_default_contextlevels('user')); // Init themes set_config('themerev', 1); // Install licenses require_once $CFG->libdir . '/licenselib.php'; license_manager::install_licenses(); /// Add two lines of data into this new table $mypage = new stdClass(); $mypage->userid = NULL; $mypage->name = '__default'; $mypage->private = 0; $mypage->sortorder = 0; if (!$DB->record_exists('my_pages', array('userid' => NULL, 'private' => 0))) { $DB->insert_record('my_pages', $mypage); } $mypage->private = 1; if (!$DB->record_exists('my_pages', array('userid' => NULL, 'private' => 1))) { $DB->insert_record('my_pages', $mypage); } }
public function definition() { global $CFG, $DB, $USER, $OUTPUT; $strrequired = get_string('required'); $mform =& $this->_form; $huburl = $this->_customdata['huburl']; $hubname = $this->_customdata['hubname']; $course = $this->_customdata['course']; $advertise = $this->_customdata['advertise']; $share = $this->_customdata['share']; $page = $this->_customdata['page']; $site = get_site(); //hidden parameters $mform->addElement('hidden', 'huburl', $huburl); $mform->addElement('hidden', 'hubname', $hubname); //check on the hub if the course has already been published $registrationmanager = new registration_manager(); $registeredhub = $registrationmanager->get_registeredhub($huburl); $publicationmanager = new course_publish_manager(); $publications = $publicationmanager->get_publications($registeredhub->huburl, $course->id, $advertise); if (!empty($publications)) { //get the last publication of this course $publication = array_pop($publications); $function = 'hub_get_courses'; $options = new stdClass(); $options->ids = array($publication->hubcourseid); $options->allsitecourses = 1; $params = array('search' => '', 'downloadable' => $share, 'enrollable' => !$share, 'options' => $options); $serverurl = $huburl . "/local/hub/webservice/webservices.php"; require_once $CFG->dirroot . "/webservice/xmlrpc/lib.php"; $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $registeredhub->token); try { $result = $xmlrpcclient->call($function, $params); $publishedcourses = $result['courses']; } catch (Exception $e) { $error = $OUTPUT->notification(get_string('errorcourseinfo', 'hub', $e->getMessage())); $mform->addElement('static', 'errorhub', '', $error); } } if (!empty($publishedcourses)) { $publishedcourse = $publishedcourses[0]; $hubcourseid = $publishedcourse['id']; $defaultfullname = $publishedcourse['fullname']; $defaultshortname = $publishedcourse['shortname']; $defaultsummary = $publishedcourse['description']; $defaultlanguage = $publishedcourse['language']; $defaultpublishername = $publishedcourse['publishername']; $defaultpublisheremail = $publishedcourse['publisheremail']; $defaultcontributornames = $publishedcourse['contributornames']; $defaultcoverage = $publishedcourse['coverage']; $defaultcreatorname = $publishedcourse['creatorname']; $defaultlicenceshortname = $publishedcourse['licenceshortname']; $defaultsubject = $publishedcourse['subject']; $defaultaudience = $publishedcourse['audience']; $defaulteducationallevel = $publishedcourse['educationallevel']; $defaultcreatornotes = $publishedcourse['creatornotes']; $defaultcreatornotesformat = $publishedcourse['creatornotesformat']; $screenshotsnumber = $publishedcourse['screenshots']; $privacy = $publishedcourse['privacy']; if ($screenshotsnumber > 0 and !empty($privacy)) { $page->requires->yui_module('moodle-block_community-imagegallery', 'M.blocks_community.init_imagegallery', array(array('imageids' => array($hubcourseid), 'imagenumbers' => array($screenshotsnumber), 'huburl' => $huburl))); } } else { $defaultfullname = $course->fullname; $defaultshortname = $course->shortname; $defaultsummary = clean_param($course->summary, PARAM_TEXT); if (empty($course->lang)) { $language = get_site()->lang; if (empty($language)) { $defaultlanguage = current_language(); } else { $defaultlanguage = $language; } } else { $defaultlanguage = $course->lang; } $defaultpublishername = $USER->firstname . ' ' . $USER->lastname; $defaultpublisheremail = $USER->email; $defaultcontributornames = ''; $defaultcoverage = ''; $defaultcreatorname = $USER->firstname . ' ' . $USER->lastname; $defaultlicenceshortname = 'cc'; $defaultsubject = 'none'; $defaultaudience = HUB_AUDIENCE_STUDENTS; $defaulteducationallevel = HUB_EDULEVEL_TERTIARY; $defaultcreatornotes = ''; $defaultcreatornotesformat = FORMAT_HTML; $screenshotsnumber = 0; } //the input parameters $mform->addElement('header', 'moodle', get_string('publicationinfo', 'hub')); $mform->addElement('text', 'name', get_string('coursename', 'hub'), array('class' => 'metadatatext')); $mform->addRule('name', $strrequired, 'required', null, 'client'); $mform->setType('name', PARAM_TEXT); $mform->setDefault('name', $defaultfullname); $mform->addHelpButton('name', 'name', 'hub'); $mform->addElement('hidden', 'id', $this->_customdata['id']); if ($share) { $buttonlabel = get_string('shareon', 'hub', !empty($hubname) ? $hubname : $huburl); $mform->addElement('hidden', 'share', $share); $mform->addElement('text', 'demourl', get_string('demourl', 'hub'), array('class' => 'metadatatext')); $mform->setType('demourl', PARAM_URL); $mform->setDefault('demourl', new moodle_url("/course/view.php?id=" . $course->id)); $mform->addHelpButton('demourl', 'demourl', 'hub'); } if ($advertise) { if (empty($publishedcourses)) { $buttonlabel = get_string('advertiseon', 'hub', !empty($hubname) ? $hubname : $huburl); } else { $buttonlabel = get_string('readvertiseon', 'hub', !empty($hubname) ? $hubname : $huburl); } $mform->addElement('hidden', 'advertise', $advertise); $mform->addElement('hidden', 'courseurl', $CFG->wwwroot . "/course/view.php?id=" . $course->id); $mform->addElement('static', 'courseurlstring', get_string('courseurl', 'hub')); $mform->setDefault('courseurlstring', new moodle_url("/course/view.php?id=" . $course->id)); $mform->addHelpButton('courseurlstring', 'courseurl', 'hub'); } $mform->addElement('text', 'courseshortname', get_string('courseshortname', 'hub'), array('class' => 'metadatatext')); $mform->setDefault('courseshortname', $defaultshortname); $mform->addHelpButton('courseshortname', 'courseshortname', 'hub'); $mform->addElement('textarea', 'description', get_string('description'), array('rows' => 10, 'cols' => 57)); $mform->addRule('description', $strrequired, 'required', null, 'client'); $mform->setDefault('description', $defaultsummary); $mform->setType('description', PARAM_TEXT); $mform->addHelpButton('description', 'description', 'hub'); $languages = get_string_manager()->get_list_of_languages(); textlib_get_instance()->asort($languages); $mform->addElement('select', 'language', get_string('language'), $languages); $mform->setDefault('language', $defaultlanguage); $mform->addHelpButton('language', 'language', 'hub'); $mform->addElement('text', 'publishername', get_string('publishername', 'hub'), array('class' => 'metadatatext')); $mform->setDefault('publishername', $defaultpublishername); $mform->addRule('publishername', $strrequired, 'required', null, 'client'); $mform->addHelpButton('publishername', 'publishername', 'hub'); $mform->addElement('text', 'publisheremail', get_string('publisheremail', 'hub'), array('class' => 'metadatatext')); $mform->setDefault('publisheremail', $defaultpublisheremail); $mform->addRule('publisheremail', $strrequired, 'required', null, 'client'); $mform->addHelpButton('publisheremail', 'publisheremail', 'hub'); $mform->addElement('text', 'creatorname', get_string('creatorname', 'hub'), array('class' => 'metadatatext')); $mform->addRule('creatorname', $strrequired, 'required', null, 'client'); $mform->setType('creatorname', PARAM_TEXT); $mform->setDefault('creatorname', $defaultcreatorname); $mform->addHelpButton('creatorname', 'creatorname', 'hub'); $mform->addElement('text', 'contributornames', get_string('contributornames', 'hub'), array('class' => 'metadatatext')); $mform->setDefault('contributornames', $defaultcontributornames); $mform->addHelpButton('contributornames', 'contributornames', 'hub'); $mform->addElement('text', 'coverage', get_string('tags', 'hub'), array('class' => 'metadatatext')); $mform->setType('coverage', PARAM_TEXT); $mform->setDefault('coverage', $defaultcoverage); $mform->addHelpButton('coverage', 'tags', 'hub'); require_once $CFG->libdir . "/licenselib.php"; $licensemanager = new license_manager(); $licences = $licensemanager->get_licenses(); $options = array(); foreach ($licences as $license) { $options[$license->shortname] = get_string($license->shortname, 'license'); } $mform->addElement('select', 'licence', get_string('license'), $options); $mform->setDefault('licence', $defaultlicenceshortname); unset($options); $mform->addHelpButton('licence', 'licence', 'hub'); $options = $publicationmanager->get_sorted_subjects(); //prepare data for the smartselect foreach ($options as $key => &$option) { $keylength = strlen($key); if ($keylength == 10) { $option = " " . $option; } else { if ($keylength == 12) { $option = " " . $option; } } } $options = array('none' => get_string('none', 'hub')) + $options; $mform->addElement('select', 'subject', get_string('subject', 'hub'), $options); unset($options); $mform->addHelpButton('subject', 'subject', 'hub'); $mform->setDefault('subject', $defaultsubject); $mform->addRule('subject', $strrequired, 'required', null, 'client'); $this->init_javascript_enhancement('subject', 'smartselect', array('selectablecategories' => false, 'mode' => 'compact')); $options = array(); $options[HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub'); $options[HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub'); $options[HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub'); $mform->addElement('select', 'audience', get_string('audience', 'hub'), $options); $mform->setDefault('audience', $defaultaudience); unset($options); $mform->addHelpButton('audience', 'audience', 'hub'); $options = array(); $options[HUB_EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'hub'); $options[HUB_EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'hub'); $options[HUB_EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'hub'); $options[HUB_EDULEVEL_GOVERNMENT] = get_string('edulevelgovernment', 'hub'); $options[HUB_EDULEVEL_ASSOCIATION] = get_string('edulevelassociation', 'hub'); $options[HUB_EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'hub'); $options[HUB_EDULEVEL_OTHER] = get_string('edulevelother', 'hub'); $mform->addElement('select', 'educationallevel', get_string('educationallevel', 'hub'), $options); $mform->setDefault('educationallevel', $defaulteducationallevel); unset($options); $mform->addHelpButton('educationallevel', 'educationallevel', 'hub'); $editoroptions = array('maxfiles' => 0, 'maxbytes' => 0, 'trusttext' => false, 'forcehttps' => false); $mform->addElement('editor', 'creatornotes', get_string('creatornotes', 'hub'), '', $editoroptions); $mform->addRule('creatornotes', $strrequired, 'required', null, 'client'); $mform->setType('creatornotes', PARAM_CLEANHTML); $mform->addHelpButton('creatornotes', 'creatornotes', 'hub'); if ($advertise) { if (!empty($screenshotsnumber)) { if (!empty($privacy)) { $baseurl = new moodle_url($huburl . '/local/hub/webservice/download.php', array('courseid' => $hubcourseid, 'filetype' => HUB_SCREENSHOT_FILE_TYPE)); $screenshothtml = html_writer::empty_tag('img', array('src' => $baseurl, 'alt' => $defaultfullname)); $screenshothtml = html_writer::tag('div', $screenshothtml, array('class' => 'coursescreenshot', 'id' => 'image-' . $hubcourseid)); } else { $screenshothtml = get_string('existingscreenshotnumber', 'hub', $screenshotsnumber); } $mform->addElement('static', 'existingscreenshots', get_string('existingscreenshots', 'hub'), $screenshothtml); $mform->addHelpButton('existingscreenshots', 'deletescreenshots', 'hub'); $mform->addElement('checkbox', 'deletescreenshots', '', ' ' . get_string('deletescreenshots', 'hub')); } $mform->addElement('hidden', 'existingscreenshotnumber', $screenshotsnumber); } $mform->addElement('filemanager', 'screenshots', get_string('addscreenshots', 'hub'), null, array('subdirs' => 0, 'maxbytes' => 1000000, 'maxfiles' => 3)); $mform->addHelpButton('screenshots', 'screenshots', 'hub'); $this->add_action_buttons(false, $buttonlabel); //set default value for creatornotes editor $data = new stdClass(); $data->creatornotes = array(); $data->creatornotes['text'] = $defaultcreatornotes; $data->creatornotes['format'] = $defaultcreatornotesformat; $this->set_data($data); }
public function definition() { global $CFG; $strrequired = get_string('required'); //retrieve the publication $hub = new local_hub(); $course = $hub->get_course($this->_customdata['id']); $mform =& $this->_form; $mform->addElement('header', 'moodle', get_string('coursesettingsform', 'local_hub', $course->fullname)); $mform->addElement('hidden', 'id', $course->id); $mform->setType('id', PARAM_INT); $mform->addElement('checkbox', 'visible', get_string('coursevisibility', 'local_hub')); $mform->addHelpButton('visible', 'coursevisibility', 'local_hub'); $mform->setDefault('visible', $course->privacy); $mform->addElement('text', 'fullname', get_string('coursename', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('fullname', PARAM_TEXT); $mform->addHelpButton('fullname', 'coursename', 'local_hub'); $mform->setDefault('fullname', $course->fullname); $mform->addRule('fullname', $strrequired, 'required', null, 'client'); if (!empty($course->courseurl)) { $mform->addElement('text', 'courseurl', get_string('courseurl', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('courseurl', PARAM_URL); $mform->addHelpButton('courseurl', 'courseurl', 'local_hub'); $mform->setDefault('courseurl', $course->courseurl); $mform->addRule('courseurl', $strrequired, 'required', null, 'client'); } else { $mform->addElement('text', 'demourl', get_string('demourl', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('demourl', PARAM_URL); $mform->addHelpButton('demourl', 'demourl', 'local_hub'); $mform->setDefault('demourl', $course->demourl); } $mform->addElement('textarea', 'description', get_string('coursedesc', 'local_hub'), array('rows' => 10, 'cols' => 56, 'class' => 'coursesettingstextarea')); $mform->addHelpButton('description', 'coursedesc', 'local_hub'); $mform->addRule('description', $strrequired, 'required', null, 'client'); $mform->setDefault('description', $course->description); $languages = get_string_manager()->get_list_of_languages(); asort($languages, SORT_LOCALE_STRING); $mform->addElement('select', 'language', get_string('courselang', 'local_hub'), $languages); $mform->setDefault('language', $course->language); $mform->addHelpButton('language', 'courselang', 'local_hub'); $mform->addElement('text', 'publishername', get_string('publishername', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('publishername', PARAM_TEXT); $mform->setDefault('publishername', $course->publishername); $mform->addRule('publishername', $strrequired, 'required', null, 'client'); $mform->addHelpButton('publishername', 'publishername', 'local_hub'); $mform->addElement('text', 'publisheremail', get_string('publisheremail', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('publisheremail', PARAM_EMAIL); $mform->setDefault('publisheremail', $course->publisheremail); $mform->addRule('publisheremail', $strrequired, 'required', null, 'client'); $mform->addHelpButton('publisheremail', 'publisheremail', 'local_hub'); $mform->addElement('text', 'creatorname', get_string('creatorname', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->addRule('creatorname', $strrequired, 'required', null, 'client'); $mform->setType('creatorname', PARAM_TEXT); $mform->setDefault('creatorname', $course->creatorname); $mform->addHelpButton('creatorname', 'creatorname', 'local_hub'); $mform->addElement('text', 'contributornames', get_string('contributornames', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('contributornames', PARAM_TEXT); $mform->setDefault('contributornames', $course->contributornames); $mform->addHelpButton('contributornames', 'contributornames', 'local_hub'); $mform->addElement('text', 'coverage', get_string('tags', 'local_hub'), array('class' => 'coursesettingstextfield')); $mform->setType('coverage', PARAM_TEXT); $mform->setDefault('coverage', $course->coverage); $mform->addHelpButton('coverage', 'tags', 'local_hub'); require_once $CFG->libdir . "/licenselib.php"; $licensemanager = new license_manager(); $licences = $licensemanager->get_licenses(); $options = array(); foreach ($licences as $license) { $options[$license->shortname] = get_string($license->shortname, 'license'); } $mform->addElement('select', 'licence', get_string('licence', 'local_hub'), $options); $mform->setDefault('licence', $course->licenceshortname); unset($options); $mform->addHelpButton('licence', 'licence', 'local_hub'); require_once $CFG->dirroot . "/course/publish/lib.php"; $publicationmanager = new course_publish_manager(); $options = $publicationmanager->get_sorted_subjects(); //prepare data for the smartselect foreach ($options as $key => &$option) { $keylength = strlen($key); if ($keylength == 10) { $option = " " . $option; } else { if ($keylength == 12) { $option = " " . $option; } } } $options = array('none' => get_string('none', 'local_hub')) + $options; $mform->addElement('select', 'subject', get_string('subject', 'local_hub'), $options); unset($options); $mform->addHelpButton('subject', 'subject', 'local_hub'); $mform->setDefault('subject', $course->subject); $mform->addRule('subject', $strrequired, 'required', null, 'client'); $this->init_javascript_enhancement('subject', 'smartselect', array('selectablecategories' => false, 'mode' => 'compact')); $options = array(); $options[HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'local_hub'); $options[HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'local_hub'); $options[HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'local_hub'); $mform->addElement('select', 'audience', get_string('audience', 'local_hub'), $options); $mform->setDefault('audience', $course->audience); unset($options); $mform->addHelpButton('audience', 'audience', 'local_hub'); $options = array(); $options[HUB_EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'local_hub'); $options[HUB_EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'local_hub'); $options[HUB_EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'local_hub'); $options[HUB_EDULEVEL_GOVERNMENT] = get_string('edulevelgovernment', 'local_hub'); $options[HUB_EDULEVEL_ASSOCIATION] = get_string('edulevelassociation', 'local_hub'); $options[HUB_EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'local_hub'); $options[HUB_EDULEVEL_OTHER] = get_string('edulevelother', 'local_hub'); $mform->addElement('select', 'educationallevel', get_string('educationallevel', 'local_hub'), $options); $mform->setDefault('educationallevel', $course->educationallevel); unset($options); $mform->addHelpButton('educationallevel', 'educationallevel', 'local_hub'); //setdefault is currently not supported making this required field not usable MDL-20988 $editoroptions = array('maxfiles' => 0, 'maxbytes' => 0, 'trusttext' => false, 'forcehttps' => false); $mform->addElement('editor', 'creatornotes', get_string('creatornotes', 'hub'), '', $editoroptions); $mform->setType('creatornotes', PARAM_CLEANHTML); $mform->addHelpButton('creatornotes', 'creatornotes', 'hub'); //set default value for creatornotes editor $data = new stdClass(); $data->creatornotes = array(); $data->creatornotes['text'] = $course->creatornotes; $data->creatornotes['format'] = $course->creatornotesformat; $this->set_data($data); //select screenshots to keep for ($screenshotnumber = 1; $screenshotnumber <= $course->screenshots; $screenshotnumber++) { $baseurl = new moodle_url($CFG->wwwroot . '/local/hub/webservice/download.php', array('courseid' => $course->id, 'filetype' => HUB_SCREENSHOT_FILE_TYPE, 'screenshotnumber' => $screenshotnumber, 'alwaysreload' => time())); $screenshothtml = html_writer::empty_tag('img', array('src' => $baseurl, 'alt' => $course->fullname)); $coursescreenshot = html_writer::tag('div', $screenshothtml, array('class' => '')); $mform->addElement('checkbox', 'screenshot_' . $screenshotnumber, get_string('keepscreenshot', 'local_hub'), $coursescreenshot); $mform->addHelpButton('screenshot_' . $screenshotnumber, 'keepscreenshot', 'local_hub'); $mform->setDefault('screenshot_' . $screenshotnumber, 1); } $mform->addElement('filemanager', 'addscreenshots', get_string('addscreenshots', 'local_hub'), null, array('subdirs' => 0, 'maxbytes' => 1000000, 'maxfiles' => MAXSCREENSHOTSNUMBER)); $mform->addHelpButton('addscreenshots', 'addscreenshots', 'local_hub'); $this->add_action_buttons(false, get_string('update')); }
/** * Parses files from XML import and inserts them into file system * * @param array $xmlparent parent element in parsed XML tree * @param string $tag * @param int $contextid * @param string $filearea * @param int $itemid * @return int */ function glossary_xml_import_files($xmlparent, $tag, $contextid, $filearea, $itemid) { global $USER, $CFG; $count = 0; if (isset($xmlparent[$tag][0]['#']['FILE'])) { $fs = get_file_storage(); $files = $xmlparent[$tag][0]['#']['FILE']; foreach ($files as $file) { $filerecord = array( 'contextid' => $contextid, 'component' => 'mod_glossary', 'filearea' => $filearea, 'itemid' => $itemid, 'filepath' => $file['#']['FILEPATH'][0]['#'], 'filename' => $file['#']['FILENAME'][0]['#'], 'userid' => $USER->id ); if (array_key_exists('FILEAUTHOR', $file['#'])) { $filerecord['author'] = $file['#']['FILEAUTHOR'][0]['#']; } if (array_key_exists('FILELICENSE', $file['#'])) { $license = $file['#']['FILELICENSE'][0]['#']; require_once($CFG->libdir . "/licenselib.php"); if (license_manager::get_license_by_shortname($license)) { $filerecord['license'] = $license; } } $content = $file['#']['CONTENTS'][0]['#']; $fs->create_file_from_string($filerecord, base64_decode($content)); $count++; } } return $count; }
public function definition() { global $CFG; $strrequired = get_string('required'); $mform =& $this->_form; //set default value $search = $this->_customdata['search']; if (isset($this->_customdata['coverage'])) { $coverage = $this->_customdata['coverage']; } else { $coverage = 'all'; } if (isset($this->_customdata['licence'])) { $licence = $this->_customdata['licence']; } else { $licence = 'all'; } if (isset($this->_customdata['subject'])) { $subject = $this->_customdata['subject']; } else { $subject = 'all'; } if (isset($this->_customdata['audience'])) { $audience = $this->_customdata['audience']; } else { $audience = 'all'; } if (isset($this->_customdata['language'])) { $language = $this->_customdata['language']; } else { $language = current_language(); } if (isset($this->_customdata['educationallevel'])) { $educationallevel = $this->_customdata['educationallevel']; } else { $educationallevel = 'all'; } if (isset($this->_customdata['visibility'])) { $visibility = $this->_customdata['visibility']; } else { $visibility = COURSEVISIBILITY_NOTVISIBLE; } if (isset($this->_customdata['downloadable'])) { $downloadable = $this->_customdata['downloadable']; } else { $downloadable = 1; } if (isset($this->_customdata['siteid'])) { $siteid = $this->_customdata['siteid']; } else { $siteid = 'all'; } if (isset($this->_customdata['lastmodified'])) { $lastmodified = $this->_customdata['lastmodified']; } else { $lastmodified = HUB_LASTMODIFIED_WEEK; } if (isset($this->_customdata['orderby'])) { $orderby = $this->_customdata['orderby']; } else { $orderby = 'newest'; } $mform->addElement('header', 'site', get_string('search', 'local_hub')); $options = array(0 => get_string('enrollable', 'local_hub'), 1 => get_string('downloadable', 'local_hub')); if (key_exists('adminform', $this->_customdata)) { $options = array('all' => get_string('any')) + $options; } $mform->addElement('select', 'downloadable', get_string('enroldownload', 'local_hub'), $options); $mform->addHelpButton('downloadable', 'enroldownload', 'local_hub'); $mform->setDefault('downloadable', $downloadable); //visible field //Note: doesn't matter if form html is hacked, index script does not return any invisible courses if (key_exists('adminform', $this->_customdata)) { $options = array(); $options[COURSEVISIBILITY_ALL] = get_string('visibilityall', 'local_hub'); $options[COURSEVISIBILITY_VISIBLE] = get_string('visibilityyes', 'local_hub'); $options[COURSEVISIBILITY_NOTVISIBLE] = get_string('visibilityno', 'local_hub'); $mform->addElement('select', 'visibility', get_string('visibility', 'local_hub'), $options); $mform->setDefault('visibility', $visibility); unset($options); $mform->addHelpButton('visibility', 'visibility', 'local_hub'); } $options = array(); $options['all'] = get_string('any'); $options[HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub'); $options[HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub'); $options[HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub'); $mform->addElement('select', 'audience', get_string('audience', 'local_hub'), $options); $mform->setDefault('audience', $audience); unset($options); $mform->addHelpButton('audience', 'audience', 'local_hub'); if (key_exists('adminform', $this->_customdata)) { $options = array(); $options['all'] = '-'; $options[HUB_LASTMODIFIED_WEEK] = get_string('periodweek', 'local_hub'); $options[HUB_LASTMODIFIED_FORTEENNIGHT] = get_string('periodforteennight', 'local_hub'); $options[HUB_LASTMODIFIED_MONTH] = get_string('periodmonth', 'local_hub'); $mform->addElement('select', 'lastmodified', get_string('lastmodified', 'local_hub'), $options); $mform->setDefault('lastmodified', $lastmodified); unset($options); $mform->addHelpButton('lastmodified', 'lastmodified', 'local_hub'); } $options = array(); $options['all'] = get_string('any'); $options[HUB_EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'hub'); $options[HUB_EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'hub'); $options[HUB_EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'hub'); $options[HUB_EDULEVEL_GOVERNMENT] = get_string('edulevelgovernment', 'hub'); $options[HUB_EDULEVEL_ASSOCIATION] = get_string('edulevelassociation', 'hub'); $options[HUB_EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'hub'); $options[HUB_EDULEVEL_OTHER] = get_string('edulevelother', 'hub'); $mform->addElement('select', 'educationallevel', get_string('educationallevel', 'local_hub'), $options); $mform->setDefault('educationallevel', $educationallevel); unset($options); $mform->addHelpButton('educationallevel', 'educationallevel', 'local_hub'); require_once $CFG->dirroot . "/course/publish/lib.php"; $publicationmanager = new course_publish_manager(); $options = $publicationmanager->get_sorted_subjects(); foreach ($options as $key => &$option) { $keylength = strlen($key); if ($keylength == 10) { $option = " " . $option; } else { if ($keylength == 12) { $option = " " . $option; } } } $options = array_merge(array('all' => get_string('any')), $options); $mform->addElement('select', 'subject', get_string('subject', 'hub'), $options); $mform->setDefault('subject', $subject); unset($options); $mform->addHelpButton('subject', 'subject', 'local_hub'); $this->init_javascript_enhancement('subject', 'smartselect', array('selectablecategories' => true, 'mode' => 'compact')); require_once $CFG->libdir . "/licenselib.php"; $licensemanager = new license_manager(); $licences = $licensemanager->get_licenses(); $options = array(); $options['all'] = get_string('any'); foreach ($licences as $license) { $options[$license->shortname] = get_string($license->shortname, 'license'); } $mform->addElement('select', 'licence', get_string('license'), $options); unset($options); $mform->addHelpButton('licence', 'licence', 'local_hub'); $mform->setDefault('licence', $licence); //search for only language that exist in the course DB require_once $CFG->dirroot . "/local/hub/lib.php"; $hub = new local_hub(); $courseslanguages = $hub->get_courses_languages(); $alllanguages = get_string_manager()->get_list_of_languages(); $languages = array(); foreach ($courseslanguages as $languagecode => $lang) { if (isset($alllanguages[$languagecode])) { $languages[$languagecode] = $alllanguages[$languagecode]; } } asort($languages, SORT_LOCALE_STRING); $languages = array_merge(array('all' => get_string('any')), $languages); $mform->addElement('select', 'language', get_string('language'), $languages); $mform->setDefault('language', $language); $mform->addHelpButton('language', 'language', 'local_hub'); $mform->addElement('select', 'orderby', get_string('orderby', 'local_hub'), array('newest' => get_string('orderbynewest', 'local_hub'), 'eldest' => get_string('orderbyeldest', 'local_hub'), 'fullname' => get_string('orderbyname', 'local_hub'), 'publisher' => get_string('orderbypublisher', 'local_hub'), 'ratingaverage' => get_string('orderbyratingaverage', 'local_hub'))); $mform->setDefault('orderby', $orderby); $mform->setType('orderby', PARAM_ALPHA); $mform->addHelpButton('orderby', 'orderby', 'local_hub'); $mform->setAdvanced('audience'); $mform->setAdvanced('educationallevel'); $mform->setAdvanced('subject'); $mform->setAdvanced('licence'); $mform->setAdvanced('language'); $mform->setAdvanced('orderby'); if (key_exists('adminform', $this->_customdata)) { if ($hub->get_sites(array(), 0, 0, true) < 100) { // field not humanly usable over 100 sites. $sites = $hub->get_sites(); $siteids = array(); foreach ($sites as $site) { $siteids[$site->id] = $site->name; } asort($siteids, SORT_LOCALE_STRING); $siteids = array('all' => get_string('any')) + $siteids; $mform->addElement('select', 'siteid', get_string('site', 'local_hub'), $siteids); $mform->setDefault('siteid', $siteid); $mform->addHelpButton('siteid', 'site', 'local_hub'); } } $mform->addElement('text', 'search', get_string('keywords', 'local_hub')); $mform->setType('search', PARAM_ALPHANUMEXT); $mform->addHelpButton('search', 'keywords', 'local_hub'); $mform->setDefault('search', $search); $mform->addElement('submit', 'submitbutton', get_string('search', 'local_hub')); }
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Allows admin to configure licenses. */ require_once '../config.php'; require_once $CFG->libdir . '/adminlib.php'; require_once $CFG->libdir . '/licenselib.php'; require_login(); require_capability('moodle/site:config', context_system::instance()); $returnurl = "{$CFG->wwwroot}/{$CFG->admin}/settings.php?section=managelicenses"; $action = optional_param('action', '', PARAM_ALPHANUMEXT); $license = optional_param('license', '', PARAM_SAFEDIR); //////////////////////////////////////////////////////////////////////////////// // process actions if (!confirm_sesskey()) { redirect($returnurl); } $return = true; switch ($action) { case 'disable': license_manager::disable($license); break; case 'enable': license_manager::enable($license); break; default: break; } if ($return) { redirect($returnurl); }
public function definition() { global $CFG, $USER, $OUTPUT; $strrequired = get_string('required'); $mform =& $this->_form; //set default value $search = $this->_customdata['search']; if (isset($this->_customdata['coverage'])) { $coverage = $this->_customdata['coverage']; } else { $coverage = 'all'; } if (isset($this->_customdata['licence'])) { $licence = $this->_customdata['licence']; } else { $licence = 'all'; } if (isset($this->_customdata['subject'])) { $subject = $this->_customdata['subject']; } else { $subject = 'all'; } if (isset($this->_customdata['audience'])) { $audience = $this->_customdata['audience']; } else { $audience = 'all'; } if (isset($this->_customdata['language'])) { $language = $this->_customdata['language']; } else { $language = current_language(); } if (isset($this->_customdata['educationallevel'])) { $educationallevel = $this->_customdata['educationallevel']; } else { $educationallevel = 'all'; } if (isset($this->_customdata['downloadable'])) { $downloadable = $this->_customdata['downloadable']; } else { $downloadable = 1; } if (isset($this->_customdata['orderby'])) { $orderby = $this->_customdata['orderby']; } else { $orderby = 'newest'; } if (isset($this->_customdata['huburl'])) { $huburl = $this->_customdata['huburl']; } else { $huburl = HUB_MOODLEORGHUBURL; } $mform->addElement('header', 'site', get_string('search', 'block_community')); //add the course id (of the context) $mform->addElement('hidden', 'courseid', $this->_customdata['courseid']); $mform->setType('courseid', PARAM_INT); $mform->addElement('hidden', 'executesearch', 1); $mform->setType('executesearch', PARAM_INT); //retrieve the hub list on the hub directory by web service $function = 'hubdirectory_get_hubs'; $params = array(); $serverurl = HUB_HUBDIRECTORYURL . "/local/hubdirectory/webservice/webservices.php"; require_once $CFG->dirroot . "/webservice/xmlrpc/lib.php"; $xmlrpcclient = new webservice_xmlrpc_client($serverurl, 'publichubdirectory'); try { $hubs = $xmlrpcclient->call($function, $params); } catch (Exception $e) { $hubs = array(); $error = $OUTPUT->notification(get_string('errorhublisting', 'block_community', $e->getMessage())); $mform->addElement('static', 'errorhub', '', $error); } //display list of registered on hub $registrationmanager = new registration_manager(); $registeredhubs = $registrationmanager->get_registered_on_hubs(); //retrieve some additional hubs that we will add to //the hub list got from the hub directory $additionalhubs = array(); foreach ($registeredhubs as $registeredhub) { $inthepubliclist = false; foreach ($hubs as $hub) { if ($hub['url'] == $registeredhub->huburl) { $inthepubliclist = true; $hub['registeredon'] = true; } } if (!$inthepubliclist) { $additionalhub = array(); $additionalhub['name'] = $registeredhub->hubname; $additionalhub['url'] = $registeredhub->huburl; $additionalhubs[] = $additionalhub; } } if (!empty($additionalhubs)) { $hubs = array_merge($hubs, $additionalhubs); } if (!empty($hubs)) { $htmlhubs = array(); foreach ($hubs as $hub) { // Name can come from hub directory - need some cleaning. $hubname = clean_text($hub['name'], PARAM_TEXT); $smalllogohtml = ''; if (array_key_exists('id', $hub)) { // Retrieve hub logo + generate small logo. $params = array('hubid' => $hub['id'], 'filetype' => HUB_HUBSCREENSHOT_FILE_TYPE); $imgurl = new moodle_url(HUB_HUBDIRECTORYURL . "/local/hubdirectory/webservice/download.php", $params); $imgsize = getimagesize($imgurl->out(false)); if ($imgsize[0] > 1) { $ascreenshothtml = html_writer::empty_tag('img', array('src' => $imgurl, 'alt' => $hubname)); $smalllogohtml = html_writer::empty_tag('img', array('src' => $imgurl, 'alt' => $hubname, 'height' => 30, 'width' => 40)); } else { $ascreenshothtml = ''; } $hubimage = html_writer::tag('div', $ascreenshothtml, array('class' => 'hubimage')); // Statistics + trusted info. $hubstats = ''; if (isset($hub['enrollablecourses'])) { //check needed to avoid warnings for Moodle version < 2011081700 $additionaldesc = get_string('enrollablecourses', 'block_community') . ': ' . $hub['enrollablecourses'] . ' - ' . get_string('downloadablecourses', 'block_community') . ': ' . $hub['downloadablecourses']; $hubstats .= html_writer::tag('div', $additionaldesc); } if ($hub['trusted']) { $hubtrusted = get_string('hubtrusted', 'block_community'); $hubstats .= $OUTPUT->doc_link('trusted_hubs') . html_writer::tag('div', $hubtrusted); } $hubstats = html_writer::tag('div', $hubstats, array('class' => 'hubstats')); // hub name link + hub description. $hubnamelink = html_writer::link($hub['url'], html_writer::tag('h2', $hubname), array('class' => 'hubtitlelink')); // The description can come from the hub directory - need to clean. $hubdescription = clean_param($hub['description'], PARAM_TEXT); $hubdescriptiontext = html_writer::tag('div', format_text($hubdescription, FORMAT_PLAIN), array('class' => 'hubdescription')); $hubtext = html_writer::tag('div', $hubdescriptiontext . $hubstats, array('class' => 'hubtext')); $hubimgandtext = html_writer::tag('div', $hubimage . $hubtext, array('class' => 'hubimgandtext')); $hubfulldesc = html_writer::tag('div', $hubnamelink . $hubimgandtext, array('class' => 'hubmainhmtl')); } else { $hubfulldesc = html_writer::link($hub['url'], $hubname); } // Add hub to the hub items. $hubinfo = new stdClass(); $hubinfo->mainhtml = $hubfulldesc; $hubinfo->rowhtml = html_writer::tag('div', $smalllogohtml, array('class' => 'hubsmalllogo')) . $hubname; $hubitems[$hub['url']] = $hubinfo; } // Hub listing form element. $mform->addElement('listing', 'huburl', '', '', array('items' => $hubitems, 'showall' => get_string('showall', 'block_community'), 'hideall' => get_string('hideall', 'block_community'))); $mform->setDefault('huburl', $huburl); //display enrol/download select box if the USER has the download capability on the course if (has_capability('moodle/community:download', context_course::instance($this->_customdata['courseid']))) { $options = array(0 => get_string('enrollable', 'block_community'), 1 => get_string('downloadable', 'block_community')); $mform->addElement('select', 'downloadable', get_string('enroldownload', 'block_community'), $options); $mform->addHelpButton('downloadable', 'enroldownload', 'block_community'); $mform->setDefault('downloadable', $downloadable); } else { $mform->addElement('hidden', 'downloadable', 0); } $mform->setType('downloadable', PARAM_INT); $options = array(); $options['all'] = get_string('any'); $options[HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub'); $options[HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub'); $options[HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub'); $mform->addElement('select', 'audience', get_string('audience', 'block_community'), $options); $mform->setDefault('audience', $audience); unset($options); $mform->addHelpButton('audience', 'audience', 'block_community'); $options = array(); $options['all'] = get_string('any'); $options[HUB_EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'hub'); $options[HUB_EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'hub'); $options[HUB_EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'hub'); $options[HUB_EDULEVEL_GOVERNMENT] = get_string('edulevelgovernment', 'hub'); $options[HUB_EDULEVEL_ASSOCIATION] = get_string('edulevelassociation', 'hub'); $options[HUB_EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'hub'); $options[HUB_EDULEVEL_OTHER] = get_string('edulevelother', 'hub'); $mform->addElement('select', 'educationallevel', get_string('educationallevel', 'block_community'), $options); $mform->setDefault('educationallevel', $educationallevel); unset($options); $mform->addHelpButton('educationallevel', 'educationallevel', 'block_community'); $publicationmanager = new course_publish_manager(); $options = $publicationmanager->get_sorted_subjects(); $mform->addElement('searchableselector', 'subject', get_string('subject', 'block_community'), $options, array('id' => 'communitysubject')); $mform->setDefault('subject', $subject); unset($options); $mform->addHelpButton('subject', 'subject', 'block_community'); require_once $CFG->libdir . "/licenselib.php"; $licensemanager = new license_manager(); $licences = $licensemanager->get_licenses(); $options = array(); $options['all'] = get_string('any'); foreach ($licences as $license) { $options[$license->shortname] = get_string($license->shortname, 'license'); } $mform->addElement('select', 'licence', get_string('licence', 'block_community'), $options); unset($options); $mform->addHelpButton('licence', 'licence', 'block_community'); $mform->setDefault('licence', $licence); $languages = get_string_manager()->get_list_of_languages(); core_collator::asort($languages); $languages = array_merge(array('all' => get_string('any')), $languages); $mform->addElement('select', 'language', get_string('language'), $languages); $mform->setDefault('language', $language); $mform->addHelpButton('language', 'language', 'block_community'); $mform->addElement('select', 'orderby', get_string('orderby', 'block_community'), array('newest' => get_string('orderbynewest', 'block_community'), 'eldest' => get_string('orderbyeldest', 'block_community'), 'fullname' => get_string('orderbyname', 'block_community'), 'publisher' => get_string('orderbypublisher', 'block_community'), 'ratingaverage' => get_string('orderbyratingaverage', 'block_community'))); $mform->setDefault('orderby', $orderby); $mform->addHelpButton('orderby', 'orderby', 'block_community'); $mform->setType('orderby', PARAM_ALPHA); $mform->setAdvanced('audience'); $mform->setAdvanced('educationallevel'); $mform->setAdvanced('subject'); $mform->setAdvanced('licence'); $mform->setAdvanced('language'); $mform->setAdvanced('orderby'); $mform->addElement('text', 'search', get_string('keywords', 'block_community'), array('size' => 30)); $mform->addHelpButton('search', 'keywords', 'block_community'); $mform->setType('search', PARAM_NOTAGS); $mform->addElement('submit', 'submitbutton', get_string('search', 'block_community')); } }
/** * Display a list of courses * If $withwriteaccess = true, we display visible field, * @param array $courses * @param boolean $withwriteaccess * @return string */ public function course_list($courses, $withwriteaccess = false, $optionalurlparams = array()) { global $CFG; require_once $CFG->dirroot . '/comment/lib.php'; comment::init(); $renderedhtml = ''; if (!empty($courses)) { $courseiteration = 0; foreach ($courses as $course) { $courseiteration = $courseiteration + 1; //create html specific to hub administrator if ($withwriteaccess) { //create site link html $managesiteurl = new moodle_url($CFG->wwwroot . '/local/hub/admin/managesites.php', array('search' => $course->site->name, 'sesskey' => sesskey())); $siteatag = html_writer::tag('a', get_string('site', 'local_hub') . ': ' . $course->site->name, array('href' => $managesiteurl)); $sitehtml = html_writer::tag('div', $siteatag, array('class' => 'coursesitelink')); //bulk operation checkbox html $checkboxhtml = html_writer::tag('div', html_writer::checkbox('bulk-' . $courseiteration, $course->id, false, '', array('class' => 'hubmanagecoursecheckbox')), array('class' => 'hubcoursedelete')); //visible icon html if ($course->privacy) { $imgparams = array('src' => $this->output->pix_url('i/hide'), 'class' => 'siteimage', 'alt' => get_string('disable')); $makevisible = false; } else { $imgparams = array('src' => $this->output->pix_url('i/show'), 'class' => 'siteimage', 'alt' => get_string('enable')); $makevisible = true; } $hideimgtag = html_writer::empty_tag('img', $imgparams); $visibleurlparams = array('sesskey' => sesskey(), 'visible' => $makevisible, 'courseid' => $course->id); $visibleurl = new moodle_url("/local/hub/admin/managecourses.php", $visibleurlparams); $visiblehtml = html_writer::tag('div', html_writer::tag('a', $hideimgtag, array('href' => $visibleurl)), array('class' => 'hubcoursevisible')); //settings link html $settingsurl = new moodle_url("/local/hub/admin/coursesettings.php", array('sesskey' => sesskey(), 'id' => $course->id)); $settingslinkhtml = html_writer::tag('div', html_writer::tag('a', get_string('edit'), array('href' => $settingsurl)), array('class' => 'hubcoursesettings')); } else { $visiblehtml = ""; $settingslinkhtml = ""; $checkboxhtml = ""; if (is_siteadmin()) { //create Edit course link $managecourseurl = new moodle_url($CFG->wwwroot . '/local/hub/admin/managecourses.php', array('courseid' => $course->id, 'sesskey' => sesskey())); $courseatag = html_writer::tag('a', get_string('editcourse', 'local_hub'), array('href' => $managecourseurl)); $sitehtml = html_writer::tag('div', $courseatag, array('class' => 'coursesitelink')); } else { $sitehtml = ""; } } //create visit link html $courseurl = ''; $linktext = ''; $visitlinkhtml = ''; if (!empty($course->courseurl)) { $courseurl = new moodle_url($course->courseurl); $linktext = get_string('visitsite', 'local_hub'); } else { if (!empty($course->demourl)) { $courseurl = new moodle_url($course->demourl); $linktext = get_string('visitdemo', 'local_hub'); } } if (!empty($courseurl)) { if (!$withwriteaccess) { $courseurl = new moodle_url('', array('sesskey' => sesskey(), 'redirectcourseid' => $course->id)); } $visitlinkhtml = html_writer::tag('a', $linktext, array('href' => $courseurl, 'class' => 'hubcoursedownload')); } // Create rating html. $featuredhtml = ""; $rating = ""; if (has_capability('moodle/rating:rate', $course->rating->context)) { $rating = html_writer::tag('div', $this->output->render($course->rating), array('class' => 'hubcourserating')); } else { if (!empty($course->rating) and $course->rating->count > 0) { $featuredimg = array('src' => $CFG->wwwroot . '/local/hub/images/featured.png', 'class' => '', 'title' => get_string('featureddesc', 'local_hub')); $featuredhtml = html_writer::empty_tag('img', $featuredimg); $featuredhtml = html_writer::tag('div', $featuredhtml, array('class' => 'featuredimg')); } } //create title html $coursename = html_writer::tag('h3', $course->fullname, array('class' => 'hubcoursetitle')); $coursenamehtml = html_writer::tag('div', $coursename, $course->privacy ? array('class' => 'hubcoursetitlepanel') : array('class' => 'dimmed_text', 'class' => 'hubcoursetitlepanel')) . $sitehtml; // create screenshots html $screenshothtml = ''; if (!empty($course->screenshots)) { $baseurl = new moodle_url($CFG->wwwroot . '/local/hub/webservice/download.php', array('courseid' => $course->id, 'filetype' => HUB_SCREENSHOT_FILE_TYPE)); $screenshothtml = html_writer::empty_tag('img', array('src' => $baseurl, 'alt' => $course->fullname)); } $coursescreenshot = html_writer::tag('div', $screenshothtml, array('class' => 'coursescreenshot', 'id' => 'image-' . $course->id)); //create description html $deschtml = html_writer::tag('div', $course->description, array('class' => 'hubcoursedescription')); //create users related information html $courseuserinfo = get_string('userinfo', 'local_hub', $course); if ($course->contributornames) { $courseuserinfo .= ' - ' . get_string('contributors', 'local_hub', $course->contributornames); } $courseuserinfo .= html_writer::tag('a', html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/email'), 'class' => 'hubcoursemail', 'alt' => get_string('msgtopublisher', 'local_hub', $course->fullname))), array('href' => new moodle_url('/local/hub/sendmessage.php', array('id' => $course->id, 'admin' => $withwriteaccess)))); $courseuserinfohtml = html_writer::tag('div', $courseuserinfo, array('class' => 'hubcourseuserinfo')); //create course content related information html $course->subject = get_string($course->subject, 'edufields'); $course->audience = get_string('audience' . $course->audience, 'hub'); $course->educationallevel = get_string('edulevel' . $course->educationallevel, 'hub'); $coursecontentinfo = ''; if (empty($course->coverage)) { $course->coverage = ''; } else { $coursecontentinfo .= get_string('coverage', 'local_hub', $course->coverage); $coursecontentinfo .= ' - '; } $coursecontentinfo .= get_string('contentinfo', 'local_hub', $course); $coursecontentinfohtml = html_writer::tag('div', $coursecontentinfo, array('class' => 'hubcoursecontentinfo')); ///create course file related information html //language if (!empty($course->language)) { $languages = get_string_manager()->get_list_of_languages(); $course->lang = $languages[$course->language]; } else { $course->lang = ''; } //licence require_once $CFG->libdir . "/licenselib.php"; $licensemanager = new license_manager(); $licenses = $licensemanager->get_licenses(); foreach ($licenses as $license) { if ($license->shortname == $course->licenceshortname) { $course->license = $license->fullname; } } $course->timeupdated = userdate($course->timemodified); $coursefileinfo = get_string('fileinfo', 'local_hub', $course); $coursefileinfohtml = html_writer::tag('div', $coursefileinfo, array('class' => 'hubcoursefileinfo')); //Create course content html $blocksandactivities = ''; if (!empty($course->contents)) { $activitieshtml = ''; $blockhtml = ''; foreach ($course->contents as $content) { if ($content->moduletype == 'block') { if (!empty($blockhtml)) { $blockhtml .= ' - '; } $blockpath = get_component_directory('block_' . $content->modulename); $blockname = !is_dir($blockpath) ? $content->modulename : get_string('pluginname', 'block_' . $content->modulename); $blockhtml .= $blockname . " (" . $content->contentcount . ")"; } else { if (!empty($activitieshtml)) { $activitieshtml .= ' - '; } $activitypath = get_component_directory($content->modulename); $activityname = !is_dir($activitypath) ? $content->modulename : get_string('modulename', $content->modulename); $activitieshtml .= $activityname . " (" . $content->contentcount . ")"; } } $blocksandactivities = html_writer::tag('div', get_string('activities', 'local_hub') . " : " . $activitieshtml); //Uncomment following lines to display blocks information // $blocksandactivities .= html_writer::tag('span', // get_string('blocks', 'local_hub') . " : " . $blockhtml); } //Create outcomes html $outcomes = ''; if (!empty($course->outcomes)) { $outcomes = get_string('outcomes', 'local_hub', implode(', ', $course->outcomes)); } $outcomeshtml = html_writer::tag('div', $outcomes, array('class' => 'hubcourseoutcomes')); //create additional information html $additionaldesc = $courseuserinfohtml . $coursecontentinfohtml . $coursefileinfohtml . $blocksandactivities . $outcomeshtml; $additionaldeschtml = html_writer::tag('div', $additionaldesc, array('class' => 'additionaldesc')); //create download button html $downloadbuttonhtml = ""; if (!$course->enrollable) { $params['courseid'] = $course->id; $params['filetype'] = HUB_BACKUP_FILE_TYPE; $params['remotemoodleurl'] = $CFG->wwwroot; $addurl = new moodle_url('/local/hub/webservice/download.php', $params); $downloadbuttonhtml = html_writer::tag('a', get_string('download', 'block_community'), array('href' => $addurl, 'class' => 'centeredbutton, hubcoursedownload')); } //create addthis button $courseurl = new moodle_url('', array('courseid' => $course->id)); $courseurl = $courseurl->out(); //TODO: admin could be able to enter their own pubid into the administration settings page $addthis = "<!-- AddThis Button BEGIN -->\n <div class=\"addthis_toolbox\">\n <div class=\"custom_images\">\n\n <a class=\"addthis_button_facebook\" addthis:url=\"" . $CFG->wwwroot . $courseurl . "\"\n addthis:title=\"" . $course->fullname . "\">\n <img src=\"" . $CFG->wwwroot . "/local/hub/images/facebook.png\" \n width=\"40\" height=\"40\" border=\"0\" alt=\"" . get_string('sharetofacebook', 'local_hub') . "\" /></a>\n <a class=\"addthis_button_twitter\" addthis:url=\"" . $CFG->wwwroot . $courseurl . "\"\n addthis:title=\"" . $course->fullname . "\">\n <img src=\"" . $CFG->wwwroot . "/local/hub/images/twitter.png\" \n width=\"40\" height=\"40\" border=\"0\" alt=\"" . get_string('sharetotwitter', 'local_hub') . "\" /></a>\n <a class=\"addthis_button_more\" addthis:url=\"" . $CFG->wwwroot . $courseurl . "\"\n addthis:title=\"" . $course->fullname . "\">\n <img src=\"" . $CFG->wwwroot . "/local/hub/images/addthis.png\" \n width=\"40\" height=\"40\" border=\"0\" alt=\"" . get_string('sharemore', 'local_hub') . "\" /></a>\n </div>\n </div>\n <script type=\"text/javascript\">\n var addthis_config = {\n \"services_exclude\" : \"print\",\n \"data_track_clickback\":true\n };\n </script>\n <!-- Note that the pubid is the default one from addthis -->\n <script type=\"text/javascript\" \n src=\"http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4db7875a502228bd\"></script> \n <!-- AddThis Button END -->"; $addthis = html_writer::tag('div', $addthis, array('class' => 'addthis')); //Create comments html $comment = html_writer::tag('div', get_string('nocomments', 'local_hub'), array('class' => 'nocomments')); if (!empty($course->comment)) { //display only if there is some comment if there is some comment $commentcount = $course->comment->count(); if ($commentcount != 0 or has_capability('moodle/comment:post', $course->comment->get_context())) { $comment = html_writer::tag('div', $course->comment->output(true), array('class' => 'hubcoursecomments')); } } //creator notes $creatornotes = ''; if (!empty($course->creatornotes)) { if (count($courses) == 1) { //creator notes $creatornotes = html_writer::tag('div', get_string('creatornotes', 'local_hub') . ':', array('class' => 'creatornotestitle')); $creatornotes .= html_writer::tag('div', format_text($course->creatornotes, $course->creatornotesformat), array('class' => 'creatornotes')); } else { //more details button $creatornotesurl = new moodle_url('', array('courseid' => $course->id)); $creatornotes = html_writer::tag('a', get_string('seecreatornotes', 'local_hub'), array('class' => 'seecreatornotes', 'href' => $creatornotesurl)); } } //the main DIV tags $buttonsdiv = html_writer::tag('div', $downloadbuttonhtml . $visitlinkhtml, array('class' => 'courseoperations')); $screenshotbuttonsdiv = html_writer::tag('div', $coursescreenshot . $buttonsdiv . $featuredhtml, array('class' => 'courselinks')); $coursedescdiv = html_writer::tag('div', $deschtml . $additionaldeschtml . $comment . $rating . $creatornotes . $addthis, array('class' => 'coursedescription')); $coursehtml = $coursenamehtml . html_writer::tag('div', $coursedescdiv . $screenshotbuttonsdiv, array('class' => 'hubcourseinfo clearfix')); $coursehtml .= html_writer::tag('div', $checkboxhtml . $visiblehtml . $settingslinkhtml, array('class' => 'hubadminoperations clearfix')); $renderedhtml .= html_writer::tag('div', $coursehtml, array('class' => 'fullhubcourse clearfix')); } $renderedhtml = html_writer::tag('div', $renderedhtml, array('class' => 'hubcourseresult')); //add the select bulk operation if ($withwriteaccess) { $selecthtml = html_writer::select(array('bulkdelete' => get_string('bulkdelete', 'local_hub'), 'bulkvisible' => get_string('bulkvisible', 'local_hub'), 'bulknotvisible' => get_string('bulknotvisible', 'local_hub')), 'bulkselect', '', array('' => get_string('bulkselectoperation', 'local_hub'))); $renderedhtml .= html_writer::tag('div', $selecthtml, array('class' => 'hubbulkselect')); //perform button $optionalurlparams['sesskey'] = sesskey(); $bulkformparam['method'] = 'post'; $bulkformparam['action'] = new moodle_url('', $optionalurlparams); $bulkbutton = html_writer::empty_tag('input', array('class' => 'bulksubmitbutton', 'name' => 'bulksubmitbutton', 'id' => 'bulksubmit', 'type' => 'submit', 'value' => get_string('bulkoperationperform', 'local_hub'))); $renderedhtml .= html_writer::tag('div', $bulkbutton, array('class' => 'hubbulkbutton')); $renderedhtml = html_writer::tag('form', $renderedhtml, $bulkformparam); $renderedhtml = html_writer::tag('div', $renderedhtml); } } return $renderedhtml; }
/** * Generate courses feed content * @param object $courses * @return array */ function local_hub_rss_generate_feed_info($courses) { global $CFG; $rssfeedinfo = array(); foreach ($courses as $course) { $courserss = new stdClass(); $courserss->title = $course->fullname; $courserss->author = $course->creatorname; $courserss->pubdate = $course->timemodified; $courseurl = new moodle_url($CFG->wwwroot . '/index.php', array('courseid' => $course->id, 'rss' => true)); $courserss->link = $courseurl->out(false); //create description $course->subject = get_string($course->subject, 'edufields'); $course->audience = get_string('audience' . $course->audience, 'hub'); $course->educationallevel = get_string('edulevel' . $course->educationallevel, 'hub'); //add course type (enrollable/downloadable) $typetext = empty($course->enrollable) ? get_string('typedownloadable', 'local_hub') : get_string('typeenrollable', 'local_hub'); $deschtml = get_string('coursetype', 'local_hub', $typetext); $deschtml .= html_writer::empty_tag('br'); $deschtml .= $course->description; //the description //create the additional description $additionaldesc = html_writer::empty_tag('br'); $additionaldesc .= get_string('userinfo', 'local_hub', $course); if ($course->contributornames) { $additionaldesc .= ' - '; $additionaldesc .= get_string('contributors', 'local_hub', $course->contributornames); } if (empty($course->coverage)) { $course->coverage = ''; } else { $additionaldesc .= ' - '; $additionaldesc .= get_string('coverage', 'local_hub', $course->coverage); } //retrieve language string //construct languages array if (!empty($course->language)) { $languages = get_string_manager()->get_list_of_languages(); $course->lang = $languages[$course->language]; } else { $course->lang = ''; } //licence require_once $CFG->libdir . "/licenselib.php"; $licensemanager = new license_manager(); $licenses = $licensemanager->get_licenses(); foreach ($licenses as $license) { if ($license->shortname == $course->licenceshortname) { $course->license = $license->fullname; } } //time modified $course->timeupdated = userdate($course->timemodified); $additionaldesc .= ' - ' . get_string('fileinfo', 'local_hub', $course); //subject/audience/level $additionaldesc .= ' - ' . get_string('contentinfo', 'local_hub', $course); $deschtml .= html_writer::tag('span', $additionaldesc, array('class' => 'additionaldesc')); $courserss->description = $deschtml; $rssfeedinfo[] = $courserss; } return $rssfeedinfo; }