original_string: protected function cron_notifications(array $changes) {
          global $CFG;
  
          if (empty($changes)) {
              return array();
          }
  
          $notifications = array();
          $pluginman = \core_plugin_manager::instance();
          $plugins = $pluginman->get_plugins();
  
          foreach ($changes as $component => $componentchanges) {
              if (empty($componentchanges)) {
                  continue;
              }
              $componentupdates = $this->get_update_info($component,
                  array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
              if (empty($componentupdates)) {
                  continue;
              }
              // Notify only about those $componentchanges that are present in $componentupdates
              // to respect the preferences.
              foreach ($componentchanges as $componentchange) {
                  foreach ($componentupdates as $componentupdate) {
                      if ($componentupdate->version == $componentchange['version']) {
                          if ($component == 'core') {
                              // In case of 'core', we already know that the $componentupdate
                              // is a real update with higher version ({@see self::get_update_info()}).
                              // We just perform additional check for the release property as there
                              // can be two Moodle releases having the same version (e.g. 2.4.0 and 2.5dev shortly
                              // after the release). We can do that because we have the release info
                              // always available for the core.
                              if ((string)$componentupdate->release === (string)$componentchange['release']) {
                                  $notifications[] = $componentupdate;
                              }
                          } else {
                              // Use the core_plugin_manager to check if the detected $componentchange
                              // is a real update with higher version. That is, the $componentchange
                              // is present in the array of {@link \core\update\info} objects
                              // returned by the plugin's available_updates() method.
                              list($plugintype, $pluginname) = core_component::normalize_component($component);
                              if (!empty($plugins[$plugintype][$pluginname])) {
                                  $availableupdates = $plugins[$plugintype][$pluginname]->available_updates();
                                  if (!empty($availableupdates)) {
                                      foreach ($availableupdates as $availableupdate) {
                                          if ($availableupdate->version == $componentchange['version']) {
                                              $notifications[] = $componentupdate;
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
          }
  
          return $notifications;
      }
code: protected function cron_notifications(array $changes) {
          global $CFG;
  
          if (empty($changes)) {
              return array();
          }
  
          $notifications = array();
          $pluginman = \core_plugin_manager::instance();
          $plugins = $pluginman->get_plugins();
  
          foreach ($changes as $component => $componentchanges) {
              if (empty($componentchanges)) {
                  continue;
              }
              $componentupdates = $this->get_update_info($component,
                  array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
              if (empty($componentupdates)) {
                  continue;
              }
              // Notify only about those $componentchanges that are present in $componentupdates
              // to respect the preferences.
              foreach ($componentchanges as $componentchange) {
                  foreach ($componentupdates as $componentupdate) {
                      if ($componentupdate->version == $componentchange['version']) {
                          if ($component == 'core') {
                              // In case of 'core', we already know that the $componentupdate
                              // is a real update with higher version ({@see self::get_update_info()}).
                              // We just perform additional check for the release property as there
                              // can be two Moodle releases having the same version (e.g. 2.4.0 and 2.5dev shortly
                              // after the release). We can do that because we have the release info
                              // always available for the core.
                              if ((string)$componentupdate->release === (string)$componentchange['release']) {
                                  $notifications[] = $componentupdate;
                              }
                          } else {
                              // Use the core_plugin_manager to check if the detected $componentchange
                              // is a real update with higher version. That is, the $componentchange
                              // is present in the array of {@link \core\update\info} objects
                              // returned by the plugin's available_updates() method.
                              list($plugintype, $pluginname) = core_component::normalize_component($component);
                              if (!empty($plugins[$plugintype][$pluginname])) {
                                  $availableupdates = $plugins[$plugintype][$pluginname]->available_updates();
                                  if (!empty($availableupdates)) {
                                      foreach ($availableupdates as $availableupdate) {
                                          if ($availableupdate->version == $componentchange['version']) {
                                              $notifications[] = $componentupdate;
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
          }
  
          return $notifications;
      }
code_tokens: protected function cron_notifications ( array $ changes ) { global $ CFG ; if ( empty ( $ changes ) ) { return array ( ) ; } $ notifications = array ( ) ; $ pluginman = \ core_plugin_manager :: instance ( ) ; $ plugins = $ pluginman -> get_plugins ( ) ; foreach ( $ changes as $ component => $ componentchanges ) { if ( empty ( $ componentchanges ) ) { continue ; } $ componentupdates = $ this -> get_update_info ( $ component , array ( 'minmaturity' => $ CFG -> updateminmaturity , 'notifybuilds' => $ CFG -> updatenotifybuilds ) ) ; if ( empty ( $ componentupdates ) ) { continue ; } // Notify only about those $componentchanges that are present in $componentupdates // to respect the preferences. foreach ( $ componentchanges as $ componentchange ) { foreach ( $ componentupdates as $ componentupdate ) { if ( $ componentupdate -> version == $ componentchange [ 'version' ] ) { if ( $ component == 'core' ) { // In case of 'core', we already know that the $componentupdate // is a real update with higher version ({@see self::get_update_info()}). // We just perform additional check for the release property as there // can be two Moodle releases having the same version (e.g. 2.4.0 and 2.5dev shortly // after the release). We can do that because we have the release info // always available for the core. if ( ( string ) $ componentupdate -> release === ( string ) $ componentchange [ 'release' ] ) { $ notifications [ ] = $ componentupdate ; } } else { // Use the core_plugin_manager to check if the detected $componentchange // is a real update with higher version. That is, the $componentchange // is present in the array of {@link \core\update\info} objects // returned by the plugin's available_updates() method. list ( $ plugintype , $ pluginname ) = core_component :: normalize_component ( $ component ) ; if ( ! empty ( $ plugins [ $ plugintype ] [ $ pluginname ] ) ) { $ availableupdates = $ plugins [ $ plugintype ] [ $ pluginname ] -> available_updates ( ) ; if ( ! empty ( $ availableupdates ) ) { foreach ( $ availableupdates as $ availableupdate ) { if ( $ availableupdate -> version == $ componentchange [ 'version' ] ) { $ notifications [ ] = $ componentupdate ; } } } } } } } } } return $ notifications ; }
docstring: Given the list of changes in available updates, pick those to send to site admins
  
  @param array $changes as returned by {@link self::compare_responses()}
  @return array of \core\update\info objects to send to site admins
docstring_tokens: Given the list of changes in available updates pick those to send to site admins