Пример #1
0
 /**
  * Calculate unique version hash for all plugins and core.
  * @static
  * @return string sha1 hash
  */
 public static function get_version_hash()
 {
     global $CFG;
     if (self::$versionhash) {
         return self::$versionhash;
     }
     $versions = array();
     // main version first
     $version = null;
     include $CFG->dirroot . '/version.php';
     $versions['core'] = $version;
     // modules
     $mods = get_plugin_list('mod');
     ksort($mods);
     foreach ($mods as $mod => $fullmod) {
         $module = new stdClass();
         $module->version = null;
         include $fullmod . '/version.php';
         $versions[$mod] = $module->version;
     }
     // now the rest of plugins
     $plugintypes = get_plugin_types();
     unset($plugintypes['mod']);
     ksort($plugintypes);
     foreach ($plugintypes as $type => $unused) {
         $plugs = get_plugin_list($type);
         ksort($plugs);
         foreach ($plugs as $plug => $fullplug) {
             $plugin = new stdClass();
             $plugin->version = null;
             @(include $fullplug . '/version.php');
             $versions[$plug] = $plugin->version;
         }
     }
     self::$versionhash = sha1(serialize($versions));
     return self::$versionhash;
 }