]> git.mjollnir.org Git - moodle.git/commitdiff
Further excellent tidy-ups to the admin pages. They are actually starting
authormartin <martin>
Thu, 8 Aug 2002 15:51:23 +0000 (15:51 +0000)
committermartin <martin>
Thu, 8 Aug 2002 15:51:23 +0000 (15:51 +0000)
to look/work as slick as the rest of the site.  :-)

admin/site.php
admin/user.php
course/delete.php
course/edit.php
course/lib.php
course/teacher.php
index.php
lang/en/moodle.php
user/edit.php

index f634b9c13b1e576d2a57ecbe891ba126eebb8db1..9b0d0661ebb86cb74b98513cc88c9245fabf1a16 100644 (file)
         $form->newsitems = 0;
     }
 
-    print_header("Admin: Setting up site", "Administration: Setting up site",
-                  "<A HREF=\"$CFG->wwwroot/admin/\">Admin</A> -> Setting up site", "$focus");
+    $stradmin = get_string("administration");
+    $strsitesettings = get_string("sitesettings");
+
+    print_header("$site->fullname", "$site->fullname",
+                  "<A HREF=\"$CFG->wwwroot/admin/\">$stradmin</A> -> $strsitesettings", "$focus");
 
     print_simple_box_start("center", "", "$THEME->cellheading");
     print_heading("Editing site settings");
index 26395f7f87267fbaf01ba8fe33165a5afbbee671..ab894c47ff7e0d0347cdfa800e2c42ed71fc0ee7 100644 (file)
@@ -4,8 +4,6 @@
        require("../user/lib.php");
     require("../lib/countries.php");
 
-    optional_variable($id);       // user id
-
     if (! record_exists_sql("SELECT * FROM user_admins")) {
         $user->firstname = "Admin";
         $user->lastname  = "User";
             error("User ID was incorrect (can't find it)");
         }
 
-        if (! $course = get_site()) {
+        if (! $site = get_site()) {
             error("Could not find site-level course");
         }
 
         $teacher->user = $user->id;
-        $teacher->course = $course->id;
+        $teacher->course = $site->id;
         $teacher->authority = 1;
         if (! insert_record("user_teachers", $teacher)) {
             error("Could not make user $id a teacher of site-level course !!!");
         $USER = $user;
         $USER->loggedin = true;
         $USER->admin = true;
-        $USER->teacher["$course->id"] = true;
+        $USER->teacher["$site->id"] = true;
         save_session("USER");
 
-        $id = $user->id;
+        redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id");
 
     } else {
-        if (! $course = get_site()) {
+        if (! $site = get_site()) {
             error("Could not find site-level course");
         }
     }
 
     if ($newuser) {                 // Create a new user
 
-        $user->firstname = "New";
-        $user->lastname  = "User";
-        $user->username  = "username";
+        $user->firstname = "";
+        $user->lastname  = "";
+        $user->username  = "changeme";
         $user->password  = "";
         $user->email     = "";
         $user->confirmed = 1;
         $user->timemodified = time();
 
         if (! $user->id = insert_record("user", $user)) {
-            error("Could not create new user record !!!");
+            if (!$user = get_record("user", "username", "changeme")) {   // half finished user from another time
+                error("Could not start a new user!");
+            }
         }
 
-        redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$course->id");
+        redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id");
         
+    } else {                        // List all users for editing
 
-    } else if ($id) {               // Edit a particular user 
+        if ($users = get_records_sql("SELECT * from user WHERE username <> 'guest' ORDER BY firstname")) {
+            $stredituser = get_string("edituser");
+            $stradministration = get_string("administration");
+            $stredit   = get_string("edit");
+            $strdelete = get_string("delete");
 
-        if (! $user = get_record("user", "id", $id)) {
-            error("User ID was incorrect (can't find it)");
-        }
-    
-        redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$course->id");
+               print_header("$site->fullname : $stredituser", $site->fullname, 
+                         "<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> $stredituser");
 
-        
-    } else {                        // List all users for editing
+            print_heading(get_string("chooseuser"));
 
-        if ($users = get_records_sql("SELECT * from user WHERE username <> 'guest' ORDER BY firstname")) {
-               print_header("Edit users", "Edit users", "<A HREF=\"$CFG->wwwroot/admin\">Admin</A> -> Edit users", "");
-            print_heading("Choose a user to edit");
-            $table->head  = array ("Name", "Email", "City/Town", "Country");
-            $table->align = array ("LEFT", "LEFT", "CENTER", "CENTER");
+            $table->head  = array (get_string("fullname"), get_string("email"), get_string("city"), 
+                                   get_string("country"), " ");
+            $table->align = array ("LEFT", "LEFT", "CENTER", "CENTER", "CENTER", "CENTER");
             foreach ($users as $user) {
-                $table->data[] = array ("<A HREF=\"user.php?id=$user->id\">$user->firstname $user->lastname</A>",
+                $table->data[] = array ("<A HREF=\"../user/edit.php?id=$user->id&course=$site->id\">$user->firstname $user->lastname</A>",
                                         "$user->email",
                                         "$user->city",
-                                        $COUNTRIES[$user->country]);
+                                        $COUNTRIES[$user->country],
+                                        "<A HREF=\"../user/edit.php?id=$user->id&course=$site->id\">$stredit</A>");
             }
             print_table($table);
         } else {
index e3ed763f9899515476759b17bc5fe74467d02e0e..6eed9b9107c73c3939352d6b5c7b2bde7c9ea179 100644 (file)
         error("You must be an administrator to use this page.");
     }
 
-    $stradmin = get_string("admin");
+    if (!$site = get_site()) {
+        error("Site not found!");
+    }
+
+    $strdeletecourse = get_string("deletecourse");
+    $stradministration = get_string("administration");
 
     if (!$id) {
-        $strdelete = get_string("deletecourse");
-           print_header($strdelete, $strdelete, "<A HREF=\"$CFG->wwwroot/admin\">$stradmin</A> -> $strdelete");
+           print_header("$site->fullname : $strdeletecourse", $site->fullname, 
+                     "<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> $strdeletecourse");
+
         if ($courses = get_records_sql("SELECT * from course WHERE category > 0 ORDER BY fullname")) {
             print_heading(get_string("choosecourse"));
             print_simple_box_start("CENTER");
     if (! $delete) {
         $strdeletecheck = get_string("deletecheck", "", $course->shortname);
         $strdeletecheckfull = get_string("deletecheckfull");
-           print_header($strdeletecheck, $strdeletecheck, 
-                     "<A HREF=\"$CFG->wwwroot/admin\">$stradmin</A> -> $strdeletecheck");
+           print_header("$site->fullname : $strdeletecheck", $site->fullname, 
+                     "<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> 
+                      <A HREF=\"delete.php\">$strdeletecourse</A> -> $strdeletecheck");
+
         notice_yesno("$strdeletecheckfull<BR><BR>$course->fullname", 
                      "delete.php?id=$course->id&delete=".md5($course->timemodified), 
                      "delete.php");
     }
 
     // OK checks done, delete the course now.
-    $strdeletingcheck = get_string("deletingcheck", "", $course->shortname);
-       print_header($strdeletingcheck, $strdeletingcheck, 
-                 "<A HREF=\"$CFG->wwwroot/admin\">$stradmin</A> -> $strdeletingcheck");
-    print_heading($strdeletingcheck);
+    $strdeletingcourse = get_string("deletingcourse", "", $course->shortname);
+
+       print_header("$site->fullname : $strdeletingcourse", $site->fullname, 
+                 "<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> 
+                  <A HREF=\"delete.php\">$strdeletecourse</A> -> $strdeletingcourse");
+
+    print_heading($strdeletingcourse);
 
     $strdeleted = get_string("deleted");
     // First delete every instance of every module
index b75e4b28eea105bbadc35757fa01c1dff8750964..e9b375899fed266954e367a202f264981d8043ec 100644 (file)
         if (!isadmin()) {
             error("Only administrators can use this page");
         }
+    }
 
-        if (! $site = get_site()) {
-            redirect("$CFG->wwwroot/admin/");
-        }
+    if (! $site = get_site()) {
+        redirect("$CFG->wwwroot/admin/");
     }
 
 
     $form->categories = get_records_sql_menu("SELECT id,name FROM course_categories");
 
     $streditcoursesettings = get_string("editcoursesettings");
-    $streditcoursesettings = get_string("editcoursesettings");
+    $straddnewcourse = get_string("addnewcourse");
+    $stradministration = get_string("administration");
 
     if (isset($course)) {
            print_header($streditcoursesettings, "$course->fullname", 
                      "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> 
                       -> $streditcoursesettings", $focus);
     } else {
-        print_header(get_string("addnewcourse"), get_string("addnewcourse"),
-                     "<A HREF=\"$CFG->wwwroot/admin/\">".get_string("admin")."</A> 
-                      -> ".get_string("addnewcourse"), $focus);
+        print_header("$site->shortname : $straddnewcourse", "$site->fullname",
+                     "<A HREF=\"$CFG->wwwroot/admin/\">$stradministration</A> 
+                      -> $straddnewcourse", $focus);
     }
 
     print_simple_box_start("center", "", "$THEME->cellheading");
index e83900af5709350cc6b1c4e67a015373aed4b75b..c409b2fc2cbed4ec60161bf97d47561cd6d586db 100644 (file)
@@ -496,6 +496,31 @@ function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
     echo "</TABLE><BR>\n\n";
 }
 
+function print_admin_links () {
+    global $THEME, $CFG;
+    
+    print_simple_box(get_string("administration"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
+    $icon = "<IMG SRC=\"$CFG->wwwroot/pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
+    $moddata[]="<A HREF=\"$CFG->wwwroot/course/log.php?id=$site->id\">".get_string("sitelogs")."</A>";
+    $modicon[]=$icon;
+    $moddata[]="<A HREF=\"$CFG->wwwroot/admin/site.php\">".get_string("sitesettings")."</A>";
+    $modicon[]=$icon;
+    $moddata[]="<A HREF=\"$CFG->wwwroot/course/edit.php\">".get_string("addnewcourse")."</A>";
+    $modicon[]=$icon;
+    $moddata[]="<A HREF=\"$CFG->wwwroot/course/teacher.php\">".get_string("assignteachers")."</A>";
+    $modicon[]=$icon;
+    $moddata[]="<A HREF=\"$CFG->wwwroot/course/delete.php\">".get_string("deletecourse")."</A>";
+    $modicon[]=$icon;
+    $moddata[]="<A HREF=\"$CFG->wwwroot/admin/user.php?newuser=true\">".get_string("addnewuser")."</A>";
+    $modicon[]=$icon;
+    $moddata[]="<A HREF=\"$CFG->wwwroot/admin/user.php\">".get_string("edituser")."</A>";
+    $modicon[]=$icon;
+    $fulladmin = "<P><A HREF=\"$CFG->wwwroot/admin/\">".get_string("admin")."</A>...";
+    print_side_block("", $moddata, "$fulladmin", $modicon);
+    echo "<IMG SRC=\"$CFG->wwwroot/pix/spacer.gif\" WIDTH=200 HEIGHT=0><BR>";
+}
+
+
 
 function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
     global $CFG;
index a74af31ac60659992697c90b87d61722cba4cec2..c9e32bfd20a0d2fd146683d06ac279829010bd3d 100644 (file)
         error("You must be an administrator to use this page.");
     }
 
+    $strassignteachers = get_string("assignteachers");
+    $stradministration = get_string("administration");
+
     if (!$id) {
-           print_header("Add teachers to a course", "Add teachers to a course", "<A HREF=\"$CFG->wwwroot/admin\">Admin</A> -> Add teachers", "");
+           print_header("$site->fullname: $strassignteachers", "$site->fullname", 
+                     "<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> $strassignteachers");
+
         if ($courses = get_records_sql("SELECT * from course WHERE category > 0 ORDER BY fullname")) {
 
             print_heading("Choose a course to add teachers to");
     }
 
 
-       print_header("Add teachers to $course->shortname", "Add teachers to a course", "<A HREF=\"$CFG->wwwroot/admin\">Admin</A> -> Add teachers to $course->shortname", "");
+       print_header("$site->fullname: $course->shortname: $strassignteachers", 
+                 "$site->fullname", 
+                 "<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> 
+                  <A HREF=\"teacher.php\">$strassignteachers</A> ->
+                  $course->shortname", "");
     print_heading($course->fullname);
 
 
index 1f4693ab140184f173090cde2f899069211d30fc..3f274113efbc47a2c8a02079d0703b8bebe35f22 100644 (file)
--- a/index.php
+++ b/index.php
          }
      
          if (isadmin()) {
-             print_simple_box(get_string("administration"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
-             $icon = "<IMG SRC=\"pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
-             $moddata[]="<A HREF=\"course/log.php?id=$site->id\">".get_string("sitelogs")."</A>";
-             $modicon[]=$icon;
-             $moddata[]="<A HREF=\"admin/site.php\">".get_string("sitesettings")."</A>";
-             $modicon[]=$icon;
-             $moddata[]="<A HREF=\"course/edit.php\">".get_string("addnewcourse")."</A>";
-             $modicon[]=$icon;
-             $moddata[]="<A HREF=\"course/teacher.php\">".get_string("assignteachers")."</A>";
-             $modicon[]=$icon;
-             $moddata[]="<A HREF=\"course/delete.php\">".get_string("deletecourse")."</A>";
-             $modicon[]=$icon;
-             $moddata[]="<A HREF=\"admin/user.php\">".get_string("edituser")."</A>";
-             $modicon[]=$icon;
-             $fulladmin = "<P><A HREF=\"admin/\">".get_string("admin")."</A>...";
-             print_side_block("", $moddata, "$fulladmin", $modicon);
-             echo "<IMG SRC=\"pix/spacer.gif\" WIDTH=200 HEIGHT=0><BR>";
+             print_admin_links();
          }
       ?>
 
index 70ef03f8ca50e721a9483bc68968b47ef43c0ec5..c5d844bcf45036ed48f0252e425aa2a37ef7c353 100644 (file)
@@ -20,6 +20,7 @@ $string[changepassword] = "Change password";
 $string[changedpassword] = "Changed password";
 $string[changessaved] = "Changes saved";
 $string[choosecourse] = "Choose a course";
+$string[chooseuser] = "Choose a user";
 $string[city] = "City/town";
 $string[confirmed] = "Your registration has been confirmed";
 $string["continue"] = "Continue";
index d610097f4392cdd2bcaed6c61c423f5b36743f41..53fdbb6321d24f2f4cf51aa9eb2397a53978100a 100644 (file)
 function find_form_errors(&$user, &$usernew, &$err) {
 
     if (isadmin()) {
-        if (empty($usernew->username))
+        if (empty($usernew->username)) {
             $err["username"] = get_string("missingusername");
 
+        } else if (record_exists("user", "username", $usernew->username) and $user->username == "changeme") {
+                $err["username"] = get_string("usernameexists");
+
+        } else {
+            $string = eregi_replace("[^([:alnum:])]", "", $user->username);
+            if (strcmp($user->username, $string)) 
+                $err["username"] = get_string("alphanumerical");
+        }
+
         if (empty($usernew->newpassword) and empty($user->password))
             $err["newpassword"] = get_string("missingpassword");
     }