Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

First changes for creating help-translation system.

http://site/files/index.php?fi=lang
shows now selected language "lang" files.
  • Loading branch information...
commit 94b9a1ca02a26092b305b6e78ac4c24a99d2faa7 1 parent 7279163
authored February 19, 2004
48  files/index.php
@@ -14,14 +14,31 @@
14 14
     optional_variable($wdir, "");
15 15
     optional_variable($action, "");
16 16
 
17  
-    if (! $course = get_record("course", "id", $id) ) {
18  
-        error("That's an invalid course id");
19  
-    }
  17
+    if (! is_numeric($id)) {
  18
+       	// editing language
  19
+        if (! isadmin()) {
  20
+            error ("You must be site administrator to edit translations");
  21
+        }    
  22
+        
  23
+        //$activelangs = get_list_of_languages();
  24
+        //if (! in_array($id, $activelangs)) {
  25
+        //    error("Selected translation is inactive. $activelangs");
  26
+        //}
  27
+
  28
+        // Create "fake" course 
  29
+        $course = new object;
  30
+        $course->id = $id;
  31
+        
  32
+    } else {
  33
+    	if (! $course = get_record("course", "id", $id) ) {
  34
+            error("That's an invalid course id");
  35
+    	}
20 36
 
21  
-    require_login($course->id);
  37
+        require_login($course->id);
22 38
 
23  
-    if (! isteacheredit($course->id) ) {
24  
-        error("You need to be a teacher with editing privileges");
  39
+        if (! isteacheredit($course->id) ) {
  40
+            error("You need to be a teacher with editing privileges");
  41
+        }
25 42
     }
26 43
 
27 44
     function html_footer() {
@@ -40,6 +57,8 @@ function html_header($course, $wdir, $formfield=""){
40 57
 
41 58
         if ($course->id == $site->id) {
42 59
             $strfiles = get_string("sitefiles");
  60
+        } else if (! is_numeric($course->id)){
  61
+            $strfiles = $course->id;
43 62
         } else {
44 63
             $strfiles = get_string("files");
45 64
         }
@@ -76,8 +95,13 @@ function html_header($course, $wdir, $formfield=""){
76 95
         echo "<tr>";
77 96
         echo "<td colspan=\"2\">";
78 97
     }
79  
-
80  
-    if (! $basedir = make_upload_directory("$course->id")) {
  98
+    
  99
+    if (is_numeric($id)) {
  100
+        $fileroot = $CFG->dataroot ;
  101
+    } else {
  102
+        $fileroot = $CFG->dirroot."/lang";
  103
+    }    
  104
+    if (! $basedir = mdl_mkdir($fileroot, "$course->id")) {
81 105
         error("The site administrator needs to fix the file permissions");
82 106
     }
83 107
 
@@ -657,9 +681,15 @@ function displaydir ($wdir) {
657 681
 
658 682
     $fullpath = $basedir.$wdir;
659 683
 
  684
+    $dontshow = array ("." , "..");
  685
+
  686
+    if (! is_numeric($id)) { //editing language files
  687
+        array_push($dontshow, "CVS");
  688
+    }
  689
+
660 690
     $directory = opendir($fullpath);             // Find all files
661 691
     while ($file = readdir($directory)) {
662  
-        if ($file == "." || $file == "..") {
  692
+        if (in_array($file , $dontshow)) {
663 693
             continue;
664 694
         }
665 695
         
9  lib/moodlelib.php
@@ -1386,8 +1386,14 @@ function make_upload_directory($directory) {
1386 1386
             return false;
1387 1387
         }
1388 1388
     }
  1389
+    $currdir = mdl_mkdir($currdir, $directory); 
  1390
+    return $currdir;
  1391
+}
1389 1392
 
1390  
-    $dirarray = explode("/", $directory);
  1393
+function mdl_mkdir($currdir, $directory) {
  1394
+//Makes directory (or multiple directorys at once)
  1395
+
  1396
+    $dirarray = explode("/", $directory); 
1391 1397
 
1392 1398
     foreach ($dirarray as $dir) {
1393 1399
         $currdir = "$currdir/$dir";
@@ -1402,7 +1408,6 @@ function make_upload_directory($directory) {
1402 1408
 
1403 1409
     return $currdir;
1404 1410
 }
1405  
-
1406 1411
 function make_mod_upload_directory($courseid) {
1407 1412
 /// Makes an upload directory for a particular module
1408 1413
     global $CFG;

0 notes on commit 94b9a1c

Please sign in to comment.
Something went wrong with that request. Please try again.