Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
paca70 authored
Showing with 46 additions and 11 deletions.
  1. +39 −9 files/index.php
  2. +7 −2 lib/moodlelib.php
View
48 files/index.php
@@ -14,14 +14,31 @@
optional_variable($wdir, "");
optional_variable($action, "");
- if (! $course = get_record("course", "id", $id) ) {
- error("That's an invalid course id");
- }
+ if (! is_numeric($id)) {
+ // editing language
+ if (! isadmin()) {
+ error ("You must be site administrator to edit translations");
+ }
+
+ //$activelangs = get_list_of_languages();
+ //if (! in_array($id, $activelangs)) {
+ // error("Selected translation is inactive. $activelangs");
+ //}
+
+ // Create "fake" course
+ $course = new object;
+ $course->id = $id;
+
+ } else {
+ if (! $course = get_record("course", "id", $id) ) {
+ error("That's an invalid course id");
+ }
- require_login($course->id);
+ require_login($course->id);
- if (! isteacheredit($course->id) ) {
- error("You need to be a teacher with editing privileges");
+ if (! isteacheredit($course->id) ) {
+ error("You need to be a teacher with editing privileges");
+ }
}
function html_footer() {
@@ -40,6 +57,8 @@ function html_header($course, $wdir, $formfield=""){
if ($course->id == $site->id) {
$strfiles = get_string("sitefiles");
+ } else if (! is_numeric($course->id)){
+ $strfiles = $course->id;
} else {
$strfiles = get_string("files");
}
@@ -76,8 +95,13 @@ function html_header($course, $wdir, $formfield=""){
echo "<tr>";
echo "<td colspan=\"2\">";
}
-
- if (! $basedir = make_upload_directory("$course->id")) {
+
+ if (is_numeric($id)) {
+ $fileroot = $CFG->dataroot ;
+ } else {
+ $fileroot = $CFG->dirroot."/lang";
+ }
+ if (! $basedir = mdl_mkdir($fileroot, "$course->id")) {
error("The site administrator needs to fix the file permissions");
}
@@ -657,9 +681,15 @@ function displaydir ($wdir) {
$fullpath = $basedir.$wdir;
+ $dontshow = array ("." , "..");
+
+ if (! is_numeric($id)) { //editing language files
+ array_push($dontshow, "CVS");
+ }
+
$directory = opendir($fullpath); // Find all files
while ($file = readdir($directory)) {
- if ($file == "." || $file == "..") {
+ if (in_array($file , $dontshow)) {
continue;
}
View
9 lib/moodlelib.php
@@ -1386,8 +1386,14 @@ function make_upload_directory($directory) {
return false;
}
}
+ $currdir = mdl_mkdir($currdir, $directory);
+ return $currdir;
+}
- $dirarray = explode("/", $directory);
+function mdl_mkdir($currdir, $directory) {
+//Makes directory (or multiple directorys at once)
+
+ $dirarray = explode("/", $directory);
foreach ($dirarray as $dir) {
$currdir = "$currdir/$dir";
@@ -1402,7 +1408,6 @@ function make_upload_directory($directory) {
return $currdir;
}
-
function make_mod_upload_directory($courseid) {
/// Makes an upload directory for a particular module
global $CFG;

0 comments on commit 94b9a1c

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