ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilDBUpdate5069 Class Reference
+ Collaboration diagram for ilDBUpdate5069:

Public Member Functions

 fix19795 ()
 Migration for bug fix 19795. More...
 

Detailed Description

Definition at line 7 of file class.ilDBUpdate5069.php.

Member Function Documentation

◆ fix19795()

ilDBUpdate5069::fix19795 ( )

Migration for bug fix 19795.

Definition at line 12 of file class.ilDBUpdate5069.php.

References $ilDB, $new, $old, $result, $row, and array.

13  {
14  global $ilDB;
15 
16  //query only the feedback with uploaded files.
17  $result = $ilDB->query("SELECT exc_assignment.exc_id, exc_assignment.peer_crit_cat, exc_assignment.id, exc_assignment_peer.giver_id, exc_assignment_peer.peer_id".
18  " FROM exc_assignment_peer, exc_assignment".
19  " WHERE exc_assignment.id = exc_assignment_peer.ass_id".
20  " AND (exc_assignment.peer_file = 1 OR exc_assignment.peer_crit_cat > 0)".
21  " AND exc_assignment_peer.tstamp IS NOT null"
22  );
23 
24  while($row = $ilDB->fetchAssoc($result))
25  {
26  include_once("./Services/Migration/DBUpdate_5069/classes/class.ilFSStorageExercise5069.php");
27  $storage = new ilFSStorageExercise5069($row['exc_id'], $row['id']);
28 //echo "0 -".$row['peer_crit_cat']."<br>";
29  //if the assignment has criteria category
30  if($row['peer_crit_cat'])
31  {
32  //get criteria id which is uploader
33  // *** string -> text
34  $res_crit = $ilDB->query($q = "SELECT id FROM exc_crit ".
35  " WHERE parent = ".$ilDB->quote($row['peer_crit_cat'],"integer").
36  " AND type = ".$ilDB->quote('file','text')
37  );
38 //echo "#".$q."#<br>";
39  while($row_crit = $ilDB->fetchAssoc($res_crit))
40  {
41  $original_path = $storage->getPeerReviewUploadPath($row['peer_id'], $row['giver_id'], $row_crit['id']);
42 //echo "a-$original_path-<br>";
43  $path_peaces = explode('/', rtrim($original_path, '/'));
44  array_pop($path_peaces);
45  $previous_dir_path = "";
46  foreach ($path_peaces as $piece)
47  {
48  $previous_dir_path .= $piece."/";
49  }
50  $dir_content = array_diff(scandir($previous_dir_path), array('.', '..'));
51 //echo $previous_dir_path."<br>";
52  //loop the directory content
53  foreach($dir_content as $content)
54  {
55  if(is_dir($previous_dir_path.$content))
56  {
57  //if the directory name is wrong(giver_id+criteria_id)
58  if($content == $row['giver_id'].$row_crit['id'])
59  {
60  if(!is_dir($previous_dir_path.$row['giver_id']))
61  {
62  mkdir($previous_dir_path.$row['giver_id']);
63 //echo "1 make dir ".$previous_dir_path.$row['giver_id']."<br>";
64  }
65 
66  if(!is_dir($previous_dir_path.$row['giver_id']."/".$row_crit['id']))
67  {
68  mkdir($previous_dir_path.$row['giver_id']."/".$row_crit['id']);
69 //echo "2 make dir ".$previous_dir_path.$row['giver_id']."/".$row_crit['id']."<br>";
70  }
71 
72 
73  $old = substr($original_path, 0, strlen($original_path) - 1);
74  $new = $previous_dir_path.$row['giver_id']."/".$row_crit['id'];
75  if (is_dir($old))
76  {
77  rename($old, $new);
78  }
79 //echo "rename ".$old." to ".$new."<br>";
80  }
81  }
82  }
83  }
84  }
85  //assignment without criteria (just rename the file and move it to the proper directory)
86  else
87  {
88  $original_path = $storage->getPeerReviewUploadPath($row['peer_id'], $row['giver_id'], $row['peer_crit_cat']);
89 
90  $path_peaces = explode('/', rtrim($original_path, '/'));
91  array_pop($path_peaces);
92  $previous_dir_path = "";
93  foreach ($path_peaces as $piece)
94  {
95  $previous_dir_path .= $piece."/";
96  }
97 
98  $dir_content = array_diff(scandir($previous_dir_path), array('.', '..'));
99 
100  foreach($dir_content as $content)
101  {
102  if(!is_dir($previous_dir_path.$content))
103  {
104  if (substr($content, 0, strlen($row['giver_id'])) === $row['giver_id'])
105  {
106  $new_filename = substr($content, strlen($row['giver_id']));
107  copy($previous_dir_path.$content, $original_path."/".$new_filename);
108 //echo "5 copy ".$previous_dir_path.$content." to ".$original_path."/".$new_filename."<br>";
109  }
110  }
111  }
112 
113  }
114 
115  }
116 
117 // die("ende");
118  }
$result
$old
Create styles array
The data for the language used.
global $ilDB

The documentation for this class was generated from the following file: