]> git.mjollnir.org Git - moodle.git/commitdiff
Change some constants to avoid name collisions. MDL-12698 ; Merged from MOODLE_19_STABLE
authorstronk7 <stronk7>
Mon, 31 Dec 2007 01:07:49 +0000 (01:07 +0000)
committerstronk7 <stronk7>
Mon, 31 Dec 2007 01:07:49 +0000 (01:07 +0000)
admin/langimport.php
install.php
lib/adminlib.php
lib/componentlib.class.php

index 4c0b084d0995271a562c5be3c2e4ebb67ed7dc50..669664ffd59c9835f8e506598c2d4d32e477e6f3 100755 (executable)
 
                 if ($cd = new component_installer('http://download.moodle.org', 'lang16',
                                                     $pack.'.zip', 'languages.md5', 'lang')) {
-                    $status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
+                    $status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
                     switch ($status) {
 
-                        case ERROR:
+                        case COMPONENT_ERROR:
                             if ($cd->get_error() == 'remotedownloaderror') {
                                 $a = new object();
                                 $a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
                             }
                         break;
 
-                        case INSTALLED:
+                        case COMPONENT_INSTALLED:
                             $notice_ok[] = get_string('langpackinstalled','admin',$pack);
                         break;
 
-                        case UPTODATE:
+                        case COMPONENT_UPTODATE:
                         break;
 
                     }
 
                 if ($cd = new component_installer('http://download.moodle.org', 'lang16',
                                        $pack.'.zip', 'languages.md5', 'lang')) {
-                $status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
+                $status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
                 switch ($status) {
 
-                    case ERROR:
+                    case COMPONENT_ERROR:
                         if ($cd->get_error() == 'remotedownloaderror') {
                             $a = new stdClass();
                             $a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
                             error(get_string($cd->get_error(), 'error')); // not probable
                         }
                     break;
-                    case UPTODATE:
+                    case COMPONENT_UPTODATE:
                         //Print error string or whatever you want to do
                     break;
-                    case INSTALLED:
+                    case COMPONENT_INSTALLED:
                         $notice_ok[] = get_string('langpackupdated', 'admin', $pack);
                         $updated = true;
                         //Print/do whatever you want
index 18e8156ee3c80d665ed3385fb60179831e1318d0..8983a827e1cf3c9dbfa8d0c0b58ead1056025520 100644 (file)
@@ -467,9 +467,9 @@ if ($INSTALL['stage'] == DOWNLOADLANG && $INSTALL['downloadlangpack']) {
 /// Download and install component
     if (($cd = new component_installer('http://download.moodle.org', 'lang16',
         $INSTALL['language'].'.zip', 'languages.md5', 'lang')) && empty($errormsg)) {
-        $status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
+        $status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
         switch ($status) {
-            case ERROR:
+            case COMPONENT_ERROR:
                 if ($cd->get_error() == 'remotedownloaderror') {
                     $a = new stdClass();
                     $a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
@@ -479,8 +479,8 @@ if ($INSTALL['stage'] == DOWNLOADLANG && $INSTALL['downloadlangpack']) {
                     $downloaderror = get_string($cd->get_error(), 'error');
                 }
             break;
-            case UPTODATE:
-            case INSTALLED:
+            case COMPONENT_UPTODATE:
+            case COMPONENT_INSTALLED:
                 $downloadsuccess = true;
             break;
             default:
index bcd2189888430dfa7d6ade630f3364a864f26660..29943d1753a7cb4963b6dca5a02428c8b33c1f84 100644 (file)
@@ -4367,9 +4367,9 @@ function upgrade_language_pack($lang='') {
     require_once($CFG->libdir.'/componentlib.class.php');
 
     if ($cd = new component_installer('http://download.moodle.org', 'lang16', $lang.'.zip', 'languages.md5', 'lang')) {
-        $status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
+        $status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
 
-        if ($status == INSTALLED) {
+        if ($status == COMPONENT_INSTALLED) {
             debugging('Downloading successful: '.$lang);
             @unlink($CFG->dataroot.'/cache/languages');
             return true;
index 1130393d6e7616a1bb882edd20dc646427706e65..a394d7786c01d63ec0e86d2e213ad4946e4d0a9f 100644 (file)
@@ -77,9 +77,9 @@
 //     require_once($CFG->libdir.'/componentlib.class.php');
 //     if ($cd = new component_installer('http://download.moodle.org', 'lang16',
 //                                       'es_utf8.zip', 'languages.md5', 'lang')) {
-//         $status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
+//         $status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
 //         switch ($status) {
-//             case ERROR:
+//             case COMPONENT_ERROR:
 //                 if ($cd->get_error() == 'remotedownloaderror') {
 //                     $a = new stdClass();
 //                     $a->url = 'http://download.moodle.org/lang16/es_utf8.zip';
 //                     error(get_string($cd->get_error(), 'error'));
 //                 }
 //                 break;
-//             case UPTODATE:
+//             case COMPONENT_UPTODATE:
 //                 //Print error string or whatever you want to do
 //                 break;
-//             case INSTALLED:
+//             case COMPONENT_INSTALLED:
 //                 //Print/do whatever you want
 //                 break;
 //             default:
 //
 // To check if current component needs to be updated
 //
-//     $status = $cd->need_upgrade();  //returns ERROR | UPTODATE | NEEDUPDATE
+//     $status = $cd->need_upgrade();  //returns COMPONENT_(ERROR | UPTODATE | NEEDUPDATE)
 //
 // To get the 3rd field of the md5 file (optional)
 //
@@ -126,10 +126,10 @@ global $CFG;
 require_once($CFG->libdir.'/filelib.php');
 
 // Some needed constants
-define('ERROR',           0);
-define('UPTODATE',        1);
-define('NEEDUPDATE',      2);
-define('INSTALLED',       3);
+define('COMPONENT_ERROR',           0);
+define('COMPONENT_UPTODATE',        1);
+define('COMPONENT_NEEDUPDATE',      2);
+define('COMPONENT_INSTALLED',       3);
 
 /**
  * This class is used to check, download and install items from
@@ -240,7 +240,7 @@ class component_installer {
      * compare md5 values, download, unzip, install and regenerate
      * local md5 file
      *
-     * @return int ERROR | UPTODATE | INSTALLED
+     * @return int COMPONENT_(ERROR | UPTODATE | INSTALLED)
      */
     function install() {
 
@@ -248,19 +248,19 @@ class component_installer {
 
     /// Check requisites are passed
         if (!$this->requisitesok) {
-            return ERROR;
+            return COMPONENT_ERROR;
         }
     /// Confirm we need upgrade
-        if ($this->need_upgrade() === ERROR) {
-            return ERROR;
-        } else if ($this->need_upgrade() === UPTODATE) {
+        if ($this->need_upgrade() === COMPONENT_ERROR) {
+            return COMPONENT_ERROR;
+        } else if ($this->need_upgrade() === COMPONENT_UPTODATE) {
             $this->errorstring='componentisuptodate';
-            return UPTODATE;
+            return COMPONENT_UPTODATE;
         }
     /// Create temp directory if necesary
         if (!make_upload_directory('temp', false)) {
              $this->errorstring='cannotcreatetempdir';
-             return ERROR;
+             return COMPONENT_ERROR;
         }
     /// Download zip file and save it to temp
         $source = $this->sourcebase.'/'.$this->zippath.'/'.$this->zipfilename;
@@ -271,26 +271,26 @@ class component_installer {
                 if (!fwrite($file, $contents)) {
                     fclose($file);
                     $this->errorstring='cannotsavezipfile';
-                    return ERROR;
+                    return COMPONENT_ERROR;
                 }
             } else {
                 $this->errorstring='cannotsavezipfile';
-                return ERROR;
+                return COMPONENT_ERROR;
             }
             fclose($file);
         } else {
             $this->errorstring='cannotdownloadzipfile';
-            return ERROR;
+            return COMPONENT_ERROR;
         }
     /// Calculate its md5
         $new_md5 = md5($contents);
     /// Compare it with the remote md5 to check if we have the correct zip file
         if (!$remote_md5 = $this->get_component_md5()) {
-            return ERROR;
+            return COMPONENT_ERROR;
         }
         if ($new_md5 != $remote_md5) {
             $this->errorstring='downloadedfilecheckfailed';
-            return ERROR;
+            return COMPONENT_ERROR;
         }
     /// Move current revision to a safe place
         $destinationdir = $CFG->dataroot.'/'.$this->destpath;
@@ -303,7 +303,7 @@ class component_installer {
             @remove_dir($destinationcomponent);
             @rename ($destinationcomponent.'_old', $destinationcomponent);
             $this->errorstring='cannotunzipfile';
-            return ERROR;
+            return COMPONENT_ERROR;
         }
     /// Delete old component version
         @remove_dir($destinationcomponent.'_old');
@@ -312,42 +312,42 @@ class component_installer {
             if (!fwrite($file, $new_md5)) {
                 fclose($file);
                 $this->errorstring='cannotsavemd5file';
-                return ERROR;
+                return COMPONENT_ERROR;
             }
         } else  {
             $this->errorstring='cannotsavemd5file';
-            return ERROR;
+            return COMPONENT_ERROR;
         }
         fclose($file);
     /// Delete temp zip file
         @unlink($zipfile);
 
-        return INSTALLED;
+        return COMPONENT_INSTALLED;
     }
 
     /**
      * This function will detect if remote component needs to be installed
      * because it's different from the local one
      *
-     * @return int ERROR | UPTODATE | NEEDUPDATE
+     * @return int COMPONENT_(ERROR | UPTODATE | NEEDUPDATE)
      */
     function need_upgrade() {
 
     /// Check requisites are passed
         if (!$this->requisitesok) {
-            return ERROR;
+            return COMPONENT_ERROR;
         }
     /// Get local md5
         $local_md5 = $this->get_local_md5();
     /// Get remote md5
         if (!$remote_md5 = $this->get_component_md5()) {
-            return ERROR;
+            return COMPONENT_ERROR;
         }
     /// Return result
        if ($local_md5 == $remote_md5) {
-           return UPTODATE;
+           return COMPONENT_UPTODATE;
        } else {
-           return NEEDUPDATE;
+           return COMPONENT_NEEDUPDATE;
        }
     }