|
@@ -1962,12 +1962,13 @@ class iassign {
|
|
|
//1 }
|
|
|
//1 $output .= "</form></center>\n";
|
|
|
//1 $only_one_send_button = 1; // avoid put comment frame again (bellow)
|
|
|
- //1 }
|
|
|
+ //1 }
|
|
|
|
|
|
$output .= $OUTPUT->box_end();
|
|
|
print $output;
|
|
|
} // if ($this->view_iassign)
|
|
|
|
|
|
+
|
|
|
print $OUTPUT->box_end(); // Box 5 to 'proposition' - close
|
|
|
|
|
|
} // if ($this->view_iassign)
|
|
@@ -5919,7 +5920,7 @@ class ilm_manager {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /// Function for get path and infos of dirs: dirid, dir_base, dir_parent, dir_home
|
|
|
+ /// Function for get path and info of directories: dirid, dir_base, dir_parent, dir_home
|
|
|
// @param string $key Key for return information
|
|
|
// @return Ambigous <unknown, number, string, NULL> Return an information requested
|
|
|
function get_dir_ilm ($key) {
|
|
@@ -5930,8 +5931,14 @@ class ilm_manager {
|
|
|
if ($dirid == 0) {
|
|
|
$dir = ($dir_home = $fs->create_directory($context->id, 'mod_iassign', 'activity', 0, $dir_base));
|
|
|
$dirid = $dir->get_id();
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
$dir = $fs->get_file_by_id($dirid);
|
|
|
+ if (!isset($dir) || !is_dir($dir)) {
|
|
|
+// print "Error: $key - $dirid => dir=''<br/>";
|
|
|
+//exit;
|
|
|
+ return;
|
|
|
+ }
|
|
|
$dir_base = $dir->get_filepath();
|
|
|
}
|
|
|
$dir_parent = $dir->get_parent_directory();
|
|
@@ -6179,10 +6186,11 @@ class ilm_manager {
|
|
|
|
|
|
|
|
|
/// Auxiliary function the get all files in a given context
|
|
|
+ // @calledby view_files_ilm($iassign_ilm_class, $extension, $start = 0)
|
|
|
// @return [array_contextid_files_thisauthor[], array_contextid_files_otherauthors[], array_contextid_files_otherauthors_userid[]]
|
|
|
//TODO Falta separar os arquivos listados, apresentar primeiro aqueles do autor e depois os demais.
|
|
|
//TODO Nao devemos listar aqueles que estao sem permissao (license == 'allrightsreserved')
|
|
|
- function get_files_in_context (&$allfiles, $contextid, $extension, $userid) {
|
|
|
+ function get_files_in_context (&$filesfrommine, &$filesfromothers, $contextid, $extension, $userid) {
|
|
|
// s_iassign_statement: id name iassignid type_iassign proposition author_name author_modified_name iassign_ilmid
|
|
|
// (NAO s_iassign_statement.file = s_files.id)
|
|
|
$fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
@@ -6194,125 +6202,44 @@ class ilm_manager {
|
|
|
//$filename = $item_fc->get_filename();
|
|
|
//$filepath = $item_fc->get_filepath();
|
|
|
//$fileid = $item_fc->get_id(); // get file ID (in *_iassign_statement table)
|
|
|
- //$fileuserid = $item_fc->get_userid(); // get user.id of the author
|
|
|
+ $fileuserid = $item_fc->get_userid(); // get user.id of the author
|
|
|
// $array_files_aux[] = $item_fc;
|
|
|
$itemid = $item_fc->get_id();
|
|
|
if (!in_array($itemid, $array_files_id)) {
|
|
|
//TODO Avoid to insert twice - necessary since it has been inserting 2 copies in iassign_statement
|
|
|
- $allfiles[] = $item_fc;
|
|
|
+ if ($fileuserid == $userid)
|
|
|
+ $filesfrommine[] = $item_fc;
|
|
|
+ else
|
|
|
+ $filesfromothers[] = $item_fc;
|
|
|
$array_files_id[] = $itemid;
|
|
|
$countf++;
|
|
|
}
|
|
|
}
|
|
|
//D echo "get_files_in_context: dir_base=$dir_base, contextid=$contextid, #array_files_id=".count($array_files_id) . " = $countf<br/>";
|
|
|
return $countf;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /// List iassign files from course directory
|
|
|
- // @calledby ilm_manager.php : $ilm_manager_instance->view_files_ilm($iassign_ilm->extension);
|
|
|
- function view_files_ilm ($iassign_ilm_class, $extension, $start = 0) {
|
|
|
- //TODO usar $start para trazer no maximo 50 arquivos iniciando em $start
|
|
|
- global $CFG, $DB, $USER, $OUTPUT;
|
|
|
- $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
- $context = context_course::instance($this->id); // $this->id = ID of the current course
|
|
|
- $ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
|
- $dirid = $this->get_dir_ilm('dirid');
|
|
|
- $dir_base = $this->get_dir_ilm('dir_base');
|
|
|
+ } // function get_files_in_context(&$filesfrommine, &$filesfromothers, $contextid, $extension, $userid)
|
|
|
|
|
|
- // Get all files in module iAssign
|
|
|
- // -- start
|
|
|
- $array_all_files = array(); // all files from all context.id (in data decreasing order)
|
|
|
- $array_contextid_files = array(); // context.id in data decreasing order
|
|
|
|
|
|
- $array_contextid_files_aux = array(); // all context.id in data creasing order
|
|
|
-
|
|
|
- // Get all files from table '*_files': id ; contenthash ; pathnamehash ; contextid ; component ;... filename ; userid ...
|
|
|
- // $DB is 'mysqli_native_moodle_database' object
|
|
|
- // if (has_capability("moodle/site:config", $context, $USER->id, true))
|
|
|
- // if (has_capability("mod/iassign:addinstance", $context, $USER->id, true))
|
|
|
- $hascapability = has_capability("moodle/site:config", $context, $USER->id); // *_capabilities="moodle/site:config" : greatest one)
|
|
|
- if ($hascapability==1) {
|
|
|
- //$array_query = array('component' => 'mod_iassign');
|
|
|
- $query_sql = "SELECT * FROM {files} WHERE component='mod_iassign' AND filearea='activity'";
|
|
|
- }
|
|
|
- else {
|
|
|
- // $array_query = array('component' => 'mod_iassign', 'userid' => $USER->id);
|
|
|
- $query_sql = "SELECT * FROM {files} WHERE component='mod_iassign' AND filearea='activity' AND " .
|
|
|
- " (license<>'allrightsreserved' OR contextid=" . $context->id . " OR userid=" . $USER->id . ")";
|
|
|
- }
|
|
|
- // files : id contenthash pathnamehash contextid component filearea itemid filepath filename userid filesize mimetype status source author license timecreated timemodified sortorder referencefileid
|
|
|
- // $files_iassign = $DB->get_records('files', $array_query); // extensions for all iLM...
|
|
|
- $files_iassign = $DB->get_records_sql($query_sql);
|
|
|
- //D echo "view_files_ilm: " . $USER->id . ", " . $hascapability . ": " . $query_sql . "<br/>";
|
|
|
- //D SELECT id,contextid,component,filearea,itemid,filepath,filename,userid FROM s_files WHERE component='mod_iassign' AND filearea='exercise';
|
|
|
-
|
|
|
- $count_all_files = 0;
|
|
|
- $count_files_with_ext = 0;
|
|
|
- $count_thisauthor_contextid = 0;
|
|
|
- $count_otherauthors_contextid = 0;
|
|
|
- //D echo "view_files_ilm: user.id=" . $USER->id . ", ext=$extension, #files=" . count($files_iassign) . "<br/>";
|
|
|
-
|
|
|
- if (is_array($files_iassign))
|
|
|
- foreach ($files_iassign as $item_files_iassign) {
|
|
|
- $extensionF = explode(".", $item_files_iassign->filename); // $item_files_iassign->get_filename()
|
|
|
- $lastitem = sizeof($extensionF);
|
|
|
- if ($lastitem>0) $lastitem--;
|
|
|
- else { echo ".";// error: it must have extension (after ".")
|
|
|
- continue;}
|
|
|
- $str_extension = $extensionF[$lastitem];
|
|
|
- $count_files_with_ext++;
|
|
|
- if ($extension == $str_extension) {
|
|
|
- $contextid = $item_files_iassign->contextid;
|
|
|
- if (!in_array($contextid, $array_contextid_files_aux)) { // not yet in array of context with this extension
|
|
|
-
|
|
|
- $array_contextid_files_aux[] = $contextid;
|
|
|
- $total_in_context = $this->get_files_in_context($array_all_files, $contextid, $extension, $USER->id); // $array_all_files by reference
|
|
|
-
|
|
|
- $count_all_files += $total_in_context;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //D echo "view_files_ilm: #array_contextid_files_aux=".count($array_contextid_files_aux). ", count_all_files=$count_all_files<br/>";
|
|
|
- //view_files_ilm: #array_contextid_files_aux=54
|
|
|
-
|
|
|
- //TODO Deste modo vem: se ADMIN => todos os arquivos de extensao compativel; senao todos os arquivos do usuario
|
|
|
- //TODO Implementar: se NAO ADMIN => pegar TODOS os arquivos do curso
|
|
|
- //TODO Tabela pegar todos '*_files.contextid' tais que '*_files.component=="mod_iassign"'
|
|
|
- $array_files_course = array();
|
|
|
- $dirs_array = ''; // if there are none 'exercise' file
|
|
|
- $files_array = ''; // idem
|
|
|
- $files_array = "''"; // idem
|
|
|
- $error_files_exists = "''"; // idem
|
|
|
- for ($ii=$count_all_files-1; $ii>0; $ii--) {
|
|
|
- //$contextid = $array_contextid_files[$ii];
|
|
|
- //$files_course = $fs->get_directory_files($contextid, 'mod_iassign', 'activity', 0, $dir_base, false, true, 'filename');
|
|
|
- //$array_files_course[] = $files_course;
|
|
|
- $files_course = $array_all_files[$ii];
|
|
|
-
|
|
|
- $files_array = '';
|
|
|
- $files_array .= "''";
|
|
|
- $error_files_exists = get_string('error_file_exists', 'iassign');
|
|
|
-
|
|
|
- $dirs_array = '';
|
|
|
- foreach ($files_course as $one_file) {
|
|
|
- if (!$one_file->is_directory())
|
|
|
- $files_array .= "'" . $one_file->get_filename() . "',";
|
|
|
- else { //if ($one_file->is_directory())
|
|
|
- $pathname = explode("/", substr($one_file->get_filepath(), 0, strlen($one_file->get_filepath()) - 1));
|
|
|
- $dirs_array .= "'" . $pathname[count($pathname) - 1] . "',";
|
|
|
- }
|
|
|
- } // foreach ($files_course as $one_file)
|
|
|
- } // for ($ii=0; $ii<$num_contexts; $ii++)
|
|
|
+ // Function to get all iLM files from the same "file type": (usually) files under the same directory
|
|
|
+ // @calledby view_files_ilm($iassign_ilm_class, $extension, $start = 0)
|
|
|
+ function get_all_ilm_files_by_fileid ($fileid) {
|
|
|
+ global $DB, $USER;
|
|
|
+ // $iassign_statement_activity_list = $DB->get_records("iassign_statement", array("file" => $fileid));
|
|
|
+ //TODO Criar coluna 'authorid'
|
|
|
+ $str_query = "SELECT * FROM {iassign_statement} " .
|
|
|
+ " WHERE file = " . $fileid . " ORDER BY author_name, timecreated DESC";
|
|
|
+ $array_iassign_ilm = $DB->get_records_sql($str_query);
|
|
|
+ return $array_iassign_ilm;
|
|
|
+ }
|
|
|
|
|
|
- print "#" . $count_all_files . "<br/>";
|
|
|
- // -- end
|
|
|
|
|
|
- $dirs_array .= "''";
|
|
|
+//NN
|
|
|
+ // Build string with JavaScript code with function to edit/remove/double iLM files
|
|
|
+ // @calledby view_files_ilm($iassign_ilm_class, $extension, $start = 0)
|
|
|
+ function get_string_JavaScript_functions ($dirid, $ilmid, $files_array, $dirs_array) {
|
|
|
+ global $CFG;
|
|
|
+ $error_files_exists = get_string('error_file_exists', 'iassign');
|
|
|
$error_dir_exists = get_string('error_dir_exists', 'iassign');
|
|
|
-
|
|
|
- //TODO Rever o 'preview' pois soh poder deixar ver uma vez
|
|
|
$code_javascript_ilm = "
|
|
|
<script type='text/javascript'>
|
|
|
//<![CDATA[
|
|
@@ -6352,7 +6279,7 @@ class ilm_manager {
|
|
|
function duplicate_ilm (ilmid, filename, fileid) { //JavaScript function
|
|
|
var filenamecopy;
|
|
|
var i;
|
|
|
- var files = new Array($files_array);
|
|
|
+ var files = new Array(" . $files_array . ");
|
|
|
do {
|
|
|
filenamecopy = prompt ('" . get_string('duplicate_file', 'iassign') . "',filename);
|
|
|
} while (filenamecopy == '');
|
|
@@ -6361,7 +6288,7 @@ class ilm_manager {
|
|
|
else {
|
|
|
for (i=0;i<files.length;i++) {
|
|
|
if (files[i]==filenamecopy) {
|
|
|
- alert('$error_files_exists');
|
|
|
+ alert('" . $error_files_exists . "');
|
|
|
return false;\n
|
|
|
}
|
|
|
}\n" .
|
|
@@ -6384,7 +6311,7 @@ class ilm_manager {
|
|
|
else {
|
|
|
for (i=0;i<files.length;i++) {
|
|
|
if (files[i]==filenamecopy) {
|
|
|
- alert('$error_files_exists');
|
|
|
+ alert('" . $error_files_exists . "');
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -6422,7 +6349,7 @@ class ilm_manager {
|
|
|
function new_dir_ilm () { //JavaScript function
|
|
|
var dirname = '';
|
|
|
var i;
|
|
|
- var dirs = new Array($dirs_array);
|
|
|
+ var dirs = new Array(" . $dirs_array . ");
|
|
|
do {
|
|
|
var dirname = prompt ('" . get_string('question_new_dir', 'iassign') . "', '');
|
|
|
} while (dirname == '');
|
|
@@ -6431,7 +6358,7 @@ class ilm_manager {
|
|
|
else {
|
|
|
for (i=0;i<dirs.length;i++) {
|
|
|
if (dirs[i]==dirname) {
|
|
|
- alert('$error_dir_exists');
|
|
|
+ alert('" . $error_dir_exists . "');
|
|
|
return false;\n
|
|
|
}
|
|
|
}
|
|
@@ -6459,7 +6386,7 @@ class ilm_manager {
|
|
|
else {
|
|
|
for (i=0;i<dirs.length;i++) {
|
|
|
if (dirs[i]==dirnamecopy) {
|
|
|
- alert('$error_dir_exists');
|
|
|
+ alert('" . $error_dir_exists . "');
|
|
|
return false;\n
|
|
|
}
|
|
|
}
|
|
@@ -6504,6 +6431,146 @@ class ilm_manager {
|
|
|
|
|
|
//]]>
|
|
|
</script>\n"; // end of $code_javascript_ilm
|
|
|
+ return $code_javascript_ilm;
|
|
|
+ } // function get_string_JavaScript_functions($dirid, $ilmid, $files_array, $dirs_array)
|
|
|
+
|
|
|
+
|
|
|
+ /// List iassign files from course directory
|
|
|
+ // @calledby ilm_manager.php : $ilm_manager_instance->view_files_ilm($iassign_ilm->extension);
|
|
|
+ function view_files_ilm ($iassign_ilm_class, $extension, $start = 0) {
|
|
|
+ //TODO usar $start para trazer no maximo 50 arquivos iniciando em $start
|
|
|
+ global $CFG, $DB, $USER, $OUTPUT;
|
|
|
+ $fs = get_file_storage(); // Get reference to all files in Moodle data
|
|
|
+ $context = context_course::instance($this->id); // $this->id = ID of the current course
|
|
|
+ $ilmid = optional_param('ilmid', NULL, PARAM_INT);
|
|
|
+ $dirid = $this->get_dir_ilm('dirid');
|
|
|
+ $dir_base = $this->get_dir_ilm('dir_base');
|
|
|
+
|
|
|
+ // Get all files in module iAssign
|
|
|
+ // -- start
|
|
|
+ $array_contextid_files = array(); // context.id in data decreasing order
|
|
|
+
|
|
|
+ $array_contextid_files_aux = array(); // all context.id in data creasing order
|
|
|
+
|
|
|
+ // Get all files from table '*_files': id ; contenthash ; pathnamehash ; contextid ; component ;... filename ; userid ...
|
|
|
+ // $DB is 'mysqli_native_moodle_database' object
|
|
|
+ // if (has_capability("moodle/site:config", $context, $USER->id, true))
|
|
|
+ // if (has_capability("mod/iassign:addinstance", $context, $USER->id, true))
|
|
|
+ $hascapability = has_capability("moodle/site:config", $context, $USER->id); // *_capabilities="moodle/site:config" : greatest one)
|
|
|
+ if ($hascapability==1) {
|
|
|
+ //$array_query = array('component' => 'mod_iassign');
|
|
|
+ $query_sql = "SELECT * FROM {files} WHERE component='mod_iassign' AND filearea='activity'";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // $array_query = array('component' => 'mod_iassign', 'userid' => $USER->id);
|
|
|
+ $query_sql = "SELECT * FROM {files} WHERE component='mod_iassign' AND filearea='activity' AND " .
|
|
|
+ " (license<>'allrightsreserved' OR contextid=" . $context->id . " OR userid=" . $USER->id . ")";
|
|
|
+ }
|
|
|
+ // files : id contenthash pathnamehash contextid component filearea itemid filepath filename userid filesize mimetype status source author license timecreated timemodified sortorder referencefileid
|
|
|
+ // $files_iassign = $DB->get_records('files', $array_query); // extensions for all iLM...
|
|
|
+ $files_iassign = $DB->get_records_sql($query_sql);
|
|
|
+ //D echo "view_files_ilm: " . $USER->id . ", " . $hascapability . ": " . $query_sql . "<br/>";
|
|
|
+ //D SELECT id,contextid,component,filearea,itemid,filepath,filename,userid FROM s_files WHERE component='mod_iassign' AND filearea='exercise';
|
|
|
+
|
|
|
+ $count_all_files_others = 0;
|
|
|
+ $count_all_files_my = 0;
|
|
|
+ $count_files_with_ext = 0;
|
|
|
+ $count_thisauthor_contextid = 0;
|
|
|
+ $count_otherauthors_contextid = 0;
|
|
|
+ //D echo "view_files_ilm: user.id=" . $USER->id . ", ext=$extension, #files=" . count($files_iassign) . "<br/>";
|
|
|
+
|
|
|
+//$files_from_others + $files_from_mine
|
|
|
+ $files_from_mine = array(); // all files from all context.id (in data decreasing order) from this user
|
|
|
+ $files_from_others = array(); // all files from all context.id (in data decreasing order) from others then this user
|
|
|
+
|
|
|
+
|
|
|
+ if (is_array($files_iassign)) {
|
|
|
+ if ($hascapability == 1) { // is Admin => get all files from this extension $extension
|
|
|
+ foreach ($files_iassign as $item_files_iassign) {
|
|
|
+ $extensionF = explode(".", $item_files_iassign->filename); // $item_files_iassign->get_filename()
|
|
|
+ $lastitem = sizeof($extensionF);
|
|
|
+ if ($lastitem>0) $lastitem--;
|
|
|
+ else {
|
|
|
+ // print "x";// error: it must have extension (after ".")
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $str_extension = $extensionF[$lastitem];
|
|
|
+ $count_files_with_ext++;
|
|
|
+ if ($extension == $str_extension) {
|
|
|
+ $contextid = $item_files_iassign->contextid;
|
|
|
+ if (!in_array($contextid, $array_contextid_files_aux)) { // not yet in array of context with this extension
|
|
|
+ $array_contextid_files_aux[] = $contextid;
|
|
|
+
|
|
|
+ // Parameters '$files_from_mine' and '$files_from_others' are by reference (will be altered by 'get_files_in_context(...)'
|
|
|
+ $total_in_context = $this->get_files_in_context($files_from_mine, $files_from_others, $contextid, $extension, $USER->id);
|
|
|
+
|
|
|
+ $count_all_files_others += $total_in_context;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else { // not admin, get only on this context
|
|
|
+ $contextid = $context->id;
|
|
|
+ $array_contextid_files_aux[] = $contextid;
|
|
|
+ // Parameters '$files_from_mine' and '$files_from_others' are by reference (will be altered by 'get_files_in_context(...)'
|
|
|
+ $total_in_context = $this->get_files_in_context($files_from_mine, $files_from_others, $contextid, $extension, $USER->id);
|
|
|
+
|
|
|
+ $count_all_files_others = $total_in_context;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // Joint all files to $array_all_files
|
|
|
+ $totalFromMine = count($files_from_mine);
|
|
|
+ $totalOthers = count($files_from_others);
|
|
|
+ $total_files = $totalFromMine + $totalOthers; //$count_all_files_others;
|
|
|
+ $array_all_files = array(); // all files from all context.id (in data decreasing order)
|
|
|
+ for ($ii=0; $ii<$totalOthers; $ii++) // Insert in first position all files from other then this user (bellow is inverted)
|
|
|
+ $array_all_files[] = $files_from_others[$ii];
|
|
|
+ for ($ii=0; $ii<$totalFromMine; $ii++) // Now insert the user's files (bellow is inverted) => will appear on first
|
|
|
+ $array_all_files[] = $files_from_mine[$ii];
|
|
|
+
|
|
|
+ //D echo "view_files_ilm: #array_contextid_files_aux=".count($array_contextid_files_aux). ", count_all_files_others=$total_files<br/>";
|
|
|
+ //view_files_ilm: #array_contextid_files_aux=54
|
|
|
+
|
|
|
+ //TODO Deste modo vem: se ADMIN => todos os arquivos de extensao compativel; senao todos os arquivos do usuario
|
|
|
+ //TODO Implementar: se NAO ADMIN => pegar TODOS os arquivos do curso
|
|
|
+ //TODO Tabela pegar todos '*_files.contextid' tais que '*_files.component=="mod_iassign"'
|
|
|
+ $array_files_course = array();
|
|
|
+ $dirs_array = ''; // if there are none 'exercise' file
|
|
|
+ $files_array = ''; // idem
|
|
|
+ $files_array = "''"; // idem
|
|
|
+ //NN $error_files_exists = "''"; // idem
|
|
|
+ for ($ii=$total_files-1; $ii>0; $ii--) {
|
|
|
+ //$contextid = $array_contextid_files[$ii];
|
|
|
+ //$files_course = $fs->get_directory_files($contextid, 'mod_iassign', 'activity', 0, $dir_base, false, true, 'filename');
|
|
|
+ //$array_files_course[] = $files_course;
|
|
|
+ $files_course = $array_all_files[$ii];
|
|
|
+
|
|
|
+ $files_array = '';
|
|
|
+ $files_array .= "''";
|
|
|
+ //NN $error_files_exists = get_string('error_file_exists', 'iassign');
|
|
|
+
|
|
|
+ $dirs_array = '';
|
|
|
+ foreach ($files_course as $one_file) {
|
|
|
+ if (!$one_file->is_directory())
|
|
|
+ $files_array .= "'" . $one_file->get_filename() . "',";
|
|
|
+ else { //if ($one_file->is_directory())
|
|
|
+ $pathname = explode("/", substr($one_file->get_filepath(), 0, strlen($one_file->get_filepath()) - 1));
|
|
|
+ $dirs_array .= "'" . $pathname[count($pathname) - 1] . "',";
|
|
|
+ }
|
|
|
+ } // foreach ($files_course as $one_file)
|
|
|
+ } // for ($ii=0; $ii<$num_contexts; $ii++)
|
|
|
+
|
|
|
+ print "#" . $total_files . "<br/>";
|
|
|
+ // -- end
|
|
|
+
|
|
|
+ $dirs_array .= "''";
|
|
|
+ //NN $error_dir_exists = get_string('error_dir_exists', 'iassign');
|
|
|
+
|
|
|
+ //TODO Rever o 'preview' pois soh poder deixar ver uma vez
|
|
|
+ //NN Retirei daqui as X linhas para definir javascript via variavel '$code_javascript_ilm'
|
|
|
+ //NN Agora em funcao get_string_JavaScript_functions(...) bellow
|
|
|
|
|
|
$output = "";
|
|
|
$select_all = "";
|
|
@@ -6514,8 +6581,8 @@ class ilm_manager {
|
|
|
foreach ($iassign_ilm as $item_iassign_ilm)
|
|
|
$extensions_allow = array_merge($extensions_allow, explode(",", $item_iassign_ilm->extension));
|
|
|
|
|
|
- //Estava foreach ($files_course as $one_file)
|
|
|
- for ($ii=$count_all_files-1; $ii>0; $ii--) { // function view_files_ilm ($iassign_ilm_class, $extension)
|
|
|
+ // Estava foreach ($files_course as $one_file)
|
|
|
+ for ($ii=$total_files-1; $ii>0; $ii--) { // function view_files_ilm ($iassign_ilm_class, $extension)
|
|
|
|
|
|
//$contextid = $array_contextid_files[$ii]; // Notice: Undefined offset: 2257 in /var/www/html/saw/mod/iassign/locallib.php on line 6333
|
|
|
//$files_course = $array_files_course[$ii];
|
|
@@ -6526,7 +6593,7 @@ class ilm_manager {
|
|
|
$filepath = $one_file->get_filepath();
|
|
|
$pathname = explode("/", substr($filepath, 0, strlen($filepath) - 1));
|
|
|
$pathname = $pathname[count($pathname) - 1];
|
|
|
- $fileid = $one_file->get_id();
|
|
|
+ $fileid = $one_file->get_id(); // get the file id (in table 'files')
|
|
|
|
|
|
$tmp = explode(".", $filename);
|
|
|
if (is_array($tmp)) { // define file type
|
|
@@ -6549,14 +6616,17 @@ class ilm_manager {
|
|
|
|
|
|
// buscar fileid nas tabelas do iassign
|
|
|
$list_filein_use = "";
|
|
|
- $iassign_statement_activity_list = $DB->get_records("iassign_statement", array("file" => $fileid));
|
|
|
+
|
|
|
+ // $iassign_statement_activity_list = $DB->get_records("iassign_statement", array("file" => $fileid));
|
|
|
+ $iassign_statement_activity_list = $this->get_all_ilm_files_by_fileid($fileid); // get all files under this directory (if it is the case)
|
|
|
+
|
|
|
if ($iassign_statement_activity_list) {
|
|
|
foreach ($iassign_statement_activity_list as $iassign_statement_activity_item) {
|
|
|
$list_filein_use .= $iassign_statement_activity_item->name . "</br>\n";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $array_iassign_ilm = $DB->get_records("iassign_ilm", array('extension' => $filetype, 'parent' => '0', 'enable' => '1'));
|
|
|
+ $array_iassign_ilm = $DB->get_records("iassign_ilm", array('extension' => $filetype, 'parent' => '0', 'enable' => '1')); // get all iLM from this "file type"
|
|
|
|
|
|
foreach ($array_iassign_ilm as $iassign_ilm) { // get files from all iLM equivalent
|
|
|
|
|
@@ -6588,7 +6658,7 @@ class ilm_manager {
|
|
|
$link_edit = " " . iassign_icons::insert('no_edit_iassign');
|
|
|
$link_filter = " <a href='#' onclick='preview_ilm(" . $fileid . "," . $ilmid . ");'>" . iassign_icons::insert('preview_iassign') . "</a>\n";
|
|
|
|
|
|
- if ($one_file->get_userid() == $USER->id) {
|
|
|
+ if ($one_file->get_userid() == $USER->id || $hascapability==1) { // is the author or is Admin
|
|
|
if ($iassign_statement_activity_list) {
|
|
|
$check_select = "";
|
|
|
$link_edit = iassign_icons::insert('edit_iassign_disable');
|
|
@@ -6597,7 +6667,7 @@ class ilm_manager {
|
|
|
}
|
|
|
else {
|
|
|
$check_select = "<input name='selected_file' type='checkbox' value='$fileid'/>\n";
|
|
|
- $link_edit = " <a href='#' onclick='update_ilm(\"$iassign_ilm->id\", $fileid)'>" . iassign_icons::insert('edit_iassign') . "</a>\n";
|
|
|
+ $link_edit = " <a href='#' onclick='update_ilm(\"" . $iassign_ilm->id . "\", $fileid)'>" . iassign_icons::insert('edit_iassign') . "</a>\n";
|
|
|
$link_delete = " <a href='#' onclick='delete_ilm(\"$iassign_ilm->id\", $fileid);'>" . iassign_icons::insert('delete_iassign') . "</a>\n";
|
|
|
$link_rename = " <a href='#' onclick='rename_ilm(\"$iassign_ilm->id\", \"$filename\"," . $fileid . ");'>" . iassign_icons::insert('rename_iassign') . "</a>\n";
|
|
|
}
|
|
@@ -6660,7 +6730,7 @@ class ilm_manager {
|
|
|
|
|
|
} // if (in_array(strtolower($filetype), $extensions) || $one_file->is_directory() || $this->from == 'block' || $this->from == 'tinymce' || $this->from == 'atto')
|
|
|
|
|
|
- } // for ($ii=$count_all_files-1; $ii>0; $ii--) // for ($ii=0; $ii<$num_contexts; $ii++)
|
|
|
+ } // for ($ii=$total_files-1; $ii>0; $ii--) // for ($ii=0; $ii<$num_contexts; $ii++)
|
|
|
|
|
|
$basename = explode("/", substr($dir_base, 0, strlen($dir_base) - 1));
|
|
|
$dir_base = "";
|
|
@@ -6705,7 +6775,7 @@ class ilm_manager {
|
|
|
$html .= $OUTPUT->help_icon('file_ilm_recover', 'iassign') . "</td></tr></table>\n";
|
|
|
$html .= "</form>\n";
|
|
|
|
|
|
- print $code_javascript_ilm;
|
|
|
+ print $this->get_string_JavaScript_functions($ilmid, $dirid, $files_array, $dirs_array); //NN put here all JavaScript code to edit/remove/double ($code_javascript_ilm)
|
|
|
|
|
|
print $html;
|
|
|
} // function view_files_ilm($extension)
|