本文整理汇总了PHP中license_manager类的典型用法代码示例。如果您正苦于以下问题:PHP license_manager类的具体用法?PHP license_manager怎么用?PHP license_manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了license_manager类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output_html
/**
* 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);
}
示例2: definition
//.........这里部分代码省略.........
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'));
}
}
示例3: course_list
/**
* 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)) {
//.........这里部分代码省略.........
示例4: xmldb_main_install
//.........这里部分代码省略.........
$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';
$admin->password = 'adminsetuppending';
$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');
}
示例5: xmldb_main_install
//.........这里部分代码省略.........
/// 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';
$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';
$admin->password = 'adminsetuppending';
$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);
}
}
示例6: definition
//.........这里部分代码省略.........
$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');
示例7: definition
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);
//.........这里部分代码省略.........
示例8: glossary_xml_import_files
/**
* 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;
}
示例9: require_login
// 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);
}
示例10: definition
//.........这里部分代码省略.........
$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'));
}
}
示例11: course_list
//.........这里部分代码省略.........
$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);
示例12: local_hub_rss_generate_feed_info
/**
* 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;
}