hub MDL-19309 new site registration form + course publication + community block
authorjerome mouneyrac <jerome@moodle.com>
Sat, 1 May 2010 05:05:55 +0000 (05:05 +0000)
committerjerome mouneyrac <jerome@moodle.com>
Sat, 1 May 2010 05:05:55 +0000 (05:05 +0000)
36 files changed:
admin/registration/confirmregistration.php [new file with mode: 0644]
admin/registration/forms.php [new file with mode: 0644]
admin/registration/hubselector.php [new file with mode: 0644]
admin/registration/index.php [new file with mode: 0644]
admin/registration/register.php [new file with mode: 0644]
admin/registration/renderer.php [new file with mode: 0644]
admin/settings/top.php
blocks/community/block_community.php [new file with mode: 0644]
blocks/community/communitycourse.php [new file with mode: 0644]
blocks/community/db/install.xml [new file with mode: 0644]
blocks/community/db/upgrade.php [new file with mode: 0644]
blocks/community/forms.php [new file with mode: 0644]
blocks/community/lang/en/block_community.php [new file with mode: 0644]
blocks/community/locallib.php [new file with mode: 0644]
blocks/community/renderer.php [new file with mode: 0644]
course/lib.php
course/publish/forms.php [new file with mode: 0644]
course/publish/hubselector.php [new file with mode: 0644]
course/publish/index.php [new file with mode: 0644]
course/publish/metadata.php [new file with mode: 0644]
course/publish/publish.php [new file with mode: 0644]
course/publish/renderer.php [new file with mode: 0644]
lang/en/edufields.php [new file with mode: 0644]
lang/en/hub.php [new file with mode: 0644]
lang/en/moodle.php
lib/adminlib.php
lib/db/access.php
lib/db/install.xml
lib/db/upgrade.php
lib/hublib.php [new file with mode: 0644]
lib/moodlelib.php
lib/navigationlib.php
pix/i/publish.png [new file with mode: 0644]
theme/standard/style/core.css
version.php
webservice/xmlrpc/lib.php [new file with mode: 0644]

diff --git a/admin/registration/confirmregistration.php b/admin/registration/confirmregistration.php
new file mode 100644 (file)
index 0000000..9f5daf5
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/*
+ * @package    moodle
+ * @subpackage registration
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * The administrator is redirect to this page from the hub to confirm that the
+ * site has been registered. It is an administration page. The administrator
+ * should be using the same browser during all the registration process.
+ * This page save the token that the hub gave us, in order to call the hub
+ * directory later by web service.
+*/
+
+require('../../config.php');
+require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->dirroot.'/lib/hublib.php');
+
+admin_externalpage_setup('siteregistrationconfirmed');
+
+$newtoken        = optional_param('newtoken', '', PARAM_ALPHANUM);
+$url             = optional_param('url', '', PARAM_URL);
+$token           = optional_param('token', '', PARAM_ALPHANUM);
+
+$hub = new hub();
+
+//check that the token/url couple exist and is not confirmed
+$registeredhub = $hub->get_registeredhub($url);
+if (!empty($registeredhub) and  $registeredhub->confirmed == 0
+        and $registeredhub->token == $token) {
+
+    $registeredhub->token = $newtoken;
+    $registeredhub->confirmed = 1;
+    $hub->update_registeredhub($registeredhub);
+
+    echo $OUTPUT->header();
+    echo $OUTPUT->notification(get_string('registrationconfirmed', 'hub'), 'notifysuccess');
+    echo $OUTPUT->footer();
+} else {
+    throw new moodle_exception('wrongtoken');
+}
+
+
diff --git a/admin/registration/forms.php b/admin/registration/forms.php
new file mode 100644 (file)
index 0000000..326d06d
--- /dev/null
@@ -0,0 +1,360 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/*
+ * @package    moodle
+ * @subpackage registration
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * The forms needed by registration pages.
+*/
+
+
+require_once($CFG->dirroot.'/lib/formslib.php');
+require_once($CFG->dirroot.'/lib/hublib.php');
+
+/**
+ * This form display a hub selector.
+ * The hub list is retrieved from Moodle.org hub directory.
+ * Also displayed, a text field to enter private hub url + its password
+ */
+class hub_selector_form extends moodleform {
+
+    public function definition() {
+        global $CFG;
+        $mform =& $this->_form;
+        $mform->addElement('header', 'site', get_string('selecthub', 'hub'));
+
+        //retrieve the hub list on the hub directory by web service
+        $function = 'hubdirectory_get_hubs';
+        $params = array();
+        $serverurl = HUBDIRECTORYURL."/local/hubdirectory/webservice/webservices.php";
+        require_once($CFG->dirroot."/webservice/xmlrpc/lib.php");
+        $xmlrpcclient = new webservice_xmlrpc_client();
+        $hubs = $xmlrpcclient->call($serverurl, 'publichubdirectory', $function, $params);
+
+        //Public hub list
+        $options = array();
+        foreach ($hubs as $hub) {
+            //to not display a name longer than 100 character (too big)
+            if (strlen($hub['name'])>100) {
+                $hubname = substr($hub['name'],0, 100);
+                $hubname = $hubname."...";
+            } else {
+                $hubname = $hub['name'];
+            }
+            $options[$hub['url']] = $hubname;
+            $mform->addElement('hidden', clean_param($hub['url'], PARAM_ALPHANUMEXT), $hubname);
+        }
+        $mform->addElement('select', 'publichub', get_string('publichub','hub'),
+                $options, array("size" => 15));
+
+        $mform->addElement('static','or' , '', get_string('orenterprivatehub', 'hub'));
+
+        //Private hub
+        $mform->addElement('text','unlistedurl' , get_string('privatehuburl', 'hub'));
+        $mform->addElement('text','password' , get_string('password'));
+
+        $this->add_action_buttons(false, get_string('selecthub', 'hub'));
+    }
+
+    /**
+     * Check the unlisted URL is a URL
+     */
+    function validation($data, $files) {
+        global $CFG;
+        $errors = parent::validation($data, $files);
+
+        $unlistedurl = $this->_form->_submitValues['unlistedurl'];
+
+        if (!empty($unlistedurl)) {
+            $unlistedurltotest = clean_param($unlistedurl, PARAM_URL);
+            if (empty($unlistedurltotest)) {
+                $errors['unlistedurl'] = get_string('badurlformat', 'hub');
+            }
+        }
+
+        return $errors;
+    }
+
+}
+
+
+/**
+ * The site registration form. Information will be sent to a given hub.
+ */
+class site_registration_form extends moodleform {
+
+    public function definition() {
+        global $CFG, $DB;
+
+        $strrequired = get_string('required');
+        $mform =& $this->_form;
+        $huburl = $this->_customdata['huburl'];
+        $hubname = $this->_customdata['hubname'];
+        $admin = get_admin();
+        $site = get_site();
+
+        //retrieve config for this hub and set default if they don't exist
+        $cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
+        $sitename = get_config('hub', 'site_name_'.$cleanhuburl);
+        if ($sitename === false) {
+            $sitename = $site->fullname;
+        }
+        $sitedescription = get_config('hub', 'site_description_'.$cleanhuburl);
+        if ($sitedescription === false) {
+            $sitedescription = $site->summary;
+        }
+        $contactname = get_config('hub', 'site_contactname_'.$cleanhuburl);
+        if ($contactname === false) {
+            $contactname = fullname($admin, true);
+        }
+        $contactemail = get_config('hub', 'site_contactemail_'.$cleanhuburl);
+        if ($contactemail === false) {
+            $contactemail = $admin->email;
+        }
+        $contactphone = get_config('hub', 'site_contactphone_'.$cleanhuburl);
+        if ($contactphone === false) {
+            $contactphone = $admin->phone1;
+        }
+        $imageurl = get_config('hub', 'site_imageurl_'.$cleanhuburl);
+        $privacy = get_config('hub', 'site_privacy_'.$cleanhuburl);
+        $address = get_config('hub', 'site_address_'.$cleanhuburl);
+        $region = get_config('hub', 'site_region_'.$cleanhuburl);
+        $country = get_config('hub', 'site_country_'.$cleanhuburl);
+        if ($country === false) {
+            $country =  $admin->country;
+        }
+        $geolocation = get_config('hub', 'site_geolocation_'.$cleanhuburl);
+        $contactable = get_config('hub', 'site_contactable_'.$cleanhuburl);
+        $emailalert = get_config('hub', 'site_emailalert_'.$cleanhuburl);
+        $coursesnumber = get_config('hub', 'site_coursesnumber_'.$cleanhuburl);
+        $usersnumber = get_config('hub', 'site_usersnumber_'.$cleanhuburl);
+        $roleassignmentsnumber = get_config('hub', 'site_roleassignmentsnumber_'.$cleanhuburl);
+        $postsnumber = get_config('hub', 'site_postsnumber_'.$cleanhuburl);
+        $questionsnumber = get_config('hub', 'site_questionsnumber_'.$cleanhuburl);
+        $resourcesnumber = get_config('hub', 'site_resourcesnumber_'.$cleanhuburl);
+        $mediancoursesize = get_config('hub', 'site_mediancoursesize_'.$cleanhuburl);
+
+        //hidden parameters
+        $mform->addElement('hidden', 'huburl', $huburl);
+        $mform->addElement('hidden', 'hubname', $hubname);
+
+        //the input parameters
+        $mform->addElement('header', 'moodle', get_string('registrationinfo', 'hub'));
+
+        $mform->addElement('text','name' , get_string('fullsitename'));
+        $mform->addRule('name', $strrequired, 'required', null, 'client');
+        $mform->setType('name', PARAM_TEXT);
+        $mform->setDefault('name', $sitename);
+
+        $options = array();
+        $hub = new hub();
+        $options[SITENOTPUBLISHED] = $hub->get_site_privacy_string(SITENOTPUBLISHED);
+        $options[SITENAMEPUBLISHED] = $hub->get_site_privacy_string(SITENAMEPUBLISHED);
+        $options[SITELINKPUBLISHED] = $hub->get_site_privacy_string(SITELINKPUBLISHED);
+        $mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), $options);
+        $mform->setDefault('privacy', $privacy);
+        unset($options);
+
+        $mform->addElement('textarea', 'description', get_string('description'), array('rows'=>10));
+        $mform->addRule('description', $strrequired, 'required', null, 'client');
+        $mform->setDefault('description', $sitedescription);
+        $mform->setType('description', PARAM_TEXT);
+
+        $mform->addElement('static', 'urlstring',get_string('siteurl', 'hub'), $CFG->wwwroot);
+
+        $languages = get_string_manager()->get_list_of_languages();
+        $mform->addElement('static', 'langstring',get_string('language'), $languages[current_language()]);
+        $mform->addElement('hidden', 'language', current_language());
+
+        $mform->addElement('static', 'versionstring',get_string('moodleversion'), $CFG->version);
+        $mform->addElement('hidden', 'moodleversion', $CFG->version);
+
+        $mform->addElement('static', 'releasestring',get_string('moodlerelease'), $CFG->release);
+        $mform->addElement('hidden', 'moodlerelease', $CFG->release);
+
+        $mform->addElement('textarea','address' , get_string('postaladdress', 'hub'));
+        $mform->setType('address', PARAM_TEXT);
+        $mform->setDefault('address', $address);
+
+        //TODO: use the region array I generated
+        $mform->addElement('select', 'region', get_string('selectaregion'), array('-' => '-'));
+        $mform->setDefault('region', $region);
+
+        $countries = get_string_manager()->get_list_of_countries();
+        $mform->addElement('select', 'country', get_string('selectacountry'), $countries);
+        $mform->setDefault('country', $country);
+
+        $mform->addElement('text','geolocation' , get_string('geolocation'));
+        $mform->setDefault('geolocation', $geolocation);
+
+        $mform->addElement('text', 'contactname', get_string('administrator'));
+        $mform->addRule('contactname', $strrequired, 'required', null, 'client');
+        $mform->setType('contactname', PARAM_TEXT);
+        $mform->setDefault('contactname', $contactname);
+
+        $mform->addElement('text','contactphone' , get_string('phone'));
+        $mform->setType('contactphone', PARAM_TEXT);
+
+        $mform->addElement('text', 'contactemail', get_string('email'));
+        $mform->addRule('contactemail', $strrequired, 'required', null, 'client');
+        $mform->setType('contactemail', PARAM_TEXT);
+        $mform->setDefault('contactemail', $contactemail);
+
+        $options = array();
+        $options[0] = get_string("registrationcontactno");
+        $options[1] = get_string("registrationcontactyes");
+        $mform->addElement('select', 'contactable', get_string('registrationcontact'), $options);
+        $mform->setDefault('contactable', $contactable);
+        unset($options);
+
+        $options = array();
+        $options[0] = get_string("registrationno");
+        $options[1] = get_string("registrationyes");
+        $mform->addElement('select', 'emailalert', get_string('registrationemail'), $options);
+        $mform->setDefault('emailalert', $emailalert);
+        unset($options);
+
+        $mform->addElement('text','imageurl' , get_string('logourl', 'hub'));
+        $mform->setType('imageurl', PARAM_URL);
+        $mform->setDefault('imageurl', $imageurl);
+
+        /// 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= average_number_of_participants();
+        $modulenumberaverage= average_number_of_courses_modules();
+
+        if (MOODLEORGHUBURL != $huburl) {
+            $mform->addElement('checkbox', 'courses',  get_string('sendfollowinginfo', 'hub'),
+                    " ".get_string('coursesnumber', 'hub', $coursecount));
+            $mform->setDefault('courses', true);
+
+            $mform->addElement('checkbox', 'users', '',
+                    " ".get_string('usersnumber', 'hub', $usercount));
+            $mform->setDefault('users', true);
+
+            $mform->addElement('checkbox', 'roleassignments', '',
+                    " ".get_string('roleassignmentsnumber', 'hub', $roleassigncount));
+            $mform->setDefault('roleassignments', true);
+
+            $mform->addElement('checkbox', 'posts', '',
+                    " ".get_string('postsnumber', 'hub', $postcount));
+            $mform->setDefault('posts', true);
+
+            $mform->addElement('checkbox', 'questions', '',
+                    " ".get_string('questionsnumber', 'hub', $questioncount));
+            $mform->setDefault('questions', true);
+
+            $mform->addElement('checkbox', 'resources', '',
+                    " ".get_string('resourcesnumber', 'hub', $resourcecount));
+            $mform->setDefault('resources', true);
+
+            $mform->addElement('checkbox', 'participantnumberaverage', '',
+                    " ".get_string('participantnumberaverage', 'hub', $participantnumberaverage));
+            $mform->setDefault('participantnumberaverage', true);
+
+            $mform->addElement('checkbox', 'modulenumberaverage', '',
+                    " ".get_string('modulenumberaverage', 'hub', $modulenumberaverage));
+            $mform->setDefault('modulenumberaverage', true);
+        } else {
+            $mform->addElement('static', 'courseslabel',get_string('sendfollowinginfo', 'hub'),
+                    " ".get_string('coursesnumber', 'hub', $coursecount));
+            $mform->addElement('hidden', 'courses', true);
+
+            $mform->addElement('static', 'userslabel', '',
+                    " ".get_string('usersnumber', 'hub', $usercount));
+            $mform->addElement('hidden', 'users', true);
+
+            $mform->addElement('static', 'roleassignmentslabel', '',
+                    " ".get_string('roleassignmentsnumber', 'hub', $roleassigncount));
+            $mform->addElement('hidden', 'roleassignments', true);
+
+            $mform->addElement('static', 'postslabel', '',
+                    " ".get_string('postsnumber', 'hub', $postcount));
+            $mform->addElement('hidden', 'posts', true);
+
+            $mform->addElement('static', 'questionslabel', '',
+                    " ".get_string('questionsnumber', 'hub', $questioncount));
+            $mform->addElement('hidden', 'questions', true);
+
+            $mform->addElement('static', 'resourceslabel', '',
+                    " ".get_string('resourcesnumber', 'hub', $resourcecount));
+            $mform->addElement('hidden', 'resources', true);
+
+            $mform->addElement('static', 'participantnumberaveragelabel', '',
+                    " ".get_string('participantnumberaverage', 'hub', $participantnumberaverage));
+            $mform->addElement('hidden', 'participantnumberaverage', true);
+
+            $mform->addElement('static', 'modulenumberaveragelabel', '',
+                    " ".get_string('modulenumberaverage', 'hub', $modulenumberaverage));
+            $mform->addElement('hidden', 'modulenumberaverage', true);
+        }
+
+        //check if it's a first registration or update
+        $hubregistered = $hub->get_registeredhub($huburl);
+
+        if (!empty($hubregistered)) {
+            $buttonlabel = get_string('updatesite', 'hub',
+                    !empty($hubname)?$hubname:$huburl);
+            $mform->addElement('hidden', 'update', true);
+        } else {
+            $buttonlabel = get_string('registersite', 'hub',
+                    !empty($hubname)?$hubname:$huburl);
+        }
+
+        $this->add_action_buttons(false, $buttonlabel);
+    }
+
+    /**
+     * Check that the image size is correct
+     */
+    function validation($data, $files) {
+        global $CFG;
+
+        $errors = array();
+
+        //check if the image (imageurl) has a correct size
+        $imageurl = $this->_form->_submitValues['imageurl'];
+        if (!empty($imageurl)) {
+            list($imagewidth, $imageheight, $imagetype, $imageattr)  = getimagesize($imageurl); //getimagesize is a GD function
+            if ($imagewidth > SITEIMAGEWIDTH or $imageheight > SITEIMAGEHEIGHT) {
+                $sizestrings = new stdClass();
+                $sizestrings->width = SITEIMAGEWIDTH;
+                $sizestrings->height = SITEIMAGEHEIGHT;
+                $errors['imageurl'] = get_string('errorbadimageheightwidth', 'hub', $sizestrings);
+            }
+        }
+
+        return $errors;
+    }
+
+}
+
+?>
diff --git a/admin/registration/hubselector.php b/admin/registration/hubselector.php
new file mode 100644 (file)
index 0000000..11fe1ab
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/*
+ * @package    moodle
+ * @subpackage registration
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * Thsi page displays a hub selector or a hub URL + password. Then it will redirect to
+ * the site registration form (with the selected hub as parameter)
+*/
+
+require('../../config.php');
+
+require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->dirroot.'/admin/registration/forms.php');
+
+admin_externalpage_setup('registrationselector');
+
+$hubselectorform = new hub_selector_form();
+$fromform = $hubselectorform->get_data();
+
+//// Redirect to the registration form if an URL has been choosen ////
+
+$selectedhuburl = optional_param('publichub', false, PARAM_URL);
+$unlistedhuburl = optional_param('unlistedurl', false, PARAM_TEXT);
+$password = optional_param('password', '', PARAM_RAW);
+
+if (!empty($unlistedhuburl)) {
+    if (clean_param($unlistedhuburl, PARAM_URL) !== '') {
+        $huburl = $unlistedhuburl;
+    }
+} else if (!empty($selectedhuburl)) {
+    $huburl = $selectedhuburl;
+}
+
+
+//redirect
+if (!empty($huburl) and confirm_sesskey()) {
+    $hubname = optional_param(clean_param($huburl, PARAM_ALPHANUMEXT), '', PARAM_TEXT);
+    $params = array('sesskey' => sesskey(), 'huburl' => $huburl,
+            'password' => $password, 'hubname' => $hubname);
+    redirect(new moodle_url($CFG->wwwroot."/admin/registration/register.php",
+            $params));
+}
+
+
+//// OUTPUT ////
+
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
+$hubselectorform->display();
+echo $OUTPUT->footer();
\ No newline at end of file
diff --git a/admin/registration/index.php b/admin/registration/index.php
new file mode 100644 (file)
index 0000000..8af727a
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/*
+ * @package    moodle
+ * @subpackage registration
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * On this page the administrator select if he wants to register on Moodle.org or
+ * a specific hub
+*/
+
+require('../../config.php');
+
+require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->libdir.'/hublib.php');
+
+admin_externalpage_setup('registrationindex');
+
+$renderer = $PAGE->get_renderer('core', 'register');
+
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
+echo $renderer->registrationselector();
+echo $OUTPUT->footer();
\ No newline at end of file
diff --git a/admin/registration/register.php b/admin/registration/register.php
new file mode 100644 (file)
index 0000000..26d112d
--- /dev/null
@@ -0,0 +1,158 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/*
+ * @package    moodle
+ * @subpackage registration
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * This page displays the site registration form.
+ * It handles redirection to the hub to continue the registration workflow process.
+ * It also handles update operation by web service.
+*/
+
+
+require_once('../../config.php');
+require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->dirroot.'/admin/registration/forms.php');
+require_once($CFG->dirroot.'/webservice/lib.php');
+require_once($CFG->dirroot.'/lib/hublib.php');
+
+admin_externalpage_setup('registration');
+
+
+$huburl = optional_param('huburl', '', PARAM_URL);
+$hubname = optional_param('hubname', '', PARAM_TEXT);
+if (empty($huburl) or !confirm_sesskey()) {
+    throw new moodle_exception('cannotaccessthispage');
+}
+
+/* TO DO
+if DB config plugin table is not good for dealing with token reference and token confirmation
+ => create other DB table
+-----------------------------------------------------------------------------
+Local Type | Token | Local WS | Remote Type | Remote URL        | Confirmed
+-----------------------------------------------------------------------------
+  HUB        4er4e   server    HUB-DIRECTORY  http...moodle.org      Yes
+  HUB        73j53   client    HUB-DIRECTORY  http...moodle.org      Yes
+  SITE       dfsd7   server    HUB            http...hub             Yes
+  SITE       fd8fd   client    HUB            http...hub             Yes
+  HUB        ds78s   server    SITE           http...site.com        Yes
+  HUB-DIR.   d7d8s   server    HUB            http...hub             Yes
+-----------------------------------------------------------------------------
+*/
+
+$hub = new hub();
+
+$registeredhub = $hub->get_registeredhub($huburl);
+
+$siteregistrationform = new site_registration_form('',
+        array('alreadyregistered' => !empty($registeredhub->token),
+                'huburl' => $huburl, 'hubname' => $hubname));
+$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->region, 'hub');
+    set_config('site_country_'.$cleanhuburl, $fromform->country, 'hub');
+    set_config('site_geolocation_'.$cleanhuburl, $fromform->geolocation, 'hub');
+    set_config('site_contactable_'.$cleanhuburl, $fromform->contactable, 'hub');
+    set_config('site_emailalert_'.$cleanhuburl, $fromform->emailalert, 'hub');
+    set_config('site_coursesnumber_'.$cleanhuburl, $fromform->courses, 'hub');
+    set_config('site_usersnumber_'.$cleanhuburl, $fromform->users, 'hub');
+    set_config('site_roleassignmentsnumber_'.$cleanhuburl, $fromform->roleassignments, 'hub');
+    set_config('site_postsnumber_'.$cleanhuburl, $fromform->posts, 'hub');
+    set_config('site_questionsnumber_'.$cleanhuburl, $fromform->questions, 'hub');
+    set_config('site_resourcesnumber_'.$cleanhuburl, $fromform->resources, 'hub');
+    set_config('site_modulenumberaverage_'.$cleanhuburl, $fromform->modulenumberaverage, 'hub');
+    set_config('site_participantnumberaverage_'.$cleanhuburl, $fromform->participantnumberaverage, 'hub');
+}
+
+/////// UNREGISTER ACTION //////
+// TODO
+
+
+/////// UPDATE ACTION ////////
+
+// update the hub registration
+$update     = optional_param('update', 0, PARAM_INT);
+if ($update and confirm_sesskey()) {
+
+    //update the registration
+    $function = 'hub_update_site_info';
+    $siteinfo = $hub->get_site_info($huburl);
+    $params = array($siteinfo);
+    $serverurl = $huburl."/local/hub/webservice/webservices.php";
+    require_once($CFG->dirroot."/webservice/xmlrpc/lib.php");
+    $xmlrpcclient = new webservice_xmlrpc_client();
+    $result = $xmlrpcclient->call($serverurl, $registeredhub->token, $function, $params);
+
+}
+
+/////// FORM REGISTRATION ACTION //////
+
+if (!empty($fromform) and empty($update) and confirm_sesskey()) {
+
+    if (!empty($fromform) and confirm_sesskey()) { // if the register button has been clicked
+        $params = (array) $fromform; //we are using the form input as the redirection parameters (token, url and name)
+
+        if (empty($registeredhub)) {
+            //we save the token into the communication table in order to have a reference
+            $registeredhub = new stdClass();
+            $registeredhub->token = md5(uniqid(rand(),1));
+            $registeredhub->huburl = $huburl;
+            $registeredhub->hubname = $hubname;
+            $registeredhub->confirmed = 0;
+            $registeredhub->id = $hub->add_registeredhub($registeredhub);
+        }
+
+        $params['token'] = $registeredhub->token;
+        $params['url'] = $CFG->wwwroot;
+        redirect(new moodle_url(MOODLEORGHUBURL.'/local/hub/siteregistration.php', $params));
+
+    }
+}
+
+/////// OUTPUT SECTION /////////////
+
+echo $OUTPUT->header();
+//Display update notification result
+if (!empty($registeredhub->confirmed)) {
+    if (!empty($result)) {
+        echo $OUTPUT->notification(get_string('siteregistrationupdated', 'hub'), 'notifysuccess');
+    }
+}
+$siteregistrationform->display();
+
+
+
+echo $OUTPUT->footer();
\ No newline at end of file
diff --git a/admin/registration/renderer.php b/admin/registration/renderer.php
new file mode 100644 (file)
index 0000000..875f3d5
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * Registration renderer.
+ * @package   moodle
+ * @subpackage registration
+ * @copyright 2010 Moodle Pty Ltd (http://moodle.com)
+ * @author    Jerome Mouneyrac
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class core_register_renderer extends plugin_renderer_base {
+
+    /**
+     * Display a box message confirming a site registration (add or update)
+     * @param string $confirmationmessage
+     * @return string
+     */
+    public function registration_confirmation($confirmationmessage) {
+        global $OUTPUT;
+        $linktositelist = html_writer::tag('a', get_string('sitelist','hub'), array('href' => new moodle_url('/local/hub/index.php')));
+        $message = $confirmationmessage.html_writer::empty_tag('br').$linktositelist;
+        return $OUTPUT->box($message);
+    }
+
+    /**
+     * Display the page to register on Moodle.org or on a specific hub
+     */
+    public function registrationselector() {
+        global $OUTPUT;
+
+        $table = new html_table();
+        $table->head  = array(get_string('moodleorg', 'hub'), get_string('specifichub', 'hub'));
+        $table->size = array('50%', '50%');
+        //$table->attributes['class'] = 'registerindextable';
+
+        //Moodle.org information cell
+        $moodleorgcell = get_string('moodleorgregistrationdetail', 'hub');
+        $moodleorgcell .= html_writer::empty_tag('br').html_writer::empty_tag('br');
+        $moodleorgcell = html_writer::tag('div', $moodleorgcell, array('class' => 'justifytext'));
+
+        //Specific hub information cell
+        $specifichubcell = get_string('specifichubregistrationdetail', 'hub');
+        $specifichubcell .= html_writer::empty_tag('br').html_writer::empty_tag('br');
+        $specifichubcell = html_writer::tag('div', $specifichubcell, array('class' => 'justifytext'));
+
+        //add information cells
+        $cells = array($moodleorgcell, $specifichubcell);
+        $row = new html_table_row($cells);
+        $table->data[] = $row;
+
+        //Moodle.org button cell
+        $registeronmoodleorgurl = new moodle_url("/admin/registration/register.php",
+                array('sesskey' => sesskey(), 'huburl' => MOODLEORGHUBURL
+                        , 'hubname' => 'Moodle.org'));
+        $registeronmoodleorgbutton = new single_button($registeronmoodleorgurl, get_string('registeronmoodleorg', 'hub'));
+        $registeronmoodleorgbutton->class = 'centeredbutton';
+        $registeronmoodleorgbuttonhtml = $OUTPUT->render($registeronmoodleorgbutton);
+        $moodleorgcell = $registeronmoodleorgbuttonhtml;
+
+        //Specific hub button cell
+        $registeronspecifichuburl = new moodle_url("/admin/registration/hubselector.php",
+                array('sesskey' => sesskey()));
+        $registeronspecifichubbutton = new single_button($registeronspecifichuburl, get_string('registeronspecifichub', 'hub'));
+        $registeronspecifichubbutton->class = 'centeredbutton';
+        $registeronspecifichubbuttonhtml = $OUTPUT->render($registeronspecifichubbutton);
+        $specifichubcell = $registeronspecifichubbuttonhtml;
+
+        //add button cells
+        $cells = array($moodleorgcell, $specifichubcell);
+        $row = new html_table_row($cells);
+        $table->data[] = $row;
+
+        return html_writer::table($table);
+
+    }
+
+}
\ No newline at end of file
index 497d112..4fcb0c9 100644 (file)
@@ -10,11 +10,15 @@ $hassiteconfig = has_capability('moodle/site:config', $systemcontext);
 
 $ADMIN->add('root', new admin_externalpage('adminnotifications', get_string('notifications'), "$CFG->wwwroot/$CFG->admin/index.php"));
 
-// Show the annoying registration button if registration hasn't been done or is 6 months old (15552000 seconds) MDL-17429
-if (empty($CFG->registered) || ($CFG->registered < (time() - 15552000))) {
-    $ADMIN->add('root', new admin_externalpage('adminregistration', get_string('registration','admin'), "$CFG->wwwroot/$CFG->admin/register.php"));
-}
-
+$ADMIN->add('root', new admin_externalpage('registrationindex', get_string('registration','admin'),
+        "$CFG->wwwroot/$CFG->admin/registration/index.php"));
+$ADMIN->add('root', new admin_externalpage('registration', get_string('registeron','hub'),
+        "$CFG->wwwroot/$CFG->admin/registration/register.php", 'moodle/site:config', true));
+$ADMIN->add('root', new admin_externalpage('registrationselector', get_string('registeron','hub'),
+        "$CFG->wwwroot/$CFG->admin/registration/hubselector.php", 'moodle/site:config', true));
+$ADMIN->add('root', new admin_externalpage('siteregistrationconfirmed',
+        get_string('registrationconfirmed', 'hub'),
+        $CFG->wwwroot."/".$CFG->admin."/registration/confirmregistration.php", 'moodle/site:config', true));
  // hidden upgrade script
 $ADMIN->add('root', new admin_externalpage('upgradesettings', get_string('upgradesettings', 'admin'), "$CFG->wwwroot/$CFG->admin/upgradesettings.php", 'moodle/site:config', true));
 
diff --git a/blocks/community/block_community.php b/blocks/community/block_community.php
new file mode 100644 (file)
index 0000000..ae59cdf
--- /dev/null
@@ -0,0 +1,66 @@
+<?PHP
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/*
+ * @package    blocks
+ * @subpackage community
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * The community block
+*/
+
+require_once('locallib.php');
+
+class block_community extends block_list {
+    function init() {
+        $this->title = get_string('pluginname', 'block_community');
+        $this->version = 2010042701;
+    }
+
+    function get_content() {
+
+        global $CFG, $OUTPUT, $USER;
+
+        $this->content = new stdClass();
+        $this->content->items = array();
+        $this->content->icons = array();
+        $this->content->footer = '';
+
+        $this->content->items[] = '<a href='.$CFG->wwwroot.'/blocks/community/communitycourse.php?add=true>'.get_string('addcourse', 'block_community').'</a>';
+        $this->content->icons[] = '<img src="'.$OUTPUT->pix_url('i/group') . '" class="icon" alt="" />';
+
+        $community = new community();
+        $courses = $community->get_community_courses($USER->id);
+        $this->content->items[] = '';
+        $this->content->icons[] = '';
+        $this->content->items[] = get_string('mycommunities', 'block_community');
+        $this->content->icons[] = '';
+        foreach ($courses as $course) {
+            $this->content->items[] = '<a href='.$course->courseurl.'>'.$course->coursename.'</a>';
+            $this->content->icons[] = '';
+        }
+
+        return $this->content;
+    }
+
+    function applicable_formats() {
+        return array('all' => true);
+    }
+
+}
+
diff --git a/blocks/community/communitycourse.php b/blocks/community/communitycourse.php
new file mode 100644 (file)
index 0000000..51caa55
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/*
+ * @package    blocks
+ * @subpackage community
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * This page display the community course search form.
+ * It also handles adding a course to the community block.
+ * It also handles downloading a course template.
+*/
+
+require('../../config.php');
+require_once($CFG->dirroot.'/blocks/community/locallib.php');
+require_once($CFG->dirroot.'/blocks/community/forms.php');
+
+require_login();
+
+$PAGE->set_url('/blocks/community/communitycourse.php');
+$PAGE->set_heading($SITE->fullname);
+$PAGE->set_pagelayout('course');
+$PAGE->set_title(get_string('searchcourse', 'block_community'));
+$PAGE->navbar->ignore_active(true);
+$PAGE->navbar->add(get_string('searchcourse', 'block_community'));
+
+$search  = optional_param('search', '', PARAM_TEXT);
+
+$community = new community();
+
+/// Check if the page has been called with trust argument
+$add  = optional_param('add', -1, PARAM_INTEGER);
+$confirm  = optional_param('confirmed', false, PARAM_INTEGER);
+if ($add != -1 and $confirm and confirm_sesskey()) {
+    $course = new stdClass();
+    $course->name  = optional_param('coursefullname', '', PARAM_TEXT);
+    $course->description  = optional_param('coursedescription', '', PARAM_TEXT);
+    $course->url  = optional_param('courseurl', '', PARAM_URL);
+    $course->imageurl  = optional_param('courseimageurl', '', PARAM_URL);
+    $community->add_community_course($course, $USER->id);
+}
+
+/// Download
+$huburl  = optional_param('huburl', false, PARAM_URL);
+$download  = optional_param('download', -1, PARAM_INTEGER);
+$courseid  = optional_param('courseid', '', PARAM_INTEGER);
+if ($download != -1 and !empty($courseid) and confirm_sesskey()) {
+    $community->get_community_course_backup($courseid, $huburl);
+}
+
+$renderer = $PAGE->get_renderer('block_community');
+
+//forms
+$hubselectorform = new community_hub_search_form('', array('search' => $search));
+$fromform = $hubselectorform->get_data();
+
+//Retrieve courses by web service
+$courses = array();
+if (!empty($fromform)) {
+    $downloadable  = optional_param('downloadable', false, PARAM_INTEGER);
+    $function = 'hub_get_courses';
+    $params = array($search, $downloadable);
+    $serverurl = $huburl."/local/hub/webservice/webservices.php";
+    require_once($CFG->dirroot."/webservice/xmlrpc/lib.php");
+    $xmlrpcclient = new webservice_xmlrpc_client();
+    $courses = $xmlrpcclient->call($serverurl, 'publichub', $function, $params);
+}
+
+// OUTPUT
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('addcommunitycourse', 'block_community'), 3, 'main');
+$hubselectorform->display();
+echo $renderer->course_list($courses, $huburl);
+echo $OUTPUT->footer();
\ No newline at end of file
diff --git a/blocks/community/db/install.xml b/blocks/community/db/install.xml
new file mode 100644 (file)
index 0000000..9803f0a
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<XMLDB PATH="blocks/community/db" VERSION="20100428" COMMENT="XMLDB file for Moodle blocks/community"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
+>
+  <TABLES>
+    <TABLE NAME="block_community" COMMENT="Community block">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="userid"/>
+        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="coursename"/>
+        <FIELD NAME="coursename" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="userid" NEXT="coursedescription"/>
+        <FIELD NAME="coursedescription" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" PREVIOUS="coursename" NEXT="courseurl"/>
+        <FIELD NAME="courseurl" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="coursedescription" NEXT="imageurl"/>
+        <FIELD NAME="imageurl" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="courseurl"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
+      </KEYS>
+    </TABLE>
+  </TABLES>
+</XMLDB>
\ No newline at end of file
diff --git a/blocks/community/db/upgrade.php b/blocks/community/db/upgrade.php
new file mode 100644 (file)
index 0000000..942099e
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file keeps track of upgrades to the community block
+ *
+ * Sometimes, changes between versions involve alterations to database structures
+ * and other major things that may break installations.
+ *
+ * The upgrade function in this file will attempt to perform all the necessary
+ * actions to upgrade your older installtion to the current version.
+ *
+ * If there's something it cannot do itself, it will tell you what you need to do.
+ *
+ * The commands in here will all be database-neutral, using the methods of
+ * database_manager class
+ *
+ * Please do not forget to use upgrade_set_timeout()
+ * before any action that may take longer time to finish.
+ *
+ * @since 2.0
+ * @package blocks
+ * @copyright 2010 Jerome Mouneyrac
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ *
+ * @param int $oldversion
+ * @param object $block
+ */
+function xmldb_block_community_upgrade($oldversion) {
+    global $CFG, $DB;
+
+    $dbman = $DB->get_manager();
+    $result = true;
+
+    if ($result && $oldversion < 2010042701) {
+
+        /// Define table block_community to be created
+        $table = new xmldb_table('block_community');
+
+        /// Adding fields to table block_community
+        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
+        $table->add_field('coursename', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('coursedescription', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
+        $table->add_field('courseurl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('imageurl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+
+        /// Adding keys to table block_community
+        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+
+        /// Conditionally launch create table for block_community
+        if (!$dbman->table_exists($table)) {
+            $dbman->create_table($table);
+        }
+
+        /// community savepoint reached
+        upgrade_block_savepoint($result, 2010042701, 'community');
+    }
+
+
+    return $result;
+}
\ No newline at end of file
diff --git a/blocks/community/forms.php b/blocks/community/forms.php
new file mode 100644 (file)
index 0000000..db3041f
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/*
+ * @package    blocks
+ * @subpackage community
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * Form for community search
+*/
+
+require_once($CFG->dirroot.'/lib/formslib.php');
+require_once($CFG->dirroot.'/lib/hublib.php');
+
+class community_hub_search_form extends moodleform {
+
+    public function definition() {
+        global $CFG;
+        $strrequired = get_string('required');
+        $mform =& $this->_form;
+        $search = $this->_customdata['search'];
+        $mform->addElement('header', 'site', get_string('search', 'block_community'));
+
+        //retrieve the hub list on the hub directory by web service
+        $function = 'hubdirectory_get_hubs';
+        $params = array();
+        $serverurl = HUBDIRECTORYURL."/local/hubdirectory/webservice/webservices.php";
+        require_once($CFG->dirroot."/webservice/xmlrpc/lib.php");
+        $xmlrpcclient = new webservice_xmlrpc_client();
+        $hubs = $xmlrpcclient->call($serverurl, 'publichubdirectory', $function, $params);
+
+        //Public hub list
+        $options = array();
+        foreach ($hubs as $hub) {
+            //to not display a name longer than 100 character (too big)
+            if (strlen($hub['name'])>100) {
+                $hubname = substr($hub['name'],0, 100);
+                $hubname = $hubname."...";
+            } else {
+                $hubname = $hub['name'];
+            }
+            $options[$hub['url']] = $hubname;
+            $mform->addElement('hidden', clean_param($hub['url'], PARAM_ALPHANUMEXT), $hubname);
+        }
+        $mform->addElement('select', 'huburl', get_string('hub','block_community'),
+                $options, array("size" => 15));
+        $mform->addRule('huburl', $strrequired, 'required', null, 'client');
+
+        $options = array(0 => get_string('enrollable', 'block_community'),
+                1 => get_string('downloadable', 'block_community'));
+        $mform->addElement('select', 'downloadable', '',
+                $options);
+
+        $mform->addElement('text','search' , get_string('search', 'block_community'));
+
+        $this->add_action_buttons(false, get_string('search', 'block_community'));
+    }
+
+}
\ No newline at end of file
diff --git a/blocks/community/lang/en/block_community.php b/blocks/community/lang/en/block_community.php
new file mode 100644 (file)
index 0000000..7af395d
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Strings for component 'block_community', language 'en', branch 'MOODLE_20_STABLE'
+ *
+ * @package   block_community
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['addcommunitycourse'] = 'Add community course';
+$string['additionalcoursedesc'] = 'Contributors: {$a->contributornames} - Coverage: {$a->coverage} - Creator: {$a->creatorname} - Publisher: {$a->publishername} - Subject: {$a->subject}
+    - Audience: {$a->audience} - Educational level: {$a->educationallevel}';
+$string['addcourse'] = 'Search';
+$string['coursedesc'] = 'Description';
+$string['courselang'] = 'Language';
+$string['coursename'] = 'Name';
+$string['download'] = 'Download';
+$string['downloadable'] = 'Downloadable';
+$string['downloadtemplate'] = 'Create course from template';
+$string['enrollable'] = 'Enrollable';
+$string['hub'] = 'hub';
+$string['mycommunities'] = 'My communities:';
+$string['nocourse'] = 'No courses found';
+$string['operation'] = 'Operation';
+$string['pluginname'] = 'Community';
+$string['search'] = 'Search';
+$string['searchcourse'] = 'Search community course';
\ No newline at end of file
diff --git a/blocks/community/locallib.php b/blocks/community/locallib.php
new file mode 100644 (file)
index 0000000..43d22b9
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/*
+ * @package    blocks
+ * @subpackage community
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * Community library
+*/
+
+class community {
+
+///////////////////////////
+/// DB Facade functions  //
+///////////////////////////
+
+    /**
+     * Add a community course
+     * @param object $course
+     * @param integer $userid
+     */
+    public function add_community_course($course, $userid) {
+        global $DB;
+        $community->userid = $userid;
+        $community->coursename = $course->name;
+        $community->coursedescription = $course->description;
+        $community->courseurl = $course->url;
+        $community->imageurl = $course->imageurl;
+        return $DB->insert_record('block_community', $community);
+    }
+
+    /**
+     Return all community courses of a user
+     * @param integer $userid
+     * @return array of course
+     */
+    public function get_community_courses($userid) {
+        global $DB;
+        return $DB->get_records('block_community', array('userid' => $userid), 'coursename');
+    }
+
+    /**
+     *
+     * @param <type> $courseid
+     * @param <type> $huburl
+     */
+    public function get_community_course_backup($courseid, $huburl) {
+        global $CFG;
+        require_once($CFG->dirroot. "/lib/filelib.php");
+        require_once($CFG->dirroot. "/lib/hublib.php");
+        $curl = new curl();
+        $params['courseid'] = $courseid;
+        $params['filetype'] = BACKUP_FILE_TYPE;
+        $filecontent = $curl->get($huburl.'/local/hub/webservice/download.php', $params);
+    }
+
+}
\ No newline at end of file
diff --git a/blocks/community/renderer.php b/blocks/community/renderer.php
new file mode 100644 (file)
index 0000000..a54d1b4
--- /dev/null
@@ -0,0 +1,127 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/**
+ * Block community renderer.
+ * @package    blocks
+ * @subpackage community
+ * @copyright 2010 Moodle Pty Ltd (http://moodle.com)
+ * @author    Jerome Mouneyrac
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class block_community_renderer extends plugin_renderer_base {
+
+     /**
+     * Display a list of courses
+     * @param array $courses
+     * @param boolean $withwriteaccess
+     * @return string
+     */
+    public function course_list($courses, $huburl) {
+        global $OUTPUT, $CFG;
+
+        $renderedhtml = '';
+
+        $table = new html_table();
+
+
+        $table->head  = array(get_string('coursename', 'block_community'),
+                get_string('coursedesc', 'block_community'),
+                get_string('courselang', 'block_community'),
+                get_string('operation', 'block_community'));
+
+        $table->align = array('left', 'left', 'center', 'center');
+        $table->size = array('25%', '40%', '5%', '%5');
+
+
+        if (empty($courses)) {
+            $renderedhtml .= get_string('nocourse', 'block_community');
+        } else {
+
+            $table->width = '100%';
+            $table->data  = array();
+            $table->attributes['class'] = 'sitedirectory';
+
+            // iterate through sites and add to the display table
+            foreach ($courses as $course) {
+
+                if (is_array($course)) {
+                    $course = (object) $course;
+                }
+
+                //create site name with link
+                if (!empty($course->courseurl)) {
+                    $courseurl = new moodle_url($course->courseurl);
+                } else {
+                    $courseurl = new moodle_url($course->demourl);
+                }
+                $courseatag = html_writer::tag('a', $course->fullname, array('href' => $courseurl));
+
+                $coursenamehtml = html_writer::tag('span', $courseatag, array());
+
+
+                //create description to display
+                $deschtml = $course->description; //the description
+                /// courses and sites number display under the description, in smaller
+                $deschtml .= html_writer::empty_tag('br');
+                $additionaldesc = get_string('additionalcoursedesc', 'block_community', $course);
+                $deschtml .= html_writer::tag('span', $additionaldesc, array('class' => 'additionaldesc'));
+
+                //retrieve language string
+                //construct languages array
+                if (!empty($course->language)) {
+                    $languages = get_string_manager()->get_list_of_languages();
+                    $language = $languages[$course->language];
+                } else {
+                    $language= '';
+                }
+
+                if ($course->enrollable) {
+                    //Add link TODO make it a button and send by post
+                    $addurl = new moodle_url("/blocks/community/communitycourse.php",
+                            array('sesskey' => sesskey(), 'add' => 1, 'confirmed' => 1,
+                                'coursefullname' => $course->fullname, 'courseurl' => $courseurl,
+                                'coursedescription' => $course->description));
+                    $addlinkhtml = html_writer::tag('a', get_string('add'), array('href' => $addurl));
+                } else {
+                    //Add link TODO make it a button and send by post
+//                    $addurl = new moodle_url("/blocks/community/communitycourse.php",
+//                            array('sesskey' => sesskey(), 'download' => 1, 'confirmed' => 1,
+//                                'courseid' => $course->id, 'huburl' => $huburl));
+//                    $addlinkhtml = html_writer::tag('a', get_string('download', 'block_community'), array('href' => $addurl));
+                
+                    $addlinkhtml = "Download not implemented yet";
+                }
+
+                // add a row to the table
+                $cells = array($coursenamehtml, $deschtml, $language, $addlinkhtml);
+
+
+                $row = new html_table_row($cells);
+
+                $table->data[] = $row;
+            }
+            $renderedhtml .= html_writer::table($table);
+        }
+        return $renderedhtml;
+    }
+
+}
\ No newline at end of file
index 4d9b5b4..9642fd9 100644 (file)
@@ -3412,6 +3412,26 @@ function get_course_by_idnumber ($idnumber) {
     return $DB->get_record('course', array('idnumber' => $idnumber));
 }
 
+/**
+ * TODO: Average number of participants (in non-empty courses)
+ * @return integer
+ */
+function average_number_of_participants() {
+    global $DB;
+    return 0;
+    return $avg;
+}
+
+/**
+ * TODO: Average number of course modules (in non-empty courses)
+ * @return integer
+ */
+function average_number_of_courses_modules() {
+    global $DB;
+    return 0;
+    return $avg;
+}
+
 /**
  * This class pertains to course requests and contains methods associated with
  * create, approving, and removing course requests.
diff --git a/course/publish/forms.php b/course/publish/forms.php
new file mode 100644 (file)
index 0000000..126b5c2
--- /dev/null
@@ -0,0 +1,220 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/*
+ * @package    course
+ * @subpackage publish
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * The forms used for course publication
+*/
+
+
+require_once($CFG->dirroot.'/lib/formslib.php');
+require_once($CFG->dirroot."/lib/hublib.php");
+
+/*
+ * Hub selector to choose on which hub we want to publish.
+*/
+class hub_publish_selector_form extends moodleform {
+
+    public function definition() {
+        global $CFG;
+        $mform =& $this->_form;
+        $share = $this->_customdata['share'];
+
+        $mform->addElement('header', 'site', get_string('selecthub', 'hub'));
+
+        $hubmanager = new hub();
+        $registeredhubs = $hubmanager->get_registered_on_hubs();
+
+        //Public hub list
+        $options = array();
+        foreach ($registeredhubs as $hub) {
+            $options[$hub->huburl] = $hub->huburl;
+            $hubname = $hub->hubname;
+            $mform->addElement('hidden', clean_param($hub->huburl, PARAM_ALPHANUMEXT), $hubname);
+        }
+        $mform->addElement('select', 'huburl', get_string('publichub','hub'),
+                $options, array("size" => 15));
+
+        $mform->addElement('hidden', 'id', $this->_customdata['id']);
+
+        if ($share) {
+            $buttonlabel = get_string('shareonhub', 'hub');
+            $mform->addElement('hidden', 'share', true);
+        } else {
+            $buttonlabel = get_string('advertiseonhub', 'hub');
+            $mform->addElement('hidden', 'advertise', true);
+        }
+
+        $this->add_action_buttons(false, $buttonlabel);
+    }
+
+}
+
+/*
+ * Course publication form
+*/
+class course_publication_form extends moodleform {
+
+    public function definition() {
+        global $CFG, $DB, $USER;
+
+        $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'];
+        $site = get_site();
+
+        //hidden parameters
+        $mform->addElement('hidden', 'huburl', $huburl);
+        $mform->addElement('hidden', 'hubname', $hubname);
+
+        //the input parameters
+        $mform->addElement('header', 'moodle', get_string('publicationinfo', 'hub'));
+
+        $mform->addElement('text','name' , get_string('coursename', 'hub'));
+        $mform->addRule('name', $strrequired, 'required', null, 'client');
+        $mform->setType('name', PARAM_TEXT);
+        $mform->setDefault('name', $course->fullname);
+
+        $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'));
+            $mform->setType('demourl', PARAM_URL);
+            $mform->setDefault('demourl', new moodle_url("/course/view.php?id=".$course->id));
+        }
+
+        if ($advertise) {
+            $buttonlabel = get_string('advertiseon', 'hub', !empty($hubname)?$hubname:$huburl);
+            $mform->addElement('hidden', 'advertise', $advertise);
+
+            $mform->addElement('text', 'courseurl', get_string('courseurl', 'hub'));
+            $mform->setType('courseurl', PARAM_URL);
+            $mform->setDefault('courseurl', new moodle_url("/course/view.php?id=".$course->id));
+        }
+
+        $mform->addElement('text', 'courseshortname',get_string('courseshortname', 'hub'));
+        $mform->setDefault('courseshortname', $course->shortname);
+
+        $mform->addElement('textarea', 'description', get_string('description'), array('rows'=>10));
+        $mform->addRule('description', $strrequired, 'required', null, 'client');
+        $mform->setDefault('description', $course->summary);
+        $mform->setType('description', PARAM_TEXT);
+
+        $languages = get_string_manager()->get_list_of_languages();
+
+        $mform->addElement('select', 'language',get_string('language'), $languages);
+        if (empty($course->lang)) {
+            $language = get_site()->lang;
+            if (empty($language)) {
+                $mform->setDefault('language', current_language());
+            } else {
+                $mform->setDefault('language', $language);
+            }
+        } else {
+            $mform->setDefault('language', $course->lang);
+        }
+
+
+
+        $mform->addElement('text', 'publishername',get_string('publishername', 'hub'));
+        $mform->setDefault('publishername', $USER->firstname.' '.$USER->lastname);
+        $mform->addRule('publishername', $strrequired, 'required', null, 'client');
+
+        $mform->addElement('text', 'contributornames', get_string('contributornames', 'hub'));
+        $mform->setDefault('contributornames', '');
+
+        $mform->addElement('text','coverage' , get_string('tags', 'hub'));
+        $mform->setType('coverage', PARAM_TEXT);
+
+        $mform->addElement('text', 'creatorname', get_string('creatorname', 'hub'));
+        $mform->addRule('creatorname', $strrequired, 'required', null, 'client');
+        $mform->setType('creatorname', PARAM_TEXT);
+        $mform->setDefault('creatorname', $USER->firstname.' '.$USER->lastname);
+
+        require_once($CFG->dirroot."/lib/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', 'cc');
+        unset($options);
+
+        $options = get_string_manager()->load_component_strings('edufields', current_language());
+        $mform->addElement('select', 'subject', get_string('subject', 'hub'), $options);
+        unset($options);
+
+        $options = array();
+        $options[AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub');
+        $options[AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub');
+        $options[AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub');
+        $mform->addElement('select', 'audience', get_string('audience', 'hub'), $options);
+        $mform->setDefault('audience', AUDIENCE_EDUCATORS);
+        unset($options);
+
+        $options = array();
+        $options[EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'hub');
+        $options[EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'hub');
+        $options[EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'hub');
+        $options[EDULEVEL_GOVERNMENT] = get_string('edulevelgovernment', 'hub');
+        $options[EDULEVEL_ASSOCIATION] = get_string('edulevelassociation', 'hub');
+        $options[EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'hub');
+        $options[EDULEVEL_OTHER] = get_string('edulevelother', 'hub');
+        $mform->addElement('select', 'educationallevel', get_string('educationallevel', 'hub'), $options);
+        $mform->setDefault('educationallevel', EDULEVEL_TERTIARY);
+        unset($options);
+
+        $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->setDefault('creatornotes', '');
+        $mform->setType('creatornotes', PARAM_CLEANHTML);
+
+
+
+        $mform->addElement('filemanager', 'screenshots', get_string('screenshots','hub'), null,
+                array('subdirs'=>0,
+                'maxbytes'=>1000000,
+                'maxfiles'=>3,
+                'filetypes'=>array('image')
+        ));
+        $mform->setHelpButton('screenshots', array('screenshots', get_string('screenshots', 'hub'), 'hub'));
+
+        $this->add_action_buttons(false, $buttonlabel);
+    }
+
+}
+
+?>
diff --git a/course/publish/hubselector.php b/course/publish/hubselector.php
new file mode 100644 (file)
index 0000000..ddc7fef
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/*
+ * @package    course
+ * @subpackage publish
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * On this page the user selects where he wants to publish the course
+*/
+
+require('../../config.php');
+
+require_once($CFG->dirroot.'/lib/hublib.php');
+require_once($CFG->dirroot.'/course/publish/forms.php');
+
+$id = optional_param('id', 0, PARAM_INT);
+$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
+require_login($course);
+
+$PAGE->set_url('/course/publish/hubselector.php', array('id' => $course->id));
+$PAGE->set_pagelayout('course');
+$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
+$PAGE->set_heading($course->fullname);
+
+
+$share = optional_param('share', false, PARAM_BOOL);
+$advertise = optional_param('advertise', false, PARAM_BOOL);
+$hubselectorform = new hub_publish_selector_form('',
+        array('id' => $id, 'share' => $share, 'advertise' => $advertise));
+$fromform = $hubselectorform->get_data();
+
+//// Redirect to the registration form if an URL has been choosen ////
+$huburl = optional_param('huburl', false, PARAM_URL);
+
+//redirect
+if (!empty($huburl) and confirm_sesskey()) {
+    $hubname = optional_param(clean_param($huburl, PARAM_ALPHANUMEXT), '', PARAM_TEXT);
+    $params = array('sesskey' => sesskey(), 'id' => $id,
+            'huburl' => $huburl, 'hubname' => $hubname, 'share' => $share, 'advertise' => $advertise);
+    redirect(new moodle_url($CFG->wwwroot."/course/publish/metadata.php",
+            $params));
+}
+
+
+//// OUTPUT ////
+
+
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('publishon', 'hub'), 3, 'main');
+$hubselectorform->display();
+echo $OUTPUT->footer();
\ No newline at end of file
diff --git a/course/publish/index.php b/course/publish/index.php
new file mode 100644 (file)
index 0000000..4a9508e
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/*
+ * @package    course
+ * @subpackage publish
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * The user selects if he wants to publish the course on Moodle.org hub or
+ * on a specific hub. The site must be registered on a hub to be able to
+ * publish a course on it.
+*/
+
+require('../../config.php');
+require_once($CFG->dirroot.'/lib/hublib.php');
+
+$id = optional_param('id', 0, PARAM_INT);
+
+$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
+
+require_login($course);
+
+if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE, $id))) {
+
+    $PAGE->set_url('/course/publish/index.php', array('id' => $course->id));
+    $PAGE->set_pagelayout('course');
+    $PAGE->set_title(get_string('course') . ': ' . $course->fullname);
+    $PAGE->set_heading($course->fullname);
+
+
+    $renderer = $PAGE->get_renderer('core', 'publish');
+
+    echo $OUTPUT->header();
+    echo $OUTPUT->heading(get_string('publishon', 'hub'), 3, 'main');
+
+    //check if the site is registered on Moodle.org hub
+    //check if the site is registered on any other specific hub
+    $hub = new hub();
+    $registeredonmoodleorg = false;
+    $registeredonhub = false;
+
+    $hubs = $hub->get_registered_on_hubs();
+    foreach ($hubs as $hub) {
+        if ($hub->huburl == MOODLEORGHUBURL) {
+            $registeredonmoodleorg = true;
+        } else {
+            $registeredonhub = true;
+        }
+    }
+
+    echo $renderer->publicationselector($course->id, $registeredonmoodleorg, $registeredonhub);
+    echo $OUTPUT->footer();
+
+}
\ No newline at end of file
diff --git a/course/publish/metadata.php b/course/publish/metadata.php
new file mode 100644 (file)
index 0000000..2d64010
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/*
+ * @package    course
+ * @subpackage publish
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * This page display the publication metadata form
+*/
+
+require_once('../../config.php');
+require_once($CFG->dirroot.'/course/publish/forms.php');
+require_once($CFG->dirroot.'/lib/hublib.php');
+
+//check user access capability to this page
+$id = optional_param('id', 0, PARAM_INT);
+$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
+require_login($course);
+
+if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE, $id))) {
+
+    //page settings
+    $PAGE->set_url('/course/publish/metadata.php', array('id' => $course->id));
+    $PAGE->set_pagelayout('course');
+    $PAGE->set_title(get_string('course') . ': ' . $course->fullname);
+    $PAGE->set_heading($course->fullname);
+
+    //retrieve hub name and hub url
+    $huburl = optional_param('huburl', '', PARAM_URL);
+    $hubname = optional_param('hubname', '', PARAM_TEXT);
+    if (empty($huburl) or !confirm_sesskey()) {
+        throw new moodle_exception('cannotaccessthispage');
+    }
+
+    //set the publication form
+    $advertise = optional_param('advertise', false, PARAM_BOOL);
+    $share = optional_param('share', false, PARAM_BOOL);
+    $coursepublicationform = new course_publication_form( new moodle_url('/course/publish/publish.php'),
+            array('huburl' => $huburl, 'hubname' => $hubname, 'sesskey' => sesskey(),
+                    'course' => $course, 'advertise' => $advertise, 'share' => $share,
+                    'id' => $id));
+    $fromform = $coursepublicationform->get_data();
+
+
+    /////// OUTPUT SECTION /////////////
+
+    echo $OUTPUT->header();
+
+    $coursepublicationform->display();
+
+    echo $OUTPUT->footer();
+
+}
\ No newline at end of file
diff --git a/course/publish/publish.php b/course/publish/publish.php
new file mode 100644 (file)
index 0000000..897c079
--- /dev/null
@@ -0,0 +1,170 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/*
+ * @package    course
+ * @subpackage publish
+ * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
+ *
+ * This page handles the publication process.
+ * It sends metadata by web services
+ * It also sends screenshots and backup files.
+*/
+
+require_once('../../config.php');
+require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
+require_once($CFG->dirroot . '/course/publish/forms.php');
+require_once($CFG->dirroot . '/webservice/lib.php');
+require_once($CFG->dirroot . '/lib/hublib.php');
+
+//check user access capability to this page
+$id = optional_param('id', 0, PARAM_INT);
+$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
+require_login($course);
+
+if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE, $id))) {
+
+//page settings
+    $PAGE->set_url('/course/publish/publish.php', array('id' => $course->id));
+    $PAGE->set_pagelayout('course');
+    $PAGE->set_title(get_string('course') . ': ' . $course->fullname);
+    $PAGE->set_heading($course->fullname);
+
+//retrieve hub name and hub url, also check the session
+    $huburl = optional_param('huburl', '', PARAM_URL);
+    $hubname = optional_param('hubname', '', PARAM_TEXT);
+    if (empty($huburl) or !confirm_sesskey()) {
+        throw new moodle_exception('cannotaccessthispage');
+    }
+
+    $advertise = optional_param('advertise', false, PARAM_BOOL);
+    $share = optional_param('share', false, PARAM_BOOL);
+
+    $huburl = optional_param('huburl', false, PARAM_URL);
+    $hubname = optional_param('hubname', false, PARAM_TEXT);
+
+//retrieve the course information
+    $courseinfo = new stdClass();
+    $courseinfo->fullname = optional_param('name', false, PARAM_TEXT);
+    $courseinfo->shortname = optional_param('courseshortname', false, PARAM_ALPHANUMEXT);
+    $courseinfo->description = optional_param('description', false, PARAM_TEXT);
+    $courseinfo->language = optional_param('language', false, PARAM_ALPHANUMEXT);
+    $courseinfo->publishername = optional_param('publishername', false, PARAM_TEXT);
+    $courseinfo->contributornames = optional_param('contributornames', false, PARAM_TEXT);
+    $courseinfo->coverage = optional_param('coverage', false, PARAM_TEXT);
+    $courseinfo->creatorname = optional_param('creatorname', false, PARAM_TEXT);
+    $courseinfo->licenceshortname = optional_param('licence', false, PARAM_ALPHANUMEXT);
+    $courseinfo->subject = optional_param('subject', false, PARAM_INTEGER);
+    $courseinfo->audience = optional_param('audience', false, PARAM_ALPHA);
+    $courseinfo->educationallevel = optional_param('educationallevel', false, PARAM_ALPHA);
+    $creatornotes = optional_param('creatornotes', false, PARAM_RAW);
+    $courseinfo->creatornotes = $creatornotes['text'];
+    $courseinfo->creatornotesformat = $creatornotes['format'];
+    if ($share) {
+        $courseinfo->demourl = optional_param('demourl', false, PARAM_URL);
+        $courseinfo->enrollable = false;
+    } else {
+        $courseinfo->courseurl = optional_param('courseurl', false, PARAM_URL);
+        $courseinfo->enrollable = true;
+    }
+
+//save into screenshots field the references to the screenshot content hash
+//(it will be like a unique id from the hub perspective)
+    $screenshots = optional_param('screenshots', false, PARAM_INTEGER);
+    $fs = get_file_storage();
+    $files = $fs->get_area_files(get_context_instance(CONTEXT_USER, $USER->id)->id, 'user_draft', $screenshots);
+    if (!empty($files)) {
+        $courseinfo->screenshotsids = '';
+        foreach ($files as $file) {
+            if ($file->is_valid_image()) {
+                $courseinfo->screenshotsids = $courseinfo->screenshotsids . "notsend:" . $file->get_contenthash() . ";";
+            }
+        }
+    }
+
+// HEADER - needed here because the backup write some stuff
+
+    echo $OUTPUT->header();
+
+// BACKUP ACTION
+    if ($share) {
+        $bc = new backup_controller(backup::TYPE_1COURSE, $course->id, backup::FORMAT_MOODLE,
+                backup::INTERACTIVE_YES, backup::MODE_HUB, $USER->id);
+        $bc->finish_ui();
+        $bc->execute_plan();
+        $backup = $bc->get_results();
+        $backupfile = $backup['backup_destination'];
+    }
+
+// PUBLISH ACTION
+
+//retrieve the token to call the hub
+    $hub = new hub();
+    $registeredhub = $hub->get_registeredhub($huburl);
+
+//publish the course information
+    $function = 'hub_register_courses';
+    $params = array(array($courseinfo));
+    $serverurl = $huburl."/local/hub/webservice/webservices.php";
+    require_once($CFG->dirroot."/webservice/xmlrpc/lib.php");
+    $xmlrpcclient = new webservice_xmlrpc_client();
+    $result = $xmlrpcclient->call($serverurl, $registeredhub->token, $function, $params);
+
+    $courseregisteredmsg = $OUTPUT->notification(get_string('coursepublished', 'hub'), 'notifysuccess');
+
+
+// SEND FILES
+
+// send screenshots
+    require_once($CFG->dirroot. "/lib/filelib.php");
+    $params = array('token' => $registeredhub->token, 'filetype' => SCREENSHOT_FILE_TYPE,
+            'courseshortname' => $courseinfo->shortname);
+    $curl = new curl();
+    foreach ($files as $file) {
+        if ($file->is_valid_image()) {
+            $params['file'] = $file;
+            $params['filename'] = $file->get_filename();
+            $curl->post($huburl."/local/hub/webservice/upload.php", $params);
+        }
+    }
+
+
+// send backup
+    if ($share) {
+        $params['filetype'] = BACKUP_FILE_TYPE;
+        $params['file'] = $backupfile;
+        $params['filename'] = $backupfile->get_filename();
+        $curl->post($huburl."/local/hub/webservice/upload.php", $params);
+    }
+
+//TODO: Delete the backup from user_tohub
+
+// OUTPUT SECTION
+
+//Display update notification result
+    if (!empty($courseregisteredmsg)) {
+        echo $courseregisteredmsg;
+    }
+
+    echo $OUTPUT->footer();
+}
\ No newline at end of file
diff --git a/course/publish/renderer.php b/course/publish/renderer.php
new file mode 100644 (file)
index 0000000..6fc93aa
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/**
+ * Course publish renderer.
+ * @package   course
+ * @subpackage publish
+ * @copyright 2010 Moodle Pty Ltd (http://moodle.com)
+ * @author    Jerome Mouneyrac
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class core_publish_renderer extends plugin_renderer_base {
+
+    /**
+     * Display the page to publish a course on Moodle.org or on a specific hub
+     */
+    public function publicationselector($courseid, $registeredonmoodleorg, $registeredonhub) {
+        global $OUTPUT;
+
+        $table = new html_table();
+        $table->head  = array(get_string('moodleorg', 'hub'), get_string('specifichub', 'hub'));
+        $table->size = array('50%', '50%');
+
+        //Moodle.org information cell
+        $moodleorgcell = get_string('moodleorgpublicationdetail', 'hub');
+        $moodleorgcell .= html_writer::empty_tag('br').html_writer::empty_tag('br');
+        $moodleorgcell = html_writer::tag('div', $moodleorgcell, array('class' => 'justifytext'));
+
+        //Specific hub information cell
+        $specifichubcell = get_string('specifichubpublicationdetail', 'hub');
+        $specifichubcell .= html_writer::empty_tag('br').html_writer::empty_tag('br');
+        $specifichubcell = html_writer::tag('div', $specifichubcell, array('class' => 'justifytext'));
+
+        //add information cells
+        $cells = array($moodleorgcell, $specifichubcell);
+        $row = new html_table_row($cells);
+        $table->data[] = $row;
+
+        //Moodle.org button cell
+        if ($registeredonmoodleorg) {
+            $advertiseonmoodleorgurl = new moodle_url("/course/publish/metadata.php",
+                                array('sesskey' => sesskey(), 'huburl' => MOODLEORGHUBURL,  'id' => $courseid
+                                    , 'hubname' => 'Moodle.org', 'advertise' => true));
+            $advertiseonmoodleorgbutton = new single_button($advertiseonmoodleorgurl, get_string('advertiseonmoodleorg', 'hub'));
+            $advertiseonmoodleorgbutton->class = 'centeredbutton';
+            $advertiseonmoodleorgbuttonhtml = $OUTPUT->render($advertiseonmoodleorgbutton);
+
+            $shareonmoodleorgurl = new moodle_url("/course/publish/metadata.php",
+                                array('sesskey' => sesskey(), 'huburl' => MOODLEORGHUBURL,  'id' => $courseid
+                                    , 'hubname' => 'Moodle.org', 'share' => true));
+            $shareonmoodleorgbutton = new single_button($shareonmoodleorgurl, get_string('shareonmoodleorg', 'hub'));
+            $shareonmoodleorgbutton->class = 'centeredbutton';
+            $shareonmoodleorgbuttonhtml = $OUTPUT->render($shareonmoodleorgbutton);
+
+            $moodleorgcell = $advertiseonmoodleorgbuttonhtml." ".$shareonmoodleorgbuttonhtml;
+        } else {
+            $moodleorgcell = html_writer::tag('span',
+                    get_string('notregisteredonmoodleorg', 'hub') , array('class' => 'publicationwarning'));
+        }
+
+         //Specific hub button cell
+        if ($registeredonhub) {
+            $advertisespecifichuburl = new moodle_url("/course/publish/hubselector.php",
+                                array('sesskey' => sesskey(), 'id' => $courseid, 'advertise' => true));
+            $advertiseonspecifichubbutton = new single_button($advertisespecifichuburl, get_string('advertiseonspecifichub', 'hub'));
+            $advertiseonspecifichubbutton->class = 'centeredbutton';
+            $advertiseonspecifichubbuttonhtml = $OUTPUT->render($advertiseonspecifichubbutton);
+
+            $sharespecifichuburl = new moodle_url("/course/publish/hubselector.php",
+                                array('sesskey' => sesskey(), 'id' => $courseid, 'share' => true));
+            $shareonspecifichubbutton = new single_button($sharespecifichuburl, get_string('shareonspecifichub', 'hub'));
+            $shareonspecifichubbutton->class = 'centeredbutton';
+            $shareonspecifichubbuttonhtml = $OUTPUT->render($shareonspecifichubbutton);
+            $specifichubcell = $advertiseonspecifichubbuttonhtml. " " . $shareonspecifichubbuttonhtml;
+          } else {
+            $specifichubcell = html_writer::tag('span',
+                    get_string('notregisteredonhub', 'hub') , array('class' => 'publicationwarning'));
+        }
+
+        //add button cells
+        $cells = array($moodleorgcell, $specifichubcell);
+        $row = new html_table_row($cells);
+        $table->data[] = $row;
+
+        return html_writer::table($table);
+
+    }
+
+}
\ No newline at end of file
diff --git a/lang/en/edufields.php b/lang/en/edufields.php
new file mode 100644 (file)
index 0000000..d42bf4f
--- /dev/null
@@ -0,0 +1,472 @@
+<?php
+
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/**
+ *
+ * Strings describing subject classification (Codes are from ASCED 2001)
+ *
+ * @package   moodle
+ * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+$string['01']='NATURAL AND PHYSICAL SCIENCES';
+$string['0101']='MATHEMATICAL SCIENCES';
+$string['010101']='Mathematics';
+$string['010103']='Statistics';
+$string['010199']='Mathematical Sciences (other)';
+$string['0103']='PHYSICS AND ASTRONOMY';
+$string['010301']='Physics';
+$string['010303']='Astronomy';
+$string['0105']='CHEMICAL SCIENCES';
+$string['010501']='Organic Chemistry';
+$string['010503']='Inorganic Chemistry';
+$string['010599']='Chemical Sciences (other)';
+$string['0107']='EARTH SCIENCES';
+$string['010701']='Atmospheric Sciences';
+$string['010703']='Geology';
+$string['010705']='Geophysics';
+$string['010707']='Geochemistry';
+$string['010709']='Soil Science';
+$string['010711']='Hydrology';
+$string['010713']='Oceanography';
+$string['010799']='Earth Sciences (other)';
+$string['0109']='BIOLOGICAL SCIENCES';
+$string['010901']='Biochemistry and Cell Biology';
+$string['010903']='Botany';
+$string['010905']='Ecology and Evolution';
+$string['010907']='Marine Science';
+$string['010909']='Genetics';
+$string['010911']='Microbiology';
+$string['010913']='Human Biology';
+$string['010915']='Zoology';
+$string['010999']='Biological Sciences (other)';
+$string['0199']='OTHER NATURAL AND PHYSICAL SCIENCES';
+$string['019901']='Medical Science';
+$string['019903']='Forensic Science';
+$string['019905']='Food Science and Biotechnology';
+$string['019907']='Pharmacology';
+$string['019909']='Laboratory Technology';
+$string['019999']='Natural and Physical Sciences (other)';
+$string['02']='INFORMATION TECHNOLOGY';
+$string['0201']='COMPUTER SCIENCE';
+$string['020101']='Formal Language Theory';
+$string['020103']='Programming';
+$string['020105']='Computational Theory';
+$string['020107']='Compiler Construction';
+$string['020109']='Algorithms';
+$string['020111']='Data Structures';
+$string['020113']='Networks and Communications';
+$string['020115']='Computer Graphics';
+$string['020117']='Operating Systems';
+$string['020119']='Artificial Intelligence';
+$string['020199']='Computer Science (other)';
+$string['0203']='INFORMATION SYSTEMS';
+$string['020301']='Conceptual Modelling';
+$string['020303']='Database Management';
+$string['020305']='Systems Analysis and Design';
+$string['020307']='Decision Support Systems';
+$string['020399']='Information Systems (other)';
+$string['0299']='OTHER INFORMATION TECHNOLOGY';
+$string['029901']='Security Science';
+$string['029999']='Information Technology (other)';
+$string['03']='ENGINEERING AND RELATED TECHNOLOGIES';
+$string['0301']='MANUFACTURING ENGINEERING AND TECHNOLOGY';
+$string['030101']='Manufacturing Engineering';
+$string['030103']='Printing';
+$string['030105']='Textile Making';
+$string['030107']='Garment Making';
+$string['030109']='Footwear Making';
+$string['030111']='Wood Machining and Turning';
+$string['030113']='Cabinet Making';
+$string['030115']='Furniture Upholstery and Renovation';
+$string['030117']='Furniture Polishing';
+$string['030199']='Manufacturing Engineering and Technology (other)';
+$string['0303']='PROCESS AND RESOURCES ENGINEERING';
+$string['030301']='Chemical Engineering';
+$string['030303']='Mining Engineering';
+$string['030305']='Materials Engineering';
+$string['030307']='Food Processing Technology';
+$string['030399']='Process and Resources Engineering (other)';
+$string['030399']='Process and Resources Engineering (other)';
+$string['0305']='AUTOMOTIVE ENGINEERING AND TECHNOLOGY';
+$string['030501']='Automotive Engineering';
+$string['030503']='Vehicle Mechanics';
+$string['030505']='Automotive Electrics and Electronics';
+$string['030507']='Automotive Vehicle Refinishing';
+$string['030509']='Automotive Body Construction';
+$string['030511']='Panel Beating';
+$string['030513']='Upholstery and Vehicle Trimming';
+$string['030515']='Automotive Vehicle Operations';
+$string['030599']='Automotive Engineering and Technology (other)';
+$string['0307']='MECHANICAL AND INDUSTRIAL ENGINEERING AND TECHNOLOGY';
+$string['030701']='Mechanical Engineering';
+$string['030703']='Industrial Engineering';
+$string['030705']='Toolmaking';
+$string['030707']='Metal Fitting, Turning and Machining';
+$string['030709']='Sheetmetal Working';
+$string['030711']='Boilermaking and Welding';
+$string['030713']='Metal Casting and Patternmaking';
+$string['030715']='Precision Metalworking';
+$string['030717']='Plant and Machine Operations';
+$string['030799']='Mechanical and Industrial Engineering and Technology (other)';
+$string['0309']='CIVIL ENGINEERING';
+$string['030901']='Construction Engineering';
+$string['030903']='Structural Engineering';
+$string['030905']='Building Services Engineering';
+$string['030907']='Water and Sanitary Engineering';
+$string['030909']='Transport Engineering';
+$string['030911']='Geotechnical Engineering';
+$string['030913']='Ocean Engineering';
+$string['030999']='Civil Engineering (other)';
+$string['0311']='GEOMATIC ENGINEERING';
+$string['031101']='Surveying';
+$string['031103']='Mapping Science';
+$string['031199']='Geomatic Engineering (other)';
+$string['0313']='ELECTRICAL AND ELECTRONIC ENGINEERING AND TECHNOLOGY';
+$string['031301']='Electrical Engineering';
+$string['031303']='Electronic Engineering';
+$string['031305']='Computer Engineering';
+$string['031307']='Communications Technologies';
+$string['031309']='Communications Equipment Installation and Maintenance';
+$string['031311']='Powerline Installation and Maintenance';
+$string['031313']='Electrical Fitting, Electrical Mechanics';
+$string['031315']='Refrigeration and Air Conditioning Mechanics';
+$string['031317']='Electronic Equipment Servicing';
+$string['031399']='Electrical and Electronic Engineering and Technology (other)';
+$string['0315']='AEROSPACE ENGINEERING AND TECHNOLOGY';
+$string['031501']='Aerospace Engineering';
+$string['031503']='Aircraft Maintenance Engineering';
+$string['031505']='Aircraft Operation';
+$string['031507']='Air Traffic Control';
+$string['031599']='Aerospace Engineering and Technology (other)';
+$string['0317']='MARITIME ENGINEERING AND TECHNOLOGY';
+$string['031701']='Maritime Engineering';
+$string['031703']='Marine Construction';
+$string['031705']='Marine Craft Operation';
+$string['031799']='Maritime Engineering and Technology (other)';
+$string['0399']='OTHER ENGINEERING AND RELATED TECHNOLOGIES';
+$string['039901']='Environmental Engineering';
+$string['039903']='Biomedical Engineering';
+$string['039905']='Fire Technology';
+$string['039907']='Rail Operations';
+$string['039909']='Cleaning';
+$string['039999']='Engineering and Related Technologies (other)';
+$string['04']='ARCHITECTURE AND BUILDING';
+$string['0401']='ARCHITECTURE AND URBAN ENVIRONMENT';
+$string['040101']='Architecture';
+$string['040103']='Urban Design and Regional Planning';
+$string['040105']='Landscape Architecture';
+$string['040107']='Interior and Environmental Design';
+$string['040199']='Architecture and Urban Environment (other)';
+$string['0403']='BUILDING';
+$string['040301']='Building Science and Technology';
+$string['040303']='Building Construction Management';
+$string['040305']='Building Surveying';
+$string['040307']='Building Construction Economics';
+$string['040309']='Bricklaying and Stonemasonry';
+$string['040311']='Carpentry and Joinery';
+$string['040313']='Ceiling, Wall and Floor Fixing';
+$string['040315']='Roof Fixing';
+$string['040317']='Plastering';
+$string['040319']='Furnishing Installation';
+$string['040321']='Floor Coverings';
+$string['040323']='Glazing';
+$string['040325']='Painting, Decorating and Sign Writing';
+$string['040327']='Plumbing';
+$string['040329']='Scaffolding and Rigging';
+$string['040399']='Building (other)';
+$string['05']='AGRICULTURE, ENVIRONMENTAL AND RELATED STUDIES';
+$string['0501']='AGRICULTURE';
+$string['050101']='Agricultural Science';
+$string['050103']='Wool Science';
+$string['050105']='Animal Husbandry';
+$string['050199']='Agriculture (other)';
+$string['0503']='HORTICULTURE AND VITICULTURE';
+$string['050301']='Horticulture';
+$string['050303']='Viticulture';
+$string['0505']='FORESTRY STUDIES';
+$string['050501']='Forestry Studies';
+$string['0507']='FISHERIES STUDIES';
+$string['050701']='Aquaculture';
+$string['050799']='Fisheries Studies (other)';
+$string['0509']='ENVIRONMENTAL STUDIES';
+$string['050901']='Land, Parks and Wildlife Management';
+$string['050999']='Environmental Studies (other)';
+$string['0599']='OTHER AGRICULTURE, ENVIRONMENTAL AND RELATED STUDIES';
+$string['059901']='Pest and Weed Control';
+$string['059999']='Agriculture, Environmental and Related Studies (other)';
+$string['06']='HEALTH';
+$string['0601']='MEDICAL STUDIES';
+$string['060101']='General Medicine';
+$string['060103']='Surgery';
+$string['060105']='Psychiatry';
+$string['060107']='Obstetrics and Gynaecology';
+$string['060109']='Paediatrics';
+$string['060111']='Anaesthesiology';
+$string['060113']='Pathology';
+$string['060115']='Radiology';
+$string['060117']='Internal Medicine';
+$string['060119']='General Practice';
+$string['060199']='Medical Studies (other)';
+$string['0603']='NURSING';
+$string['060301']='General Nursing';
+$string['060303']='Midwifery';
+$string['060305']='Mental Health Nursing';
+$string['060307']='Community Nursing';
+$string['060309']='Critical Care Nursing';
+$string['060311']='Aged Care Nursing';
+$string['060313']='Palliative Care Nursing';
+$string['060315']='Mothercraft Nursing and Family and Child Health Nursing';
+$string['060399']='Nursing (other)';
+$string['0605']='PHARMACY';
+$string['060501']='Pharmacy';
+$string['0607']='DENTAL STUDIES';
+$string['060701']='Dentistry';
+$string['060703']='Dental Assisting';
+$string['060705']='Dental Technology';
+$string['060799']='Dental Studies (other)';
+$string['0609']='OPTICAL SCIENCE';
+$string['060901']='Optometry';
+$string['060903']='Optical Technology';
+$string['060999']='Optical Science (other)';
+$string['0611']='VETERINARY STUDIES';
+$string['061101']='Veterinary Science';
+$string['061103']='Veterinary Assisting';
+$string['061199']='Veterinary Studies (other)';
+$string['0613']='PUBLIC HEALTH';
+$string['061301']='Occupational Health and Safety';
+$string['061303']='Environmental Health';
+$string['061305']='Indigenous Health';
+$string['061307']='Health Promotion';
+$string['061309']='Community Health';
+$string['061311']='Epidemiology';
+$string['061399']='Public Health (other)';
+$string['0615']='RADIOGRAPHY';
+$string['061501']='Radiography';
+$string['0617']='REHABILITATION THERAPIES';
+$string['061701']='Physiotherapy';
+$string['061703']='Occupational Therapy';
+$string['061705']='Chiropractic and Osteopathy';
+$string['061707']='Speech Pathology';
+$string['061709']='Audiology';
+$string['061711']='Massage Therapy';
+$string['061713']='Podiatry';
+$string['061799']='Rehabilitation Therapies (other)';
+$string['0619']='COMPLEMENTARY THERAPIES';
+$string['061901']='Naturopathy';
+$string['061903']='Acupuncture';
+$string['061905']='Traditional Chinese Medicine';
+$string['061999']='Complementary Therapies (other)';
+$string['0699']='OTHER HEALTH';
+$string['069901']='Nutrition and Dietetics';
+$string['069903']='Human Movement';
+$string['069905']='Paramedical Studies';
+$string['069907']='First Aid';
+$string['069999']='Health (other)';
+$string['07']='EDUCATION';
+$string['0701']='TEACHER EDUCATION';
+$string['070101']='Teacher Education: Early Childhood';
+$string['070103']='Teacher Education: Primary';
+$string['070105']='Teacher Education: Secondary';
+$string['070107']='Teacher-Librarianship';
+$string['070109']='Teacher Education: Vocational Education and Training';
+$string['070111']='Teacher Education: Higher Education';
+$string['070113']='Teacher Education: Special Education';
+$string['070115']='English as a Second Language Teaching';
+$string['070117']='Nursing Education Teacher Training';
+$string['070199']='Teacher Education (other)';
+$string['0703']='CURRICULUM AND EDUCATION STUDIES';
+$string['070301']='Curriculum Studies';
+$string['070303']='Education Studies';
+$string['0799']='OTHER EDUCATION';
+$string['079999']='Education (other)';
+$string['08']='MANAGEMENT AND COMMERCE';
+$string['0801']='ACCOUNTING';
+$string['080101']='Accounting';
+$string['0803']='BUSINESS AND MANAGEMENT';
+$string['080301']='Business Management';
+$string['080303']='Human Resource Management';
+$string['080305']='Personal Management Training';
+$string['080307']='Organisation Management';
+$string['080309']='Industrial Relations';
+$string['080311']='International Business';
+$string['080313']='Public and Health Care Administration';
+$string['080315']='Project Management';
+$string['080317']='Quality Management';
+$string['080319']='Hospitality Management';
+$string['080321']='Farm Management and Agribusiness';
+$string['080323']='Tourism Management';
+$string['080399']='Business and Management (other)';
+$string['0805']='SALES AND MARKETING';
+$string['080501']='Sales';
+$string['080503']='Real Estate';
+$string['080505']='Marketing';
+$string['080507']='Advertising';
+$string['080509']='Public Relations';
+$string['080599']='Sales and Marketing (other)';
+$string['0807']='TOURISM';
+$string['080701']='Tourism';
+$string['0809']='OFFICE STUDIES';
+$string['080901']='Secretarial and Clerical Studies';
+$string['080903']='Keyboard Skills';
+$string['080905']='Practical Computing Skills';
+$string['080999']='Office Studies (other)';
+$string['0811']='BANKING, FINANCE AND RELATED FIELDS';
+$string['081101']='Banking and Finance';
+$string['081103']='Insurance and Actuarial Studies';
+$string['081105']='Investment and Securities';
+$string['081199']='Banking, Finance and Related Fields (other)';
+$string['0899']='OTHER MANAGEMENT AND COMMERCE';
+$string['089901']='Purchasing, Warehousing and Distribution';
+$string['089903']='Valuation';
+$string['089999']='Management and Commerce (other)';
+$string['09']='SOCIETY AND CULTURE';
+$string['0901']='POLITICAL SCIENCE AND POLICY STUDIES';
+$string['090101']='Political Science';
+$string['090103']='Policy Studies';
+$string['0903']='STUDIES IN HUMAN SOCIETY';
+$string['090301']='Sociology';
+$string['090303']='Anthropology';
+$string['090305']='History';
+$string['090307']='Archaeology';
+$string['090309']='Human Geography';
+$string['090311']='Indigenous Studies';
+$string['090313']='Gender Specific Studies';
+$string['090399']='Studies in Human Society (other)';
+$string['0905']='HUMAN WELFARE STUDIES AND SERVICES';
+$string['090501']='Social Work';
+$string['090503']='Children\'s Services';
+$string['090505']='Youth Work';
+$string['090507']='Care for the Aged';
+$string['090509']='Care for the Disabled';
+$string['090511']='Residential Client Care';
+$string['090513']='Counselling';
+$string['090515']='Welfare Studies';
+$string['090599']='Human Welfare Studies and Services (other)';
+$string['0907']='BEHAVIOURAL SCIENCE';
+$string['090701']='Psychology';
+$string['090799']='Behavioural Science (other)';
+$string['0909']='LAW';
+$string['090901']='Business and Commercial Law';
+$string['090903']='Constitutional Law';
+$string['090905']='Criminal Law';
+$string['090907']='Family Law';
+$string['090909']='International Law';
+$string['090911']='Taxation Law';
+$string['090913']='Legal Practice';
+$string['090999']='Law (other)';
+$string['0911']='JUSTICE AND LAW ENFORCEMENT';
+$string['091101']='Justice Administration';
+$string['091103']='Legal Studies';
+$string['091105']='Police Studies';
+$string['091199']='Justice and Law Enforcement (other)';
+$string['0913']='LIBRARIANSHIP, INFORMATION MANAGEMENT AND CURATORIAL STUDIES';
+$string['091301']='Librarianship and Information Management';
+$string['091303']='Curatorial Studies';
+$string['0915']='LANGUAGE AND LITERATURE';
+$string['091501']='English Language';
+$string['091503']='Northern European Languages';
+$string['091505']='Southern European Languages';
+$string['091507']='Eastern European Languages';
+$string['091509']='Southwest Asian and North African Languages';
+$string['091511']='Southern Asian Languages';
+$string['091513']='Southeast Asian Languages';
+$string['091515']='Eastern Asian Languages';
+$string['091517']='Australian Indigenous Languages';
+$string['091519']='Translating and Interpreting';
+$string['091521']='Linguistics';
+$string['091523']='Literature';
+$string['091599']='Language and Literature (other)';
+$string['0917']='PHILOSOPHY AND RELIGIOUS STUDIES';
+$string['091701']='Philosophy';
+$string['091703']='Religious Studies';
+$string['0919']='ECONOMICS AND ECONOMETRICS';
+$string['091901']='Economics';
+$string['091903']='Econometrics';
+$string['0921']='SPORT AND RECREATION';
+$string['092101']='Sport and Recreation Activities';
+$string['092103']='Sports Coaching, Officiating and Instruction';
+$string['092199']='Sport and Recreation (other)';
+$string['0999']='OTHER SOCIETY AND CULTURE';
+$string['099901']='Family and Consumer Studies';
+$string['099903']='Criminology';
+$string['099905']='Security Services';
+$string['099999']='Society and Culture (other)';
+$string['10']='CREATIVE ARTS';
+$string['1001']='PERFORMING ARTS';
+$string['100101']='Music';
+$string['100103']='Drama and Theatre Studies';
+$string['100105']='Dance';
+$string['100199']='Performing Arts (other)';
+$string['1003']='VISUAL ARTS AND CRAFTS';
+$string['100301']='Fine Arts';
+$string['100303']='Photography';
+$string['100305']='Crafts';
+$string['100307']='Jewellery Making';
+$string['100309']='Floristry';
+$string['100399']='Visual Arts and Crafts (other)';
+$string['1005']='GRAPHIC AND DESIGN STUDIES';
+$string['100501']='Graphic Arts and Design Studies';
+$string['100503']='Textile Design';
+$string['100505']='Fashion Design';
+$string['100599']='Graphic and Design Studies (other)';
+$string['1007']='COMMUNICATION AND MEDIA STUDIES';
+$string['100701']='Audio Visual Studies';
+$string['100703']='Journalism';
+$string['100705']='Written Communication';
+$string['100707']='Verbal Communication';
+$string['100799']='Communication and Media Studies (other)';
+$string['1099']='OTHER CREATIVE ARTS';
+$string['109999']='Creative Arts (other)';
+$string['11']='FOOD, HOSPITALITY AND PERSONAL SERVICES';
+$string['1101']='FOOD AND HOSPITALITY';
+$string['110101']='Hospitality';
+$string['110103']='Food and Beverage Service';
+$string['110105']='Butchery';
+$string['110107']='Baking and Pastrymaking';
+$string['110109']='Cookery';
+$string['110111']='Food Hygiene';
+$string['110199']='Food and Hospitality (other)';
+$string['1103']='PERSONAL SERVICES';
+$string['110301']='Beauty Therapy';
+$string['110303']='Hairdressing';
+$string['110399']='Personal Services (other)';
+$string['12']='MIXED FIELD PROGRAMMES';
+$string['1201']='GENERAL EDUCATION PROGRAMMES';
+$string['120101']='General Primary and Secondary Education Programmes';
+$string['120103']='Literacy and Numeracy Programmes';
+$string['120105']='Learning Skills Programmes';
+$string['120199']='General Education Programmes (other)';
+$string['1203']='SOCIAL SKILLS PROGRAMMES';
+$string['120301']='Social and Interpersonal Skills Programmes';
+$string['120303']='Survival Skills Programmes';
+$string['120305']='Parental Education Programmes';
+$string['120399']='Social Skills Programmes (other)';
+$string['1205']='EMPLOYMENT SKILLS PROGRAMMES';
+$string['120501']='Career Development Programmes';
+$string['120503']='Job Search Skills Programmes';
+$string['120505']='Work Practices Programmes';
+$string['120599']='Employment Skills Programmes (other)';
+$string['1299']='OTHER MIXED FIELD PROGRAMMES';
+$string['129999']='Mixed Field Programmes (other)';
diff --git a/lang/en/hub.php b/lang/en/hub.php
new file mode 100644 (file)
index 0000000..b5412c2
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ *
+ * Hub related strings
+ *
+ * @package   hub
+ * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['advertise'] = 'Advertise';
+$string['advertiseon'] = 'Advertise on {$a}';
+$string['advertiseonhub'] = 'Advertise on hub';
+$string['advertiseonmoodleorg'] = 'Advertise on Moodle.org';
+$string['advertiseonspecifichub'] = 'Advertise on a specific hub';
+$string['allowglobalsearch'] = 'Publish this hub and allow global search of all courses';
+$string['allowpublicsearch'] = 'Publish this hub so people can join it';
+$string['audience'] = 'Audience';
+$string['audienceeducators'] = 'Educators';
+$string['audiencestudents'] = 'Students';
+$string['audienceadmins'] = 'Administators';
+$string['badurlformat'] = 'Bad URL format';
+$string['community'] = 'Community';
+$string['confirmregistration'] = 'Confirm registration';
+$string['contactemail'] = 'Contact email';
+$string['contactname'] = 'Contact name';
+$string['contributornames'] = 'Contributor names';
+$string['coursemap'] = 'Course map';
+$string['coursename'] = 'Name';
+$string['courseprivate'] = 'Private';
+$string['coursepublic'] = 'Public';
+$string['coursepublished'] = 'Course published';
+$string['courseshortname'] = 'Shortname';
+$string['coursesnumber'] = 'Number of courses ({$a})';
+$string['courseurl'] = 'Course URL';
+$string['creatorname'] = 'Creator name';
+$string['creatornotes'] = 'Creator notes';
+$string['demourl'] = 'Demo URL';
+$string['description'] = 'Description';
+$string['downloadable'] = 'Downloadable';
+$string['educationallevel'] = 'Educational level';
+$string['edulevelassociation'] = 'Association';
+$string['edulevelcorporate'] = 'Corporate';
+$string['edulevelgovernment'] = 'Government';
+$string['edulevelother'] = 'Other';
+$string['edulevelprimary'] = 'Primary';
+$string['edulevelsecondary'] = 'Secondary';
+$string['eduleveltertiary'] = 'Tertiary';
+$string['enrollable'] = 'Enrollable';
+$string['errorbadimageheightwidth'] = 'The image should have a maximum size of {$a->width} X {$a->height}';
+$string['errorlangnotrecognized'] = 'Language code is unknown by Moodle. Please contact {$a}';
+$string['hub'] = 'Hub';
+$string['imageurl'] = 'Image url';
+$string['information'] = 'Information';
+$string['language'] = 'Language';
+$string['logourl'] = 'Logo URL';
+$string['modulenumberaverage'] = 'Average number of course modules ({$a})';
+$string['moodleorg'] = 'Moodle.org';
+$string['moodleorgpublicationdetail'] = 'Publish your course on Moodle.org. It will be found when doing a global search.';
+$string['moodleorgregistrationdetail'] = 'This option allows you to register your Moodle site with Moodle.org.  Registration is free.
+The main benefit of registering is that you will be added to a low-volume mailing list for important notifications such as security alerts and new releases of Moodle.
+By default, your information will be kept private, and will never be sold or passed on to anyone else.  The only reason for collecting this information is for support purposes, and to help build up a statistical picture of the Moodle community as a whole.
+If you choose, you can allow your site name, country and URL to be added to the public list of Moodle Sites.
+All new registrations are verified manually before they are added to the list, but once you are added you can update your registration (and your entry on the public list) at any time.';
+$string['name'] = 'Name';
+$string['no'] = 'No';
+$string['nosearch'] = 'Don\'t publish hub or courses';
+$string['notregisteredonhub'] = 'You cannot publish this course on a hub  different from Moodle.org, because this site isn\'t registered on any different hub. Contact your administrator if you want to do so.';
+$string['notregisteredonmoodleorg'] = 'You cannot publish this course on Moodle.org hub, because this site isn\'t registered on Moodle.org hub. Contact your administrator if you want to do so.';
+$string['operation'] = 'Operation';
+$string['orenterprivatehub'] = 'or enter a private hub URL:';
+$string['participantnumberaverage'] = 'Average number of participants ({$a})';
+$string['postaladdress'] = 'Postal address';
+$string['postsnumber'] = 'Number of posts ({$a})';
+$string['prioritise'] = 'Prioritise';
+$string['privacy'] = 'Privacy';
+$string['private'] = 'Private';
+$string['privatehuburl'] = 'Private hub URL';
+$string['publicationinfo'] = 'Course publication information';
+$string['publichub'] = 'Public hub';
+$string['publishcourseon'] = 'Publish on {$a}';
+$string['publishername'] = 'Publisher';
+$string['publishon'] = 'Publish on';
+$string['publishonmoodleorg'] = 'Publish on Moodle.org';
+$string['publishonspecifichub'] = 'Publish on a Hub';
+$string['questionsnumber'] = 'Number of questions ({$a})';
+$string['registeredcourses'] = 'Registered courses';
+$string['registeredsites'] = 'Registered sites';
+$string['registrationinfo'] = 'Registration information';
+$string['registersite'] = 'Register on {$a}';
+$string['registeron'] = 'Register on';
+$string['registeronmoodleorg'] = 'Register on Moodle.org';
+$string['registeronspecifichub'] = 'Register on a specific hub';
+$string['registrationconfirmed'] = 'Site registration confirmed';
+$string['registrationupdated'] = 'Registration has been updated.';
+$string['registrationupdatedfailed'] = 'Registration update failed.';
+$string['resourcesnumber'] = 'Number of resources ({$a})';
+$string['roleassignmentsnumber'] = 'Number of role assignments ({$a})';
+$string['screenshots'] = 'Screenshots';
+$string['search'] = 'Search';
+$string['selecthub'] = 'Select hub';
+$string['sendfollowinginfo'] = 'Send the following information:';
+$string['settings'] = 'Settings';
+$string['settingsupdated'] = 'Settings have been updated.';
+$string['share'] = 'Share';
+$string['shareon'] = 'Share on {$a}';
+$string['shareonhub'] = 'Share on hub';
+$string['shareonmoodleorg'] = 'Share on Moodle.org';
+$string['shareonspecifichub'] = 'Share on a specific hub';
+$string['siteadmin'] = 'Administrator';
+$string['sitecreated'] = 'Site created';
+$string['sitedesc'] = 'Description';
+$string['sitelang'] = 'Language';
+$string['sitename'] = 'Name';
+$string['siteprivacy'] = 'Privacy';
+$string['siteregconfcomment'] = 'Your site needs a final confirmation on {$a} (in order to avoid spam on {$a})';
+$string['siteregistrationupdated'] = 'Site registration updated';
+$string['siteurl'] = 'Site URL';
+$string['specifichub'] = 'Specific hub';
+$string['specifichubpublicationdetail'] = 'You can publish on another hub.';
+$string['specifichubregistrationdetail'] = 'You can register to other hub.';
+$string['statistics'] = 'Statistics privacy';
+$string['subject'] = 'Subject';
+$string['tags'] = 'Tags';
+$string['trustme'] = 'Trust';
+$string['unlistedurl'] = 'Unlisted hub URL';
+$string['unprioritise'] = 'Unprioritise';
+$string['untrustme'] = 'Untrust';
+$string['updatesite'] = 'Update registration on {$a}';
+$string['url'] = 'hub URL';
+$string['usersnumber'] = 'Number of users ({$a})';
+$string['wrongurlformat'] = 'Bad URL format';
+
index b1360d6..05dd5e9 100644 (file)
@@ -749,6 +749,7 @@ $string['gdnot'] = 'GD is not installed';
 $string['gd1'] = 'GD 1.x is installed';
 $string['gd2'] = 'GD 2.x is installed';
 $string['general'] = 'General';
+$string['geolocation'] = 'latitude - longitude';
 $string['gettheselogs'] = 'Get these logs';
 $string['go'] = 'Go';
 $string['gotoyourserver'] = '(Links back to your server)';
@@ -1077,6 +1078,7 @@ $string['modulesuccess'] = '{$a} tables have been set up correctly';
 $string['moodledocs'] = 'Moodle Docs';
 $string['moodledocslink'] = 'Moodle Docs for this page';
 $string['moodleversion'] = 'Moodle Version';
+$string['moodlerelease'] = 'Moodle Release';
 $string['more'] = 'more';
 $string['morehelp'] = 'More help';
 $string['moreinformation'] = 'More information about this error';
@@ -1340,6 +1342,7 @@ $string['publicdirectory2'] = 'Publish the site name with a link';
 $string['publicsitefileswarning'] = 'Note: files placed here can be accessed by anyone';
 $string['publicsitefileswarning2'] = 'Note: Files placed here can be accessed by anyone who knows (or can guess) the URL. For security reasons, it is recommended that any backup files are deleted immediately after restoring them.';
 $string['publicsitefileswarning3'] = 'Note: Files placed here can be accessed by anyone who knows (or can guess) the URL. <br />For security reasons, backup files should be saved in the secure backupdata folder only.';
+$string['publish'] = 'Publish';
 $string['question'] = 'Question';
 $string['questionsinthequestionbank'] = 'Questions in the question bank';
 $string['readinginfofrombackup'] = 'Reading info from backup';
@@ -1478,6 +1481,7 @@ $string['sectionusedefaultname'] = 'Use default section name';
 $string['seealsostats'] = 'See also: stats';
 $string['select'] = 'Select';
 $string['selectacountry'] = 'Select a country';
+$string['selectaregion'] = 'Select a region';
 $string['selectall'] = 'Select all';
 $string['selectamodule'] = 'Please select an activity module';
 $string['selectdefault'] = 'Select default';
index 1b496fc..17b891b 100644 (file)
@@ -5437,7 +5437,7 @@ function admin_get_root($reload=false, $requirefulltree=true) {
 
         $ADMIN->loaded = true;
     }
-
+    
     return $ADMIN;
 }
 
@@ -5851,6 +5851,7 @@ function print_plugin_tables() {
         'calendar_month',
         'calendar_upcoming',
         'comments',
+        'community',
         'course_list',
         'course_summary',
         'glossary_random',
index 8b04f2c..defcc33 100644 (file)
@@ -1537,6 +1537,16 @@ $capabilities = array(
             'editingteacher' => CAP_ALLOW,
             'manager' => CAP_ALLOW
         )
+    ),
+     'moodle/course:publish' => array(
+
+        'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'legacy' => array(
+            'manager' => CAP_ALLOW
+        )
     ),
     'moodle/course:markcomplete' => array(
         'captype' => 'write',
index 837d495..fea641e 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20100429" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20100430" COMMENT="XMLDB file for core Moodle tables"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
 >
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="license" COMMENT="store licenses used by moodle" PREVIOUS="rating" NEXT="backup_controllers">
+    <TABLE NAME="license" COMMENT="store licenses used by moodle" PREVIOUS="rating" NEXT="registration_hubs">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="shortname"/>
         <FIELD NAME="shortname" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="id" NEXT="fullname"/>
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="backup_controllers" COMMENT="To store the backup_controllers as they are used" PREVIOUS="license" NEXT="backup_ids_template">
+    <TABLE NAME="registration_hubs" COMMENT="hub where the site is registered on with their associated token" PREVIOUS="license" NEXT="backup_controllers">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="token"/>
+        <FIELD NAME="token" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="hubname"/>
+        <FIELD NAME="hubname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="token" NEXT="huburl"/>
+        <FIELD NAME="huburl" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="hubname" NEXT="confirmed"/>
+        <FIELD NAME="confirmed" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="huburl"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="backup_controllers" COMMENT="To store the backup_controllers as they are used" PREVIOUS="registration_hubs" NEXT="backup_ids_template">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="backupid"/>
         <FIELD NAME="backupid" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="unique id of the backup" PREVIOUS="id" NEXT="type"/>
       </INDEXES>
     </TABLE>
   </TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index b713bbf..0845d70 100644 (file)
@@ -2984,7 +2984,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
         upgrade_main_savepoint($result, 2010031900);
     }
 
-
+   
     if ($result && $oldversion < 2010032400) {
         // Upgrade all of those using the standardold theme to the use the standard
         // theme instead
@@ -3697,7 +3697,7 @@ AND EXISTS (SELECT 'x'
         upgrade_main_savepoint($result, 2010042802);
     }
 
-
+    
     if ($result && $oldversion < 2010043000) {  // Adding new course completion feature
 
     /// Add course completion tables
@@ -3857,6 +3857,30 @@ AND EXISTS (SELECT 'x'
         upgrade_main_savepoint($result, 2010043000);
     }
 
+    if ($result && $oldversion < 2010043001) {
+
+    /// Define table registration_hubs to be created
+        $table = new xmldb_table('registration_hubs');
+
+    /// Adding fields to table registration_hubs
+        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+        $table->add_field('token', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('hubname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('huburl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('confirmed', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+
+    /// Adding keys to table registration_hubs
+        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+
+    /// Conditionally launch create table for registration_hubs
+        if (!$dbman->table_exists($table)) {
+            $dbman->create_table($table);
+        }
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2010043001);
+    }
+
 
     return $result;
 }
diff --git a/lib/hublib.php b/lib/hublib.php
new file mode 100644 (file)
index 0000000..f609f68
--- /dev/null
@@ -0,0 +1,340 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ *
+ * Hub library
+ *
+ * @package   hub
+ * @copyright 2010 Moodle Pty Ltd (http://moodle.com)
+ * @author    Jerome Mouneyrac
+ * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+///// IMAGE SIZES /////
+
+/**
+ * SITEIMAGEHEIGHT - the maximum height size of a site logo
+ */
+define('SITEIMAGEHEIGHT',   150);
+
+/**
+ * SITEIMAGEWIDTH - the maximum width size of a site logo
+ */
+define('SITEIMAGEWIDTH',   150);
+
+
+
+///// MOODLE.ORG URLS //////
+
+/**
+ * Hub directory url (should be moodle.org)
+ */
+//define('HUBDIRECTORYURL', "http://jerome.moodle.local/Moodle_HEAD_hubdirectory/moodle");
+define('HUBDIRECTORYURL', "http://hubdirectory.moodle.org");
+
+
+/**
+ * Moodle.org url (should be moodle.org)
+ */
+//define('MOODLEORGHUBURL', "http://jerome.moodle.local/Moodle_HEAD_secure_hub/moodle");
+define('MOODLEORGHUBURL', "http://hub.moodle.org");
+
+
+
+//// SITE PRIVACY /////
+
+/**
+ * Site privacy: private
+ */
+define('SITENOTPUBLISHED', 'notdisplayed');
+
+/**
+ * Site privacy: public
+ */
+define('SITENAMEPUBLISHED', 'named');
+
+/**
+ * Site privacy: public and global
+ */
+define('SITELINKPUBLISHED', 'linked');
+
+
+
+//// Communication /////
+
+/**
+ * Hub server
+ */
+define('HUB', 'hub');
+
+/**
+ * Registered site
+ */
+define('REGISTEREDSITE', 'site');
+
+/**
+ * Public site
+ */
+define('PUBLICSITE', 'publicsite');
+
+/**
+ * Hub directory
+ */
+define('HUBDIRECTORY', 'hubdirectory');
+
+/**
+ * WS server
+ */
+define('WSSERVER', 'server');
+
+/**
+ * WS client
+ */
+define('WSCLIENT', 'client');
+
+
+
+//// AUDIENCE ////
+
+/**
+ * Audience: educators
+ */
+define('AUDIENCE_EDUCATORS', 'educators');
+
+/**
+ * Audience: students
+ */
+define('AUDIENCE_STUDENTS', 'students');
+
+/**
+ * Audience: admins
+ */
+define('AUDIENCE_ADMINS', 'admins');
+
+
+
+///// EDUCATIONAL LEVEL /////
+
+/**
+ * Educational level: primary
+ */
+define('EDULEVEL_PRIMARY', 'primary');
+
+/**
+ * Educational level: secondary
+ */
+define('EDULEVEL_SECONDARY', 'secondary');
+
+/**
+ * Educational level: tertiary
+ */
+define('EDULEVEL_TERTIARY', 'tertiary');
+
+/**
+ * Educational level: government
+ */
+define('EDULEVEL_GOVERNMENT', 'government');
+
+/**
+ * Educational level: association
+ */
+define('EDULEVEL_ASSOCIATION', 'association');
+
+/**
+ * Educational level: corporate
+ */
+define('EDULEVEL_CORPORATE', 'corporate');
+
+/**
+ * Educational level: other
+ */
+define('EDULEVEL_OTHER', 'other');
+
+
+
+///// FILE TYPES /////
+
+/**
+ * FILE TYPE: SCREENSHOTS
+ */
+define('SCREENSHOT_FILE_TYPE', 'screenshot');
+
+/**
+ * FILE TYPE: BACKUP
+ */
+define('BACKUP_FILE_TYPE', 'backup');
+
+
+
+class hub {
+
+///////////////////////////
+/// DB Facade functions  //
+///////////////////////////
+
+    public function add_registeredhub($hub) {
+        global $DB;
+        $id = $DB->insert_record('registration_hubs', $hub);
+        return $id;
+    }
+
+    public function get_registeredhub($huburl = null, $token = null) {
+        global $DB;
+
+        $params = array();
+        if (!empty($huburl)) {
+            $params['huburl'] = $huburl;
+        }
+        if (!empty($token)) {
+            $params['token'] = $token;
+        }
+        $token = $DB->get_record('registration_hubs',$params);
+        return $token;
+    }
+
+    public function update_registeredhub($communication) {
+        global $DB;
+        $DB->update_record('registration_hubs', $communication);
+    }
+
+
+///////////////////////////
+/// Library functions   ///
+///////////////////////////
+
+
+
+    /**
+     * Return site information for a specific hub
+     * @param string $huburl
+     * @return array site info
+     */
+    public function get_site_info($huburl) {
+        global $CFG, $DB;
+
+        $siteinfo = array();
+        $cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
+        $siteinfo['name'] = get_config('hub', 'site_name_'.$cleanhuburl);
+        $siteinfo['description'] = get_config('hub', 'site_description_'.$cleanhuburl);
+        $siteinfo['contactname'] = get_config('hub', 'site_contactname_'.$cleanhuburl);
+        $siteinfo['contactemail'] = get_config('hub', 'site_contactemail_'.$cleanhuburl);
+        $siteinfo['contactphone'] = get_config('hub', 'site_contactphone_'.$cleanhuburl);
+        $siteinfo['imageurl'] = get_config('hub', 'site_imageurl_'.$cleanhuburl);
+        $siteinfo['privacy'] = get_config('hub', 'site_privacy_'.$cleanhuburl);
+        $siteinfo['street'] = get_config('hub', 'site_address_'.$cleanhuburl);
+        $siteinfo['regioncode'] = get_config('hub', 'site_region_'.$cleanhuburl);
+        $siteinfo['countrycode'] = get_config('hub', 'site_country_'.$cleanhuburl);
+        $siteinfo['geolocation'] = get_config('hub', 'site_geolocation_'.$cleanhuburl);
+        $siteinfo['contactable'] = get_config('hub', 'site_contactable_'.$cleanhuburl);
+        $siteinfo['emailalert'] = get_config('hub', 'site_emailalert_'.$cleanhuburl);
+        if (get_config('hub', 'site_coursesnumber_'.$cleanhuburl) == -1) {
+            $coursecount = -1;
+        } else {
+            $coursecount = $DB->count_records('course')-1;
+        }
+        $siteinfo['courses'] = $coursecount;
+        if (get_config('hub', 'site_usersnumber_'.$cleanhuburl) == -1) {
+            $usercount = -1;
+        } else {
+            $usercount = $DB->count_records('user', array('deleted'=>0));
+        }
+        $siteinfo['users'] = $usercount;
+
+        if (get_config('hub', 'site_roleassignmentsnumber_'.$cleanhuburl) == -1) {
+            $roleassigncount = -1;
+        } else {
+            $roleassigncount = $DB->count_records('role_assignments');
+        }
+        $siteinfo['enrolments'] = $roleassigncount;
+        if (get_config('hub', 'site_postsnumber_'.$cleanhuburl) == -1) {
+            $postcount = -1;
+        } else {
+            $postcount = $DB->count_records('forum_posts');
+        }
+        $siteinfo['posts'] = $postcount;
+        if (get_config('hub', 'site_questionsnumber_'.$cleanhuburl) == -1) {
+            $questioncount = -1;
+        } else {
+            $questioncount = $DB->count_records('question');
+        }
+        $siteinfo['questions'] = $questioncount;
+        if (get_config('hub', 'site_resourcesnumber_'.$cleanhuburl) == -1) {
+            $resourcecount = -1;
+        } else {
+            $resourcecount = $DB->count_records('resource');
+        }
+        $siteinfo['resources'] = $resourcecount;
+        //TODO
+        require_once($CFG->dirroot."/course/lib.php");
+        if (get_config('hub', 'site_participantnumberaverage_'.$cleanhuburl) == -1) {
+            $participantnumberaverage = -1;
+        } else {
+            $participantnumberaverage = average_number_of_participants();
+        }
+        $siteinfo['participantnumberaverage'] = $participantnumberaverage;
+        if (get_config('hub', 'site_modulenumberaverage_'.$cleanhuburl) == -1) {
+            $modulenumberaverage = -1;
+        } else {
+            $modulenumberaverage = average_number_of_courses_modules();
+        }
+        $siteinfo['modulenumberaverage'] = $modulenumberaverage;
+        $siteinfo['language'] = current_language();
+        $siteinfo['moodleversion'] = $CFG->version;
+        $siteinfo['moodlerelease'] = $CFG->release;
+        $siteinfo['url'] = $CFG->wwwroot;
+
+        return $siteinfo;
+    }
+
+
+    /**
+     * Retrieve the site privacy string matching the define value
+     * @param string $privacy must match the define into moodlelib.php
+     * @return string
+     */
+    public function get_site_privacy_string($privacy) {
+        switch ($privacy) {
+            case SITENOTPUBLISHED:
+                $privacystring = get_string('publicdirectory0');
+                break;
+            case SITENAMEPUBLISHED:
+                $privacystring = get_string('publicdirectory1');
+                break;
+            case SITELINKPUBLISHED:
+                $privacystring = get_string('publicdirectory2');
+                break;
+        }
+        if (empty($privacystring)) {
+            throw new moodle_exception('unknownprivacy');
+        }
+        return $privacystring;
+    }
+
+
+
+    /**
+     * Return all hubs where the site is registered on
+     */
+    public function get_registered_on_hubs() {
+        global $DB;
+        $hubs = $DB->get_records('registration_hubs', array());
+        return $hubs;
+    }
+
+}
\ No newline at end of file
index cc3b2b7..5c57efd 100644 (file)
@@ -935,7 +935,7 @@ function set_config($name, $value, $plugin=NULL) {
  * @global object
  * @param string $plugin default NULL
  * @param string $name default NULL
- * @return mixed hash-like object or single value
+ * @return mixed hash-like object or single value, return false no config found
  */
 function get_config($plugin=NULL, $name=NULL) {
     global $CFG, $DB;
@@ -3449,13 +3449,13 @@ function delete_user($user) {
     require_once($CFG->libdir.'/grouplib.php');
     require_once($CFG->libdir.'/gradelib.php');
     require_once($CFG->dirroot.'/message/lib.php');
-
-    // delete all grades - backup is kept in grade_grades_history table
-    if ($grades = grade_grade::fetch_all(array('userid'=>$user->id))) {
-        foreach ($grades as $grade) {
-            $grade->delete('userdelete');
+  
+        // delete all grades - backup is kept in grade_grades_history table
+        if ($grades = grade_grade::fetch_all(array('userid'=>$user->id))) {
+            foreach ($grades as $grade) {
+                $grade->delete('userdelete');
+            }
         }
-    }
 
     //move unread messages from this user to read
     message_move_userfrom_unread2read($user->id);
@@ -6913,6 +6913,7 @@ function get_core_subsystems() {
             'debug'       => NULL,
             'dock'        => NULL,
             'editor'      => 'lib/editor',
+            'edufields'   => NULL,
             'error'       => NULL,
             'filepicker'  => NULL,
             'filters'     => NULL,
@@ -6922,6 +6923,7 @@ function get_core_subsystems() {
             'grades'      => 'grade',
             'group'       => 'group',
             'help'        => NULL,
+            'hub'         => NULL,
             'imscc'       => NULL,
             'install'     => NULL,
             'iso6392'     => NULL,
@@ -6936,8 +6938,10 @@ function get_core_subsystems() {
             'pagetype'    => NULL,
             'pix'         => NULL,
             'portfolio'   => 'portfolio',
+            'publish'     => 'course/publish',
             'question'    => 'question',
             'rating'      => 'rating',
+            'register'    => 'admin/registration',
             'repository'  => 'repository',
             'role'        => $CFG->admin.'/role',
             'simpletest'  => NULL,
@@ -9448,7 +9452,7 @@ function is_primary_admin($userid){
     }
 }
 
-/**
+ /**
  * Returns the site identifier
  *
  * @global object
index b181766..b2ce795 100644 (file)
@@ -2383,6 +2383,12 @@ class settings_navigation extends navigation_node {
             $coursenode->add(get_string('import'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/restore', ''));
         }
 
+        // Publish course on a hub
+        if (has_capability('moodle/course:publish', $coursecontext)) {
+            $url = new moodle_url('/course/publish/index.php', array('id'=>$course->id));
+            $coursenode->add(get_string('publish'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/publish', ''));
+        }
+
         // Reset this course
         if (has_capability('moodle/course:reset', $coursecontext)) {
             $url = new moodle_url('/course/reset.php', array('id'=>$course->id));
diff --git a/pix/i/publish.png b/pix/i/publish.png
new file mode 100644 (file)
index 0000000..da279c1
Binary files /dev/null and b/pix/i/publish.png differ
index d838e3b..815474a 100644 (file)
@@ -352,3 +352,28 @@ table#tag-management-list {margin: 10px auto;width: 80%;}
 .ie6.course-view li.activity {height:0;}
 .ie6 #help_icon_tooltip .yui-tt-shadow-visible {background-color: transparent;}
 
+/**
+ * Site registration
+ */
+
+ #page-admin-registration-index .centeredbutton {text-align: center}
+ #page-admin-registration-index .cell {border-width: 0 1px;}
+ #page-admin-registration-index .justifytext {text-align: justify}
+
+
+ /**
+ * Course publication
+ */
+
+ #page-course-publish-index .centeredbutton {text-align: center}
+ #page-course-publish-index .cell {border-width: 0 1px;}
+ #page-course-publish-index .justifytext {text-align: justify}
+ #page-course-publish-index .publicationwarning {color: #6666ff;}
+
+ /**
+ * Community block
+ */
+ #page-blocks-community-communitycourse .trustedtr {background-color: #ffe1c3;}
+ #page-blocks-community-communitycourse .prioritisetr {background-color: #ffd4ff;}
+ #page-blocks-community-communitycourse .additionaldesc {font-size: 80%; color: purple;}
+ #page-blocks-community-communitycourse .additionaladmindesc {font-size: 80%; color: #6666ff;}
\ No newline at end of file
index 1624632..27ce4f7 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-    $version = 2010043000;  // YYYYMMDD   = date of the last version bump
+    $version = 2010043001;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20100501)';  // Human-friendly version name
diff --git a/webservice/xmlrpc/lib.php b/webservice/xmlrpc/lib.php
new file mode 100644 (file)
index 0000000..9153b9e
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * XML-RPC client class
+ */
+class webservice_xmlrpc_client {
+    /**
+     * Execute client WS request with token authentication
+     * @param string $entrypointurl
+     * @param string $token
+     * @param string $functionname
+     * @param array $params
+     * @return mixed
+     */
+    public function call($entrypointurl, $token, $functionname, $params) {
+        global $DB, $CFG;
+
+        //zend expects 0 based array with numeric indexes
+        $params = array_values($params);
+
+        //traditional Zend xmlrpc client call (integrating the token into the URL)
+        require_once 'Zend/XmlRpc/Client.php';
+        $serverurl = $entrypointurl."?wstoken=".$token;
+        $client = new Zend_XmlRpc_Client($serverurl);
+        $result = $client->call($functionname, $params);
+
+        return $result;
+    }
+}
\ No newline at end of file