Merge branch 'MDL-58694-master' of git://github.com/jleyva/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 6 Jun 2017 17:34:16 +0000 (19:34 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 6 Jun 2017 17:34:16 +0000 (19:34 +0200)
1  2 
admin/registration/forms.php

@@@ -249,6 -249,11 +249,11 @@@ class site_registration_form extends mo
          $mediancoursesize = get_config('hub', 'site_mediancoursesize_' . $cleanhuburl);
          $participantnumberaveragecfg = get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl);
          $modulenumberaveragecfg = get_config('hub', 'site_modulenumberaverage_' . $cleanhuburl);
+         // Mobile related information.
+         $mobileservicesenabled = get_config('hub', 'site_mobileservicesenabled_' . $cleanhuburl);
+         $mobilenotificacionsenabled = get_config('hub', 'site_mobilenotificacionsenabled_' . $cleanhuburl);
+         $registereduserdevices = get_config('hub', 'site_registereduserdevices_' . $cleanhuburl);
+         $registeredactiveuserdevices = get_config('hub', 'site_registeredactiveuserdevices_' . $cleanhuburl);
  
          //hidden parameters
          $mform->addElement('hidden', 'huburl', $huburl);
          require_once($CFG->libdir . '/badgeslib.php');
          $badges = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
          $issuedbadges = $DB->count_records('badge_issued');
+         // Mobile related information.
+         $ismobileenabled = false;
+         $aremobilenotificationsenabled = false;
+         $registereduserdevicescount = 0;
+         $registeredactiveuserdevicescount = 0;
+         if (!empty($CFG->enablewebservices) && !empty($CFG->enablemobilewebservice)) {
+             $ismobileenabled = true;
+             $registereduserdevicescount = $DB->count_records('user_devices');
+             $airnotifierextpath = $CFG->dirroot . '/message/output/airnotifier/externallib.php';
+             if (file_exists($airnotifierextpath)) { // Maybe some one uninstalled the plugin.
+                 require_once($airnotifierextpath);
+                 $aremobilenotificationsenabled = (bool) message_airnotifier_external::is_system_configured();
+                 $registeredactiveuserdevicescount = $DB->count_records('message_airnotifier_devices', array('enable' => 1));
+             }
+         }
  
          if (HUB_MOODLEORGHUBURL != $huburl) {
              $mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'),
              $mform->addElement('checkbox', 'badges', '',
                      " " . get_string('badgesnumber', 'hub', $badges));
              $mform->setDefault('badges', $badgesnumber != -1);
 -            $mform->setType('resources', PARAM_INT);
 +            $mform->setType('badges', PARAM_INT);
  
              $mform->addElement('checkbox', 'issuedbadges', '',
                      " " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
              $mform->setDefault('issuedbadges', $issuedbadgesnumber != -1);
 -            $mform->setType('resources', PARAM_INT);
 +            $mform->setType('issuedbadges', PARAM_INT);
  
              $mform->addElement('checkbox', 'participantnumberaverage', '',
                      " " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
                      " " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
              $mform->setDefault('modulenumberaverage', $modulenumberaveragecfg != -1);
              $mform->setType('modulenumberaverage', PARAM_FLOAT);
+             $mobileservicestatus = $ismobileenabled ? 'yes' : 'no';
+             $mform->addElement('checkbox', 'mobileservicesenabled', '',
+                     " " . get_string('mobileservicesenabled', 'hub', $mobileservicestatus));
+             $mform->setDefault('mobileservicesenabled', $mobileservicesenabled != -1);
+             $mform->setType('mobileservicesenabled', PARAM_INT);
+             $mobilenotificationsstatus = $aremobilenotificationsenabled ? 'yes' : 'no';
+             $mform->addElement('checkbox', 'mobilenotificacionsenabled', '',
+                     " " . get_string('mobilenotificacionsenabled', 'hub', $mobilenotificationsstatus));
+             $mform->setDefault('mobilenotificacionsenabled', $mobilenotificacionsenabled != -1);
+             $mform->setType('mobilenotificacionsenabled', PARAM_INT);
+             $mform->addElement('checkbox', 'registereduserdevices', '',
+                     " " . get_string('registereduserdevices', 'hub', $registereduserdevicescount));
+             $mform->setDefault('registereduserdevices', $registereduserdevices != -1);
+             $mform->setType('registereduserdevices', PARAM_INT);
+             $mform->addElement('checkbox', 'registeredactiveuserdevices', '',
+                     " " . get_string('registeredactiveuserdevices', 'hub', $registeredactiveuserdevicescount));
+             $mform->setDefault('registeredactiveuserdevices', $registeredactiveuserdevices != -1);
+             $mform->setType('registeredactiveuserdevices', PARAM_INT);
          } else {
              $mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'),
                      " " . get_string('coursesnumber', 'hub', $coursecount));
                      " " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
              $mform->addElement('hidden', 'modulenumberaverage', 1);
              $mform->setType('modulenumberaverage', PARAM_FLOAT);
+             $mobileservicestatus = $ismobileenabled ? 'yes' : 'no';
+             $mform->addElement('static', 'mobileservicesenabledlabel', '',
+                     " " . get_string('mobileservicesenabled', 'hub', $mobileservicestatus));
+             $mform->addElement('hidden', 'mobileservicesenabled', 1);
+             $mform->setType('mobileservicesenabled', PARAM_INT);
+             $mobilenotificationsstatus = $aremobilenotificationsenabled ? 'yes' : 'no';
+             $mform->addElement('static', 'mobilenotificacionsenabledlabel', '',
+                     " " . get_string('mobilenotificacionsenabled', 'hub', $mobilenotificationsstatus));
+             $mform->addElement('hidden', 'mobilenotificacionsenabled', 1);
+             $mform->setType('mobilenotificacionsenabled', PARAM_INT);
+             $mform->addElement('static', 'registereduserdeviceslabel', '',
+                     " " . get_string('registereduserdevices', 'hub', $registereduserdevicescount));
+             $mform->addElement('hidden', 'registereduserdevices', 1);
+             $mform->setType('registereduserdevices', PARAM_INT);
+             $mform->addElement('static', 'registeredactiveuserdeviceslabel', '',
+                     " " . get_string('registeredactiveuserdevices', 'hub', $registeredactiveuserdevicescount));
+             $mform->addElement('hidden', 'registeredactiveuserdevices', 1);
+             $mform->setType('registeredactiveuserdevices', PARAM_INT);
          }
  
          //check if it's a first registration or update