Allowing certificates in gradebook

skala
Julio Montoya 13 years ago
parent c86289ed19
commit 012940efe3
  1. 2
      main/document/document.php
  2. 55
      main/inc/lib/document.lib.php

@ -1056,7 +1056,7 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
$row[] = $document_data['path'];
}
if (DocumentManager::is_folder_to_avoid($document_data['path'])) {
if (DocumentManager::is_folder_to_avoid($document_data['path'], $is_certificate_mode)) {
continue;
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -9,12 +10,14 @@
*
* @package chamilo.library
*/
/**
* Code
*/
class DocumentManager {
private function __construct() {
}
/**
@ -554,7 +557,6 @@ class DocumentManager {
$temp[$row['id']] = $row;
}
//@todo use the DocumentManager::is_visible function
//Checking disponibility in a session
foreach ($my_repeat_ids as $id) {
foreach ($doc_list as $row) {
@ -648,7 +650,6 @@ class DocumentManager {
}
} else {
//no invisible folders
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
@ -843,7 +844,6 @@ class DocumentManager {
$mdStore->mds_delete_offspring($eid);
}
/**
* This deletes a document by changing visibility to 2, renaming it to filename_DELETED_#id
* Files/folders that are inside a deleted folder get visibility 2
@ -939,7 +939,6 @@ class DocumentManager {
return true;
} else {
//Something went wrong
//The file or directory isn't there anymore (on the filesystem)
// This means it has been removed externally. To prevent a
// blocking error from happening, we drop the related items from the
@ -1083,7 +1082,6 @@ class DocumentManager {
return false;
}
/**
* Allow to set a specific document as a new template for FCKEditor for a particular user in a particular course
*
@ -1112,7 +1110,6 @@ class DocumentManager {
return true;
}
/**
* Unset a document as template
*
@ -1229,7 +1226,6 @@ class DocumentManager {
//2. Course and Session visibility are handle in local.inc.php/global.inc.php
//3. Checking if user exist in course/session
if ($session_id == 0) {
@ -1295,7 +1291,6 @@ class DocumentManager {
return false;
}
/**
* Allow attach a certificate to a course
* @param string The course id
@ -1467,6 +1462,7 @@ class DocumentManager {
$info_list[] = $info_to_replace_in_content_html;
return $info_list;
}
/**
* Remove default certificate
* @param string The course id
@ -1576,7 +1572,6 @@ class DocumentManager {
if (!$is_file) {
$attributes = self::parse_HTML_attributes($source_html, $wanted_attributes);
} else {
if (is_file($source_html)) {
$abs_path = $source_html;
@ -1610,10 +1605,14 @@ class DocumentManager {
$sources = $attributes[$attr];
foreach ($sources as $source) {
//skip what is obviously not a resource
if (strpos($source, '+this.')) continue; //javascript code - will still work unaltered
if (strpos($source, '.') === false) continue; //no dot, should not be an external file anyway
if (strpos($source, 'mailto:')) continue; //mailto link
if (strpos($source, ';') && !strpos($source, '&amp;')) continue; //avoid code - that should help
if (strpos($source, '+this.'))
continue; //javascript code - will still work unaltered
if (strpos($source, '.') === false)
continue; //no dot, should not be an external file anyway
if (strpos($source, 'mailto:'))
continue; //mailto link
if (strpos($source, ';') && !strpos($source, '&amp;'))
continue; //avoid code - that should help
if ($attr == 'value') {
if (strpos($source, 'mp3file')) {
@ -1865,11 +1864,8 @@ class DocumentManager {
'))' .
'|' .
// '(@import([ \n\t\r]+)?("[^"]+"|\'[^\']+\'|[^ \n\t\r]+)))?/', -> takes a lot (like 100's of thousands of empty possibilities)
'(@import([ \n\t\r]+)?("[^"]+"|\'[^\']+\'|[^ \n\t\r]+)))/',
$attrString,
$regs
'(@import([ \n\t\r]+)?("[^"]+"|\'[^\']+\'|[^ \n\t\r]+)))/', $attrString, $regs
);
} catch (Exception $e) {
error_log('Caught exception: ' . $e->getMessage(), 0);
}
@ -1936,8 +1932,6 @@ class DocumentManager {
$real_orig_url = $source[0]; // url
$scope_url = $source[1]; // scope (local, remote)
$type_url = $source[2]; // tyle (rel, abs, url)
// Get path and query from origin url
$orig_parse_url = parse_url($real_orig_url);
$real_orig_path = $orig_parse_url['path'];
@ -1988,7 +1982,6 @@ class DocumentManager {
$doc_id = add_document($destination_course_info, $filepath_to_add, 'file', $size, basename($filepath_to_add));
api_item_property_update($destination_course_info, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $user_id, null, null, null, null);
}
}
}
@ -2130,8 +2123,6 @@ class DocumentManager {
$real_orig_url = $source[0]; // url
$scope_url = $source[1]; // scope (local, remote)
$type_url = $source[2]; // tyle (rel, abs, url)
// Get path and query from origin url
$orig_parse_url = parse_url($real_orig_url);
$real_orig_path = $orig_parse_url['path'];
@ -2271,7 +2262,6 @@ class DocumentManager {
*/
function get_text_content($doc_path, $doc_mime) {
// TODO: review w$ compatibility
// Use usual exec output lines array to store stdout instead of a temp file
// because we need to store it at RAM anyway before index on ChamiloIndexer object
$ret_val = null;
@ -2338,13 +2328,11 @@ class DocumentManager {
$content .= $line . "\n";
}
return $content;
}
else {
} else {
return false;
}
}
/**
* Calculates the total size of all documents in a course
*
@ -2395,7 +2383,6 @@ class DocumentManager {
}
}
/**
* Here we count 1 kilobyte = 1000 byte, 12 megabyte = 1000 kilobyte.
*/
@ -2442,7 +2429,6 @@ class DocumentManager {
echo $message;
}
/**
* Display the document quota in a simple way
*
@ -2458,7 +2444,6 @@ class DocumentManager {
echo Display::div($message, array('id' => 'document_quota'));
}
/**
* Checks if there is enough place to add a file on a directory
* on the base of a maximum directory size allowed
@ -2486,7 +2471,6 @@ class DocumentManager {
* @param array paremeters: count, url, extension
* @return string
*/
static function generate_jplayer_jquery($params = array()) {
$js_path = api_get_path(WEB_LIBRARY_PATH) . 'javascript/';
@ -2917,7 +2901,9 @@ class DocumentManager {
if (!empty($document_data)) {
//if admin or course teacher, allow anyway
if (api_is_platform_admin() || CourseManager::is_course_teacher($user_id,$course_code)) { return true; }
if (api_is_platform_admin() || CourseManager::is_course_teacher($user_id, $course_code)) {
return true;
}
$course_info = api_get_course_info($course_code);
if ($document_data['parent_id'] == false || empty($document_data['parent_id'])) {
$visible = self::is_visible_by_id($doc_id, $course_info, $session_id, $user_id);
@ -3034,7 +3020,6 @@ class DocumentManager {
// Actually, it consists on a delete of terms from db,
// insert new ones, create a new search engine document,
// and remove the old one
// Get search_did
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
$sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
@ -3139,7 +3124,7 @@ class DocumentManager {
return array('ods', 'odt');
}
public static function is_folder_to_avoid($path) {
public static function is_folder_to_avoid($path, $is_certificate_mode = false) {
$folders_to_avoid = array(
'/HotPotatoes_files',
'/certificates',
@ -3154,10 +3139,12 @@ class DocumentManager {
return true;
}
if ($is_certificate_mode == false) {
//Certificate results
if (strstr($path, 'certificates')) {
return true;
}
}
//Admin setting for Hide/Show the folders of all users
if (api_get_setting('show_users_folders') == 'false') {
@ -3195,5 +3182,7 @@ class DocumentManager {
);
return $system_folders;
}
}
//end class DocumentManager

Loading…
Cancel
Save