]> git.mjollnir.org Git - moodle.git/commitdiff
Commented the "needed users" option (too complex for this initial release).
authorstronk7 <stronk7>
Sun, 4 May 2003 01:10:20 +0000 (01:10 +0000)
committerstronk7 <stronk7>
Sun, 4 May 2003 01:10:20 +0000 (01:10 +0000)
Check all and course users.

backup/backup.html
backup/check.html
backup/db/backup_mysql.php
backup/lib.php

index d52589197168cc6fc4a1d5de11aa13cd52fed6a9..7996fdb00a93b939a9d8268ae687496a94bdb752 100644 (file)
@@ -34,7 +34,7 @@
 
     //Check other parameters
     if (!isset($backup_users)) {
-        $backup_users = 2;
+        $backup_users = 1;
     }
    
     if (!isset($backup_logs)) {
@@ -91,7 +91,7 @@
         echo "</td><td>";
         $user_options[0] = get_string("all");
         $user_options[1] = get_string("course");
-        $user_options[2] = get_string("needed");
+        //$user_options[2] = get_string("needed");-->NOT IMPLEMENTED
         choose_from_menu($user_options, "backup_users", $backup_users, "");
         echo "</td></tr>";
 
index 378962326376968808eab6e760f79108782c7b3b..f1e4ea9ea6b0cb88441ef973763a22e5e64959de 100644 (file)
@@ -34,7 +34,7 @@
 
     //Check other parameters
     if (!isset($backup_users)) {
-        $backup_users = 2;
+        $backup_users = 1;
     }
    
     if (!isset($backup_logs)) {
 
         //Now print the Users tr
         echo "<tr>";
-        echo "<td align=\"right\"><P><B>";
-        echo get_string("users").":";
-        echo "</td><td>";
-        $user_options[0] = get_string("all");
-        $user_options[1] = get_string("course");
-        $user_options[2] = get_string("needed");
-        choose_from_menu($user_options, "backup_users", $backup_users, "");
+        echo "<td colspan=\"2\"><P><B>";
+        $user_options[0] = get_string("includeallusers");
+        $user_options[1] = get_string("includecourseusers");
+        ///$user_options[2] = get_string("includeneededusers");--->NOT IMPLEMENTED
+        echo "<li>".$user_options[$backup_users]."<P>";
+        //Add as hidden name
+        echo "<input type=\"hidden\" name=\"backup_users\" value=\"".$backup_users."\">";
+        //Print info
+        $table->data = user_check_backup($id,$backup_unique_code,$backup_users);  
+        print_table($table); 
         echo "</td></tr>";
 
-        //Now print the Logs tr
-        echo "<tr>";
-        echo "<td align=\"right\"><P><B>";
-        echo get_string("logs").":";                                               
-        echo "</td><td>";
-        $log_options[0] = get_string("no");
-        $log_options[1] = get_string("yes"); 
-        choose_from_menu($log_options, "backup_logs", $backup_logs, ""); 
-        echo "</td></tr>";
+        //Now print the Logs tr conditionally
+        if ($backup_logs) {
+            echo "<tr>";
+            echo "<td colspan=\"2\"><P><B>";
+            echo "<li>".get_string("includelogentries");; 
+            echo "</td></tr>";
+        }
+        //Add as hidden name
+        echo "<input type=\"hidden\" name=\"backup_logs\" value=\"".$backup_logs."\">";
 
-        //Now print the User Files tr
-        echo "<tr>";
-        echo "<td align=\"right\"><P><B>";
-        echo get_string ("userfiles").":";
-        echo "</td><td>";
-        $user_file_options[0] = get_string("no"); 
-        $user_file_options[1] = get_string("yes"); 
-        choose_from_menu($user_file_options, "backup_user_files", $backup_user_files, "");
-        echo "</td></tr>";
+        //Now print the User Files tr conditionally
+        if ($backup_user_files) {
+            echo "<tr>";
+            echo "<td colspan=\"2\"><P><B>";
+            echo "<li>".get_string("includeuserfiles");;
+            echo "</td></tr>";
+        }
+        //Add as hidden name
+        echo "<input type=\"hidden\" name=\"backup_user_files\" value=\"".$backup_user_files."\">";
 
-        //Now print the Course Files tr
-        echo "<tr>";
-        echo "<td align=\"right\"><P><B>";
-        echo get_string ("coursefiles").":";
-        echo "</td><td>";
-        $course_file_options[0] = get_string("no");
-        $course_file_options[1] = get_string("yes");
-        choose_from_menu($course_file_options, "backup_course_files", $backup_course_files, "");
-        echo "</td></tr>";
+        //Now print the Course Files tr conditionally
+       if ($backup_course_files) {
+            echo "<tr>";
+            echo "<td colspan=\"2\"><P><B>";
+            echo "<li>".get_string("includecoursefiles");; 
+            echo "</td></tr>";
+        }
+        //Add as hidden name
+        echo "<input type=\"hidden\" name=\"backup_course_files\" value=\"".$backup_course_files."\">";
     }
 ?>
 </table>
index 1b332cbf5467ce9d7eca470a1b0e55c35b13e7d7..69d29b1dbf4025b9e16e3da3501a4219ef86d5b7 100644 (file)
@@ -37,7 +37,7 @@ function backup_upgrade($oldversion=0) {
 
     if ($oldversion < 2003050301 and $result) {
         $result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
-                         ADD `time` INT(10) UNSIGNED");
+                         ADD `info` VARCHAR(30)");
     } 
 
 
index f07ac6db9bc926d3578621d06658d8bbc1e0a2fd..22250ce42ae717064bccb5853501634f1a3433e8 100644 (file)
                                WHERE backup_code = '$backup_unique_code'",false);
         return $status;
     }
+    //Calculate the number of users to backup and put their ids in backup_ids
+    //Return an array of info (name,value)
+    function user_check_backup($course,$backup_unique_code,$backup_users) {
+        //$backup_users=0-->all
+        //              1-->course
+        //              2-->needed-->NOT IMPLEMEMTED
+
+        global $CFG;
+
+        if ($backup_users == 0) {
+            //Insert all users (from user)
+            $sql_insert = "INSERT INTO {$CFG->prefix}backup_ids
+                               (backup_code, table_name, old_id)
+                           SELECT DISTINCT '$backup_unique_code','user',u.id
+                           FROM {$CFG->prefix}user u";
+        } else {
+            //Insert only course users (from user_students and user_teachers)
+            $sql_insert = "INSERT INTO {$CFG->prefix}backup_ids
+                               (backup_code, table_name, old_id)
+                           SELECT DISTINCT '$backup_unique_code','user',u.id
+                           FROM {$CFG->prefix}user u,
+                                {$CFG->prefix}user_students s,
+                                {$CFG->prefix}user_teachers t
+                           WHERE s.course = '$course' AND
+                                 t.course = s.course AND
+                                 (s.userid = u.id OR t.userid = u.id)";
+        }
+        //Execute the insert
+        $status = execute_sql($sql_insert,false);
+
+        //Now execute the select
+        $ids = get_records_sql("SELECT DISTINCT u.old_id,u.table_name
+                                FROM {$CFG->prefix}backup_ids u
+                                WHERE backup_code = '$backup_unique_code' AND
+                                      table_name ='user'");
+    
+        //Gets the user data
+        $info[0][0] = get_string("users");
+        if ($ids) {
+            $info[0][1] = count($ids);      
+        } else {
+            $info[0][1] = 0;
+        }
+
+        return $info;
+    }
 
 ?>