Ignore:
Timestamp:
May 2, 2016, 12:09:23 PM (4 years ago)
Author:
jrpelegrina
Message:

Updated to moodle 3.0.3

Location:
moodle/trunk/fuentes/admin/registration
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • moodle/trunk/fuentes/admin/registration/confirmregistration.php

    r136 r1331  
    5959    echo $OUTPUT->header();
    6060    echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main');
    61     $hublink = html_writer::tag('a', $hubname, array('href' => $url));
    6261
    6362    $registeredhub->token = $newtoken;
     
    6665    $registrationmanager->update_registeredhub($registeredhub);
    6766
    68     //display notficiation message
    69     $notificationmessage = $OUTPUT->notification(
    70             get_string('registrationconfirmedon', 'hub', $hublink), 'notifysuccess');
    71     echo $notificationmessage;
     67    // Display notification message.
     68    echo $OUTPUT->notification(get_string('registrationconfirmedon', 'hub'), 'notifysuccess');
    7269
    7370    //display continue button
  • moodle/trunk/fuentes/admin/registration/index.php

    r136 r1331  
    2323 * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
    2424 *
    25  * On this page the administrator selects which hub he wants to register,
    26  * except for MOOCH. Admins can register with MOOCH with the top admin menu "Registration" link.
    27  * On this page the administrator can also unregister from any hubs, including MOOCH.
     25 * On this page the administrator selects which hub he wants to register (except for moodle.net)
     26 * Admins can register with moodle.net via the site admin menu "Registration" link.
     27 * On this page the administrator can also unregister from any hubs including moodle.net.
    2828 */
    2929
  • moodle/trunk/fuentes/admin/registration/lib.php

    r136 r1331  
    5454        global $CFG;
    5555        if (extension_loaded('xmlrpc')) {
    56             //check if the last registration cron update was less than a week ago
    57             $lastcron = get_config('registration', 'crontime');
    58             if ($lastcron === false or $lastcron < strtotime("-7 day")) { //set to a week, see MDL-23704
    59                 $function = 'hub_update_site_info';
    60                 require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
    61 
    62                 //update all hub where the site is registered on
    63                 $hubs = $this->get_registered_on_hubs();
    64                 foreach ($hubs as $hub) {
    65                     //update the registration
    66                     $siteinfo = $this->get_site_info($hub->huburl);
    67                     $params = array('siteinfo' => $siteinfo);
    68                     $serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
    69                     $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
    70                     try {
    71                         $result = $xmlrpcclient->call($function, $params);
    72                         mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
    73                     } catch (Exception $e) {
    74                         $errorparam = new stdClass();
    75                         $errorparam->errormessage = $e->getMessage();
    76                         $errorparam->hubname = $hub->hubname;
    77                         mtrace(get_string('errorcron', 'hub', $errorparam));
    78                     }
     56            $function = 'hub_update_site_info';
     57            require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
     58
     59            // Update all hubs where the site is registered.
     60            $hubs = $this->get_registered_on_hubs();
     61            if (empty($hubs)) {
     62                mtrace(get_string('registrationwarning', 'admin'));
     63            }
     64            foreach ($hubs as $hub) {
     65                // Update the registration.
     66                $siteinfo = $this->get_site_info($hub->huburl);
     67                $params = array('siteinfo' => $siteinfo);
     68                $serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
     69                $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
     70                try {
     71                    $result = $xmlrpcclient->call($function, $params);
     72                    $this->update_registeredhub($hub); // To update timemodified.
     73                    mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
     74                } catch (Exception $e) {
     75                    $errorparam = new stdClass();
     76                    $errorparam->errormessage = $e->getMessage();
     77                    $errorparam->hubname = $hub->hubname;
     78                    mtrace(get_string('errorcron', 'hub', $errorparam));
    7979                }
    80                 set_config('crontime', time(), 'registration');
    8180            }
    8281        } else {
     
    119118    public function add_registeredhub($hub) {
    120119        global $DB;
     120        $hub->timemodified = time();
    121121        $id = $DB->insert_record('registration_hubs', $hub);
    122122        return $id;
     
    172172    /**
    173173     * Update a registered hub (mostly use to update the confirmation status)
    174      * @param object $communication the hub
    175      */
    176     public function update_registeredhub($communication) {
    177         global $DB;
    178         $DB->update_record('registration_hubs', $communication);
    179     }
    180 
    181     /**
    182      * Return all hubs where the site is registered on
     174     * @param object $hub the hub
     175     */
     176    public function update_registeredhub($hub) {
     177        global $DB;
     178        $hub->timemodified = time();
     179        $DB->update_record('registration_hubs', $hub);
     180    }
     181
     182    /**
     183     * Return all hubs where the site is registered
    183184     */
    184185    public function get_registered_on_hubs() {
  • moodle/trunk/fuentes/admin/registration/register.php

    r136 r1331  
    3939require_once($CFG->dirroot . '/webservice/lib.php');
    4040require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
     41
     42require_sesskey();
    4143
    4244$huburl = required_param('huburl', PARAM_URL);
     
    117119    try {
    118120        $result = $xmlrpcclient->call($function, $params);
     121        $registrationmanager->update_registeredhub($registeredhub); // To update timemodified.
    119122    } catch (Exception $e) {
    120123        $error = $OUTPUT->notification(get_string('errorregistration', 'hub', $e->getMessage()));
     
    176179}
    177180
    178 //some Moodle.org resitration explanation
     181// Some Moodle.org registration explanation.
    179182if ($huburl == HUB_MOODLEORGHUBURL) {
     183    if (!empty($registeredhub->token)) {
     184        if ($registeredhub->timemodified == 0) {
     185            $registrationmessage = get_string('pleaserefreshregistrationunknown', 'admin');
     186        } else {
     187            $lastupdated = userdate($registeredhub->timemodified, get_string('strftimedate', 'langconfig'));
     188            $registrationmessage = get_string('pleaserefreshregistration', 'admin', $lastupdated);
     189        }
     190    } else {
     191        $registrationmessage = get_string('registrationwarning', 'admin');
     192    }
     193    echo $OUTPUT->notification($registrationmessage);
     194
    180195    echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin'));
    181196    $renderer = $PAGE->get_renderer('core', 'register');
  • moodle/trunk/fuentes/admin/registration/renderer.php

    r136 r1331  
    3232
    3333    /**
    34      * Display Moodle.org registration message about benefit to register on Moodle.org
     34     * Display message about the benefits of registering on Moodle.org
    3535     *
    3636     * @return string
    3737     */
    3838    public function moodleorg_registration_message() {
    39         $moodleorgurl = html_writer::link('http://moodle.org', 'Moodle.org');
    40         $moodleorgstatsurl = html_writer::link('http://moodle.org/stats', get_string('statsmoodleorg', 'admin'));
    41         $moochurl = html_writer::link(HUB_MOODLEORGHUBURL, get_string('moodleorghubname', 'admin'));
    42         $moodleorgregmsg = get_string('registermoodleorg', 'admin', $moodleorgurl);
     39        $moodleorgstatslink = html_writer::link('http://moodle.net/stats',
     40                                               get_string('statsmoodleorg', 'admin'),
     41                                               array('target' => '_blank'));
     42
     43        $moodleorgregmsg = get_string('registermoodleorg', 'admin');
    4344        $items = array(get_string('registermoodleorgli1', 'admin'),
    44             get_string('registermoodleorgli2', 'admin', $moodleorgstatsurl),
    45             get_string('registermoodleorgli3', 'admin', $moochurl));
     45                       get_string('registermoodleorgli2', 'admin', $moodleorgstatslink));
    4646        $moodleorgregmsg .= html_writer::alist($items);
    4747        return $moodleorgregmsg;
Note: See TracChangeset for help on using the changeset viewer.