本文整理汇总了PHP中registration_manager::get_registeredhub方法的典型用法代码示例。如果您正苦于以下问题:PHP registration_manager::get_registeredhub方法的具体用法?PHP registration_manager::get_registeredhub怎么用?PHP registration_manager::get_registeredhub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类registration_manager
的用法示例。
在下文中一共展示了registration_manager::get_registeredhub方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rtrim
require_once $CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php';
require_once $CFG->dirroot . '/webservice/lib.php';
require_once $CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php';
$huburl = required_param('huburl', PARAM_URL);
$huburl = rtrim($huburl, "/");
if ($huburl == HUB_MOODLEORGHUBURL) {
// register to Moodle.org
admin_externalpage_setup('registrationmoodleorg');
} else {
//register to a hub
admin_externalpage_setup('registrationhub');
}
$password = optional_param('password', '', PARAM_TEXT);
$hubname = optional_param('hubname', '', PARAM_TEXT);
$registrationmanager = new registration_manager();
$registeredhub = $registrationmanager->get_registeredhub($huburl);
$siteregistrationform = new site_registration_form('', array('alreadyregistered' => !empty($registeredhub->token), 'huburl' => $huburl, 'hubname' => $hubname, 'password' => $password));
$fromform = $siteregistrationform->get_data();
if (!empty($fromform) and confirm_sesskey()) {
//save the settings
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
set_config('site_name_' . $cleanhuburl, $fromform->name, 'hub');
set_config('site_description_' . $cleanhuburl, $fromform->description, 'hub');
set_config('site_contactname_' . $cleanhuburl, $fromform->contactname, 'hub');
set_config('site_contactemail_' . $cleanhuburl, $fromform->contactemail, 'hub');
set_config('site_contactphone_' . $cleanhuburl, $fromform->contactphone, 'hub');
set_config('site_imageurl_' . $cleanhuburl, $fromform->imageurl, 'hub');
set_config('site_privacy_' . $cleanhuburl, $fromform->privacy, 'hub');
set_config('site_address_' . $cleanhuburl, $fromform->address, 'hub');
set_config('site_region_' . $cleanhuburl, $fromform->regioncode, 'hub');
set_config('site_country_' . $cleanhuburl, $fromform->countrycode, 'hub');
示例2: block_community_download_course_backup
/**
* Download the community course backup and save it in file API
* @param integer $courseid
* @param string $huburl
* @return array 'privatefile' the file name saved in private area
* 'tmpfile' the file name saved in the moodledata temp dir (for restore)
*/
public function block_community_download_course_backup($course)
{
global $CFG, $USER;
require_once $CFG->libdir . "/filelib.php";
require_once $CFG->dirroot . "/course/publish/lib.php";
$params['courseid'] = $course->id;
$params['filetype'] = HUB_BACKUP_FILE_TYPE;
make_upload_directory('temp/backup');
$filename = md5(time() . '-' . $course->id . '-' . $USER->id . '-' . random_string(20));
$url = new moodle_url($course->huburl . '/local/hub/webservice/download.php', $params);
$path = $CFG->dataroot . '/temp/backup/' . $filename . ".mbz";
$fp = fopen($path, 'w');
$curlurl = $course->huburl . '/local/hub/webservice/download.php?filetype=' . HUB_BACKUP_FILE_TYPE . '&courseid=' . $course->id;
//send an identification token if the site is registered on the hub
require_once $CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php';
$registrationmanager = new registration_manager();
$registeredhub = $registrationmanager->get_registeredhub($course->huburl);
if (!empty($registeredhub)) {
$token = $registeredhub->token;
$curlurl .= '&token=' . $token;
}
$ch = curl_init($curlurl);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
curl_close($ch);
fclose($fp);
$fs = get_file_storage();
$record = new stdClass();
$record->contextid = get_context_instance(CONTEXT_USER, $USER->id)->id;
$record->component = 'user';
$record->filearea = 'private';
$record->itemid = 0;
$record->filename = urlencode($course->fullname) . "_" . time() . ".mbz";
$record->filepath = '/downloaded_backup/';
if (!$fs->file_exists($record->contextid, $record->component, $record->filearea, 0, $record->filepath, $record->filename)) {
$fs->create_file_from_pathname($record, $CFG->dataroot . '/temp/backup/' . $filename . ".mbz");
}
$filenames = array();
$filenames['privatefile'] = $record->filename;
$filenames['tmpfile'] = $filename;
return $filenames;
}
示例3: array
require_once $CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php';
require_once $CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php';
require_once $CFG->dirroot . '/course/publish/lib.php';
require_once $CFG->dirroot . "/webservice/xmlrpc/lib.php";
admin_externalpage_setup('registrationindex');
$renderer = $PAGE->get_renderer('core', 'register');
$unregistration = optional_param('unregistration', 0, PARAM_INT);
$cleanregdata = optional_param('cleanregdata', 0, PARAM_BOOL);
$confirm = optional_param('confirm', 0, PARAM_INT);
$huburl = optional_param('huburl', '', PARAM_URL);
$cancel = optional_param('cancel', null, PARAM_ALPHA);
$registrationmanager = new registration_manager();
$publicationmanager = new course_publish_manager();
$errormessage = '';
if (empty($cancel) and $unregistration and $confirm and confirm_sesskey()) {
$hub = $registrationmanager->get_registeredhub($huburl);
//unpublish course and unregister the site by web service
if (!$cleanregdata) {
//check if we need to unpublish courses
//enrollable courses
$unpublishalladvertisedcourses = optional_param('unpublishalladvertisedcourses', 0, PARAM_INT);
$hubcourseids = array();
if ($unpublishalladvertisedcourses) {
$enrollablecourses = $publicationmanager->get_publications($huburl, null, 1);
if (!empty($enrollablecourses)) {
foreach ($enrollablecourses as $enrollablecourse) {
$hubcourseids[] = $enrollablecourse->hubcourseid;
}
}
}
//downloadable courses
示例4: definition
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);
//.........这里部分代码省略.........
示例5: definition
//.........这里部分代码省略.........
$mform->setType('imageurl', PARAM_URL);
$mform->addElement('static', 'urlstring', get_string('siteurl', 'hub'), $CFG->wwwroot);
$mform->addHelpButton('urlstring', 'siteurl', 'hub');
$mform->addElement('static', 'versionstring', get_string('siteversion', 'hub'), $CFG->version);
$mform->addElement('hidden', 'moodleversion', $CFG->version);
$mform->setType('moodleversion', PARAM_INT);
$mform->addHelpButton('versionstring', 'siteversion', 'hub');
$mform->addElement('static', 'releasestring', get_string('siterelease', 'hub'), $CFG->release);
$mform->addElement('hidden', 'moodlerelease', $CFG->release);
$mform->setType('moodlerelease', PARAM_TEXT);
$mform->addHelpButton('releasestring', 'siterelease', 'hub');
/// Display statistic that are going to be retrieve by the hub
$coursecount = $DB->count_records('course') - 1;
$usercount = $DB->count_records('user', array('deleted' => 0));
$roleassigncount = $DB->count_records('role_assignments');
$postcount = $DB->count_records('forum_posts');
$questioncount = $DB->count_records('question');
$resourcecount = $DB->count_records('resource');
require_once $CFG->dirroot . "/course/lib.php";
$participantnumberaverage = number_format(average_number_of_participants(), 2);
$modulenumberaverage = number_format(average_number_of_courses_modules(), 2);
require_once $CFG->libdir . '/badgeslib.php';
$badges = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
$issuedbadges = $DB->count_records('badge_issued');
if (HUB_MOODLEORGHUBURL != $huburl) {
$mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'), " " . get_string('coursesnumber', 'hub', $coursecount));
$mform->setDefault('courses', $coursesnumber != -1);
$mform->setType('courses', PARAM_INT);
$mform->addHelpButton('courses', 'sendfollowinginfo', 'hub');
$mform->addElement('checkbox', 'users', '', " " . get_string('usersnumber', 'hub', $usercount));
$mform->setDefault('users', $usersnumber != -1);
$mform->setType('users', PARAM_INT);
$mform->addElement('checkbox', 'roleassignments', '', " " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
$mform->setDefault('roleassignments', $roleassignmentsnumber != -1);
$mform->setType('roleassignments', PARAM_INT);
$mform->addElement('checkbox', 'posts', '', " " . get_string('postsnumber', 'hub', $postcount));
$mform->setDefault('posts', $postsnumber != -1);
$mform->setType('posts', PARAM_INT);
$mform->addElement('checkbox', 'questions', '', " " . get_string('questionsnumber', 'hub', $questioncount));
$mform->setDefault('questions', $questionsnumber != -1);
$mform->setType('questions', PARAM_INT);
$mform->addElement('checkbox', 'resources', '', " " . get_string('resourcesnumber', 'hub', $resourcecount));
$mform->setDefault('resources', $resourcesnumber != -1);
$mform->setType('resources', PARAM_INT);
$mform->addElement('checkbox', 'badges', '', " " . get_string('badgesnumber', 'hub', $badges));
$mform->setDefault('badges', $badgesnumber != -1);
$mform->setType('resources', PARAM_INT);
$mform->addElement('checkbox', 'issuedbadges', '', " " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
$mform->setDefault('issuedbadges', $issuedbadgesnumber != -1);
$mform->setType('resources', PARAM_INT);
$mform->addElement('checkbox', 'participantnumberaverage', '', " " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
$mform->setDefault('participantnumberaverage', $participantnumberaveragecfg != -1);
$mform->setType('participantnumberaverage', PARAM_FLOAT);
$mform->addElement('checkbox', 'modulenumberaverage', '', " " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
$mform->setDefault('modulenumberaverage', $modulenumberaveragecfg != -1);
$mform->setType('modulenumberaverage', PARAM_FLOAT);
} else {
$mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'), " " . get_string('coursesnumber', 'hub', $coursecount));
$mform->addElement('hidden', 'courses', 1);
$mform->setType('courses', PARAM_INT);
$mform->addHelpButton('courseslabel', 'sendfollowinginfo', 'hub');
$mform->addElement('static', 'userslabel', '', " " . get_string('usersnumber', 'hub', $usercount));
$mform->addElement('hidden', 'users', 1);
$mform->setType('users', PARAM_INT);
$mform->addElement('static', 'roleassignmentslabel', '', " " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
$mform->addElement('hidden', 'roleassignments', 1);
$mform->setType('roleassignments', PARAM_INT);
$mform->addElement('static', 'postslabel', '', " " . get_string('postsnumber', 'hub', $postcount));
$mform->addElement('hidden', 'posts', 1);
$mform->setType('posts', PARAM_INT);
$mform->addElement('static', 'questionslabel', '', " " . get_string('questionsnumber', 'hub', $questioncount));
$mform->addElement('hidden', 'questions', 1);
$mform->setType('questions', PARAM_INT);
$mform->addElement('static', 'resourceslabel', '', " " . get_string('resourcesnumber', 'hub', $resourcecount));
$mform->addElement('hidden', 'resources', 1);
$mform->setType('resources', PARAM_INT);
$mform->addElement('static', 'badgeslabel', '', " " . get_string('badgesnumber', 'hub', $badges));
$mform->addElement('hidden', 'badges', 1);
$mform->setType('badges', PARAM_INT);
$mform->addElement('static', 'issuedbadgeslabel', '', " " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
$mform->addElement('hidden', 'issuedbadges', true);
$mform->setType('issuedbadges', PARAM_INT);
$mform->addElement('static', 'participantnumberaveragelabel', '', " " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
$mform->addElement('hidden', 'participantnumberaverage', 1);
$mform->setType('participantnumberaverage', PARAM_FLOAT);
$mform->addElement('static', 'modulenumberaveragelabel', '', " " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
$mform->addElement('hidden', 'modulenumberaverage', 1);
$mform->setType('modulenumberaverage', PARAM_FLOAT);
}
//check if it's a first registration or update
$hubregistered = $registrationmanager->get_registeredhub($huburl);
if (!empty($hubregistered)) {
$buttonlabel = get_string('updatesite', 'hub', !empty($hubname) ? $hubname : $huburl);
$mform->addElement('hidden', 'update', true);
$mform->setType('update', PARAM_BOOL);
} else {
$buttonlabel = get_string('registersite', 'hub', !empty($hubname) ? $hubname : $huburl);
}
$this->add_action_buttons(false, $buttonlabel);
}
示例6: array
require_capability('moodle/site:config', context_system::instance());
$strheading = get_string('requestaccesskey', 'message_airnotifier');
$PAGE->navbar->add(get_string('administrationsite'));
$PAGE->navbar->add(get_string('plugins', 'admin'));
$PAGE->navbar->add(get_string('messageoutputs', 'message'));
$returl = new moodle_url('/admin/settings.php', array('section' => 'messagesettingairnotifier'));
$PAGE->navbar->add(get_string('pluginname', 'message_airnotifier'), $returl);
$PAGE->navbar->add($strheading);
$PAGE->set_heading($strheading);
$PAGE->set_title($strheading);
$msg = "";
// If we are requesting a key to the official message system, verify first that this site is registered.
// This check is also done in Airnotifier.
if (strpos($CFG->airnotifierurl, AIRNOTIFIER_PUBLICURL) !== false) {
$registrationmanager = new registration_manager();
if (!$registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL)) {
$msg = get_string('sitemustberegistered', 'message_airnotifier');
$msg .= $OUTPUT->continue_button($returl);
echo $OUTPUT->header();
echo $OUTPUT->box($msg, 'generalbox');
echo $OUTPUT->footer();
die;
}
}
$manager = new message_airnotifier_manager();
if ($key = $manager->request_accesskey()) {
set_config('airnotifieraccesskey', $key);
$msg = get_string('keyretrievedsuccessfully', 'message_airnotifier');
} else {
$msg = get_string('errorretrievingkey', 'message_airnotifier');
}