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']; $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; continue;
} }

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

Loading…
Cancel
Save