Moves code from document.inc.php to document.lib.php

1.10.x
Julio Montoya 11 years ago
parent a5fc66dd0b
commit ef0eb9f4b2
  1. 2
      main/admin/access_url_add_usergroup_to_url.php
  2. 1
      main/admin/access_url_edit.php
  3. 2
      main/admin/add_students_to_session.php
  4. 2
      main/admin/add_teachers_to_session.php
  5. 1
      main/admin/settings.lib.php
  6. 1
      main/admin/skill_badge_create.php
  7. 1
      main/admin/skill_badge_list.php
  8. 2
      main/admin/special_exports.php
  9. 18
      main/auth/conditional_login/conditional_login.php
  10. 3
      main/auth/ldap/authldap.php
  11. 10
      main/auth/shibboleth/app/view/admin_login.php
  12. 2
      main/calendar/agenda.inc.php
  13. 1
      main/calendar/agenda.php
  14. 5
      main/calendar/download.php
  15. 2
      main/calendar/ical_export.php
  16. 4
      main/calendar/myagenda.inc.php
  17. 11
      main/conference/audiopost.php
  18. 12
      main/conference/checksession.php
  19. 2
      main/coursecopy/classes/CourseBuilder.class.php
  20. 1
      main/coursecopy/classes/CourseRestorer.class.php
  21. 2
      main/dashboard/index.php
  22. 7
      main/document/create_audio.php
  23. 3
      main/document/create_document.php
  24. 6
      main/document/create_draw.php
  25. 5
      main/document/create_paint.php
  26. 1036
      main/document/document.inc.php
  27. 47
      main/document/document.php
  28. 45
      main/document/document_lite.php
  29. 7
      main/document/edit_document.php
  30. 5
      main/document/edit_draw.php
  31. 5
      main/document/edit_paint.php
  32. 6
      main/document/record_audio.php
  33. 6
      main/document/record_audio_wami.php
  34. 7
      main/document/upload.php
  35. 7
      main/document/webcam_clip.php
  36. 7
      main/dropbox/dropbox_init.inc.php
  37. 8
      main/dropbox/index.php
  38. 5
      main/gradebook/gradebook_edit_all.php
  39. 2
      main/gradebook/gradebook_flatview.php
  40. 3
      main/inc/ajax/document.ajax.php
  41. 3
      main/inc/course_document.inc.php
  42. 5
      main/inc/lib/dashboard.lib.php
  43. 1044
      main/inc/lib/document.lib.php
  44. 3
      main/upload/upload.document.php
  45. 4
      main/work/work.lib.php

@ -12,8 +12,6 @@
$language_file = 'admin'; $language_file = 'admin';
$cidReset = true; $cidReset = true;
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php';
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
api_protect_global_admin_script(); api_protect_global_admin_script();

@ -8,7 +8,6 @@
$language_file = 'admin'; $language_file = 'admin';
$cidReset = true; $cidReset = true;
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
api_protect_global_admin_script(); api_protect_global_admin_script();

@ -12,8 +12,6 @@ $cidReset = true;
// including some necessary files // including some necessary files
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once '../inc/lib/xajax/xajax.inc.php';
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
// setting the section (for the tabs) // setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;

@ -12,8 +12,6 @@ $cidReset = true;
// including some necessary files // including some necessary files
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once '../inc/lib/xajax/xajax.inc.php';
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
// setting the section (for the tabs) // setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;

@ -1089,7 +1089,6 @@ function select_gradebook_default_grade_model_id() {
* @author Guillaume Viguier <guillaume.viguier@beeznest.com> * @author Guillaume Viguier <guillaume.viguier@beeznest.com>
*/ */
function update_gradebook_score_display_custom_values($values) { function update_gradebook_score_display_custom_values($values) {
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/scoredisplay.class.php';
$scoredisplay = ScoreDisplay::instance(); $scoredisplay = ScoreDisplay::instance();
$scores = $values['gradebook_score_display_custom_values_endscore']; $scores = $values['gradebook_score_display_custom_values_endscore'];
$displays = $values['gradebook_score_display_custom_values_displaytext']; $displays = $values['gradebook_score_display_custom_values_displaytext'];

@ -8,7 +8,6 @@
$cidReset = true; $cidReset = true;
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once '../inc/lib/fileUpload.lib.php';
if (!api_is_platform_admin() || api_get_setting('allow_skills_tool') !== 'true') { if (!api_is_platform_admin() || api_get_setting('allow_skills_tool') !== 'true') {
api_not_allowed(true); api_not_allowed(true);

@ -8,7 +8,6 @@
$cidReset = true; $cidReset = true;
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once '../inc/lib/fileUpload.lib.php';
if (!api_is_platform_admin() || api_get_setting('allow_skills_tool') !== 'true') { if (!api_is_platform_admin() || api_get_setting('allow_skills_tool') !== 'true') {
api_not_allowed(true); api_not_allowed(true);

@ -21,8 +21,6 @@ $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAd
api_protect_admin_script(true); api_protect_admin_script(true);
$nameTools = get_lang('SpecialExports'); $nameTools = get_lang('SpecialExports');
// include additional libraries
require_once '../document/document.inc.php';
// include additional libraries // include additional libraries
require_once '../coursecopy/classes/CourseBuilder.class.php'; require_once '../coursecopy/classes/CourseBuilder.class.php';
require_once '../coursecopy/classes/CourseArchiver.class.php'; require_once '../coursecopy/classes/CourseArchiver.class.php';

@ -2,15 +2,15 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/* /*
This script is included by local.inc.php to redirect users to some url if some conditions are satisfied. This script is included by local.inc.php to redirect users to some url if some conditions are satisfied.
* Please populate the $login_conditions array with a conditional function and an url. * Please populate the $login_conditions array with a conditional function and an url.
* If the conditional function returns true the user will be redirected to URL at login. * If the conditional function returns true the user will be redirected to URL at login.
* This array must be filled for this module to work. * This array must be filled for this module to work.
* This is an example asking the user to enter his phone number if it is empty. * This is an example asking the user to enter his phone number if it is empty.
* Note you can enter more than one condition in the array. They will be checked in the array order. * Note you can enter more than one condition in the array. They will be checked in the array order.
*/ */
/** /**
* Please implements the functions of the $login_conditions array. * Please implements the functions of the $login_conditions array.
* Each of these function will take a user array (user_id, username, password (crypted), auth_source, active, expiration_date) * Each of these function will take a user array (user_id, username, password (crypted), auth_source, active, expiration_date)
*/ */
$login_conditions = array(); $login_conditions = array();
@ -26,8 +26,6 @@ array_push($login_conditions, array(
// 'url' => api_get_path(WEB_PATH).'main/auth/conditional_login/complete_phone_number.php' // 'url' => api_get_path(WEB_PATH).'main/auth/conditional_login/complete_phone_number.php'
//)); //));
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
function dc_check_phone_number($user){ function dc_check_phone_number($user){
$uInfo = UserManager::get_user_info_by_id($user['user_id']); $uInfo = UserManager::get_user_info_by_id($user['user_id']);
if (empty($uInfo['phone'])) { if (empty($uInfo['phone'])) {
@ -37,12 +35,12 @@ function dc_check_phone_number($user){
} }
/** /**
* Checks if the user accepted or not the legal conditions * Checks if the user accepted or not the legal conditions
* *
* @param array $user * @param array $user
* @return boolean true if user pass, false otherwise * @return boolean true if user pass, false otherwise
*/ */
function check_platform_legal_conditions($user) { function check_platform_legal_conditions($user) {
if (api_get_setting('allow_terms_conditions') == 'true') { if (api_get_setting('allow_terms_conditions') == 'true') {
$term_and_condition_status = api_check_term_condition($user['user_id']); $term_and_condition_status = api_check_term_condition($user['user_id']);
// @todo not sure why we need the login password and update_term_status // @todo not sure why we need the login password and update_term_status

@ -206,7 +206,6 @@ function ldap_put_user_info_locally($login, $info_array) {
2. add info to Chamilo 2. add info to Chamilo
------------------------------------------------------------ */ ------------------------------------------------------------ */
require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
$language = api_get_setting('platformLanguage'); $language = api_get_setting('platformLanguage');
if (empty($language)) { $language = 'english'; } if (empty($language)) { $language = 'english'; }
$_userId = UserManager::create_user($prenom, $nom, $status, $_userId = UserManager::create_user($prenom, $nom, $status,
@ -644,4 +643,4 @@ function syncro_users() {
} else { } else {
//echo "<h3>Unable to connect to LDAP server</h3>"; //echo "<h3>Unable to connect to LDAP server</h3>";
} }
} }

@ -4,17 +4,15 @@ namespace Shibboleth;
/** /**
* Administratrive login. Useful when the standard login is not available anymore * Administratrive login. Useful when the standard login is not available anymore
* which is usually the case. * which is usually the case.
* *
* This page allow administrators to log into the application using the standard * This page allow administrators to log into the application using the standard
* Chamilo method when Shibboleth is not available. * Chamilo method when Shibboleth is not available.
* *
* @license see /license.txt * @license see /license.txt
* @author Laurent Opprecht <laurent@opprecht.info>, Nicolas Rod for the University of Geneva * @author Laurent Opprecht <laurent@opprecht.info>, Nicolas Rod for the University of Geneva
*/ */
$dir = dirname(__FILE__); $dir = dirname(__FILE__);
include_once("$dir/../../init.php"); include_once("$dir/../../init.php");
require_once api_get_path(LIBRARY_PATH).'userportal.lib.php';
ShibbolethController::instance()->admin_login();
ShibbolethController::instance()->admin_login();

@ -3535,8 +3535,6 @@ function show_add_form($id = '', $type = null)
*/ */
function agenda_import_ical($course_info, $file) function agenda_import_ical($course_info, $file)
{ {
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
$charset = api_get_system_encoding(); $charset = api_get_system_encoding();
$filepath = api_get_path(SYS_ARCHIVE_PATH).$file['name']; $filepath = api_get_path(SYS_ARCHIVE_PATH).$file['name'];
if (!@move_uploaded_file($file['tmp_name'], $filepath)) { if (!@move_uploaded_file($file['tmp_name'], $filepath)) {

@ -38,7 +38,6 @@ if (empty($action)) {
/* Resource linker */ /* Resource linker */
$_SESSION['source_type'] = 'Agenda'; $_SESSION['source_type'] = 'Agenda';
require_once '../resourcelinker/resourcelinker.inc.php'; require_once '../resourcelinker/resourcelinker.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
$group_id = api_get_group_id(); $group_id = api_get_group_id();
$eventId = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; $eventId = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$type = $event_type = isset($_GET['type']) ? $_GET['type'] : null; $type = $event_type = isset($_GET['type']) ? $_GET['type'] : null;

@ -17,7 +17,6 @@ session_cache_limiter('public');
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once 'agenda.inc.php'; require_once 'agenda.inc.php';
// IMPORTANT to avoid caching of documents // IMPORTANT to avoid caching of documents
@ -40,7 +39,7 @@ if (empty($course_id) || empty($doc_url)) {
$is_user_is_subscribed = CourseManager::is_user_subscribed_in_course($user_id, $course_info['code'], true, $session_id); $is_user_is_subscribed = CourseManager::is_user_subscribed_in_course($user_id, $course_info['code'], true, $session_id);
if (!api_is_allowed_to_edit() && !$is_user_is_subscribed) { if (!api_is_allowed_to_edit() && !$is_user_is_subscribed) {
api_not_allowed(); api_not_allowed();
} }
@ -75,7 +74,7 @@ $sql='SELECT filename FROM '.$tbl_agenda_attachment.'
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result)) { if (Database::num_rows($result)) {
$row = Database::fetch_array($result); $row = Database::fetch_array($result);
$title = str_replace(' ','_', $row['filename']); $title = str_replace(' ','_', $row['filename']);
if (Security::check_abs_path($full_file_name, api_get_path(SYS_COURSE_PATH).$course_info['path'].'/upload/calendar/')) { if (Security::check_abs_path($full_file_name, api_get_path(SYS_COURSE_PATH).$course_info['path'].'/upload/calendar/')) {
DocumentManager::file_send_for_download($full_file_name,TRUE, $title); DocumentManager::file_send_for_download($full_file_name,TRUE, $title);

@ -13,8 +13,6 @@ require_once '../inc/global.inc.php';
$this_section = SECTION_MYAGENDA; $this_section = SECTION_MYAGENDA;
api_block_anonymous_users(); api_block_anonymous_users();
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
// setting the name of the tool // setting the name of the tool
$nameTools = get_lang('MyAgenda'); $nameTools = get_lang('MyAgenda');

@ -16,9 +16,6 @@
*/ */
$setting_agenda_link = 'coursecode'; // valid values are coursecode and icon $setting_agenda_link = 'coursecode'; // valid values are coursecode and icon
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
/** /**
* This function retrieves all the agenda items of all the courses the user is subscribed to * This function retrieves all the agenda items of all the courses the user is subscribed to
*/ */
@ -717,7 +714,6 @@ function get_personal_agenda_items_between_dates($user_id, $date_start='', $date
// get agenda-items for every course // get agenda-items for every course
$courses = api_get_user_courses($user_id,false); $courses = api_get_user_courses($user_id,false);
require_once(api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
foreach ($courses as $id => $course) { foreach ($courses as $id => $course) {
$c = api_get_course_info($course['code']); $c = api_get_course_info($course['code']);
//databases of the courses //databases of the courses

@ -1,9 +1,6 @@
<?php <?php
/* See license terms in /license.txt */ /* See license terms in /license.txt */
//file_put_contents("result.txt", print_r($_POST, true));
//file_put_contents("result3.txt", print_r($_FILES, true));
//file_put_contents("result2.txt", print_r($_GET, true));
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
// check the request comes from our red5 server // check the request comes from our red5 server
@ -40,13 +37,9 @@ if($is_our_server)
$target = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/audio/'; $target = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/audio/';
$basename = basename( $_FILES['file']['name']); $basename = basename( $_FILES['file']['name']);
$target = $target . $basename ; $target = $target . $basename ;
if(!move_uploaded_file($_FILES['file']['tmp_name'], $target)) if(!move_uploaded_file($_FILES['file']['tmp_name'], $target)) {
{
error_log(__FILE__.':'.__LINE__.': File upload to '.$target.' failed',0); error_log(__FILE__.':'.__LINE__.': File upload to '.$target.' failed',0);
} } else {
else
{
require_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
$id = add_document($course_info,'/audio/'.$basename,'file',filesize($target),$basename); $id = add_document($course_info,'/audio/'.$basename,'file',filesize($target),$basename);
if($id !== false) if($id !== false)
{ {

@ -8,18 +8,6 @@ session_cache_limiter("none");
* This script gives information to the videoconference scripts (in OpenLaszlo) * This script gives information to the videoconference scripts (in OpenLaszlo)
* to use the right URL and ports for the videoconference. * to use the right URL and ports for the videoconference.
*/ */
require_once('../newscorm/learnpath.class.php');
if($debug>0) error_log('New LP - Included learnpath',0);
require_once('../newscorm/learnpathItem.class.php');
if($debug>0) error_log('New LP - Included learnpathItem',0);
require_once('../newscorm/scorm.class.php');
if($debug>0) error_log('New LP - Included scorm',0);
require_once('../newscorm/scormItem.class.php');
if($debug>0) error_log('New LP - Included scormItem',0);
require_once('../newscorm/aicc.class.php');
if($debug>0) error_log('New LP - Included aicc',0);
require_once('../newscorm/aiccItem.class.php');
if($debug>0) error_log('New LP - Included aiccItem',0);
require("../../main/inc/global.inc.php"); require("../../main/inc/global.inc.php");
require_once('get_translation.lib.php'); require_once('get_translation.lib.php');

@ -26,8 +26,6 @@ require_once 'Thematic.class.php';
require_once 'Attendance.class.php'; require_once 'Attendance.class.php';
require_once 'Work.class.php'; require_once 'Work.class.php';
require_once api_get_path(SYS_CODE_PATH).'exercice/question.class.php';
/** /**
* Class CourseBuilder * Class CourseBuilder
* Builds a course-object from a Chamilo-course. * Builds a course-object from a Chamilo-course.

@ -14,7 +14,6 @@ require_once 'CourseDescription.class.php';
require_once 'CourseCopyLearnpath.class.php'; require_once 'CourseCopyLearnpath.class.php';
require_once 'Survey.class.php'; require_once 'Survey.class.php';
require_once 'SurveyQuestion.class.php'; require_once 'SurveyQuestion.class.php';
require_once api_get_path(SYS_CODE_PATH).'exercice/question.class.php';
require_once 'Glossary.class.php'; require_once 'Glossary.class.php';
require_once 'wiki.class.php'; require_once 'wiki.class.php';
require_once 'Thematic.class.php'; require_once 'Thematic.class.php';

@ -11,8 +11,6 @@ $cidReset = true;
// including files // including files
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'dashboard.lib.php';
require_once api_get_path(LIBRARY_PATH).'app_view.php';
require_once 'dashboard_controller.php'; require_once 'dashboard_controller.php';
require_once 'block.class.php'; require_once 'block.class.php';

@ -17,9 +17,6 @@ require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'document/createaudio'; $_SESSION['whereami'] = 'document/createaudio';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
require_once 'document.inc.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
$nameTools = get_lang('CreateAudio'); $nameTools = get_lang('CreateAudio');
api_protect_course_script(); api_protect_course_script();
@ -88,7 +85,9 @@ if (!$is_allowed_in_course) {
} }
if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) { if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))
) {
api_not_allowed(true); api_not_allowed(true);
} }

@ -142,9 +142,6 @@ function InnerDialogLoaded() {
}); });
</script>'; </script>';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
//I'm in the certification module? //I'm in the certification module?
$is_certificate_mode = false; $is_certificate_mode = false;

@ -18,9 +18,6 @@ require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'document/createdraw'; $_SESSION['whereami'] = 'document/createdraw';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
$nameTools = get_lang('Draw'); $nameTools = get_lang('Draw');
api_protect_course_script(); api_protect_course_script();
@ -93,7 +90,8 @@ if (!$is_allowed_in_course) {
api_not_allowed(true); api_not_allowed(true);
} }
if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir), api_get_session_id()))) { if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir), api_get_session_id()))) {
api_not_allowed(true); api_not_allowed(true);
} }

@ -17,8 +17,6 @@ require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'document/createpaint'; $_SESSION['whereami'] = 'document/createpaint';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
require_once 'document.inc.php';
$nameTools = get_lang('PhotoRetouching'); $nameTools = get_lang('PhotoRetouching');
api_protect_course_script(); api_protect_course_script();
@ -93,7 +91,8 @@ if (!$is_allowed_in_course) {
api_not_allowed(true); api_not_allowed(true);
} }
if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir),api_get_session_id()))) { if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
DocumentManager::is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir),api_get_session_id()))) {
api_not_allowed(true); api_not_allowed(true);
} }

File diff suppressed because it is too large Load Diff

@ -37,7 +37,6 @@ $to_user_id = null;
$parent_id = null; $parent_id = null;
$message = null; $message = null;
require_once 'document.inc.php';
$lib_path = api_get_path(LIBRARY_PATH); $lib_path = api_get_path(LIBRARY_PATH);
api_protect_course_script(true); api_protect_course_script(true);
@ -181,8 +180,8 @@ switch ($action) {
case 'delete_item': case 'delete_item':
if ($is_allowed_to_edit || if ($is_allowed_to_edit ||
$group_member_with_upload_rights || $group_member_with_upload_rights ||
is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) || DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) ||
is_my_shared_folder(api_get_user_id(), $moveTo, $sessionId) DocumentManager::is_my_shared_folder(api_get_user_id(), $moveTo, $sessionId)
) { ) {
if (isset($_GET['deleteid'])) { if (isset($_GET['deleteid'])) {
if (!$is_allowed_to_edit) { if (!$is_allowed_to_edit) {
@ -305,8 +304,8 @@ switch ($action) {
} }
//filter when I am into shared folder, I can download only my shared folder //filter when I am into shared folder, I can download only my shared folder
if (is_any_user_shared_folder($document_data['path'], $sessionId)) { if (DocumentManager::is_any_user_shared_folder($document_data['path'], $sessionId)) {
if (is_my_shared_folder(api_get_user_id(), $document_data['path'], $sessionId) if (DocumentManager::is_my_shared_folder(api_get_user_id(), $document_data['path'], $sessionId)
|| api_is_allowed_to_edit() || api_is_allowed_to_edit()
|| api_is_platform_admin()) { || api_is_platform_admin()) {
require 'downloadfolder.inc.php'; require 'downloadfolder.inc.php';
@ -941,8 +940,8 @@ $moveForm = null;
//Only teacher and all users into their group and each user into his/her shared folder //Only teacher and all users into their group and each user into his/her shared folder
if ($is_allowed_to_edit || if ($is_allowed_to_edit ||
$group_member_with_upload_rights || $group_member_with_upload_rights ||
is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) || DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) ||
is_my_shared_folder(api_get_user_id(), $moveTo, $sessionId) DocumentManager::is_my_shared_folder(api_get_user_id(), $moveTo, $sessionId)
) { ) {
if (isset($_GET['move']) && $_GET['move'] != '') { if (isset($_GET['move']) && $_GET['move'] != '') {
$my_get_move = intval($_REQUEST['move']); $my_get_move = intval($_REQUEST['move']);
@ -975,7 +974,7 @@ if ($is_allowed_to_edit ||
); );
// filter if is my shared folder. TODO: move this code to build_move_to_selector function // filter if is my shared folder. TODO: move this code to build_move_to_selector function
if (is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) && !$is_allowed_to_edit) { if (DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) && !$is_allowed_to_edit) {
//only main user shared folder //only main user shared folder
$main_user_shared_folder_main = '/shared_folder/sf_user_'.api_get_user_id(); $main_user_shared_folder_main = '/shared_folder/sf_user_'.api_get_user_id();
$main_user_shared_folder_sub = '/shared_folder\/sf_user_'.api_get_user_id().'\//'; //all subfolders $main_user_shared_folder_sub = '/shared_folder\/sf_user_'.api_get_user_id().'\//'; //all subfolders
@ -988,7 +987,7 @@ if ($is_allowed_to_edit ||
} }
$moveForm .= '<legend>'.get_lang('Move').'</legend>'; $moveForm .= '<legend>'.get_lang('Move').'</legend>';
$moveForm .= build_move_to_selector( $moveForm .= DocumentManager::build_move_to_selector(
$user_shared_folders, $user_shared_folders,
$move_path, $move_path,
$my_get_move, $my_get_move,
@ -996,7 +995,7 @@ if ($is_allowed_to_edit ||
); );
} else { } else {
$moveForm .= '<legend>'.get_lang('Move').'</legend>'; $moveForm .= '<legend>'.get_lang('Move').'</legend>';
$moveForm .= build_move_to_selector( $moveForm .= DocumentManager::build_move_to_selector(
$folders, $folders,
$move_path, $move_path,
$my_get_move, $my_get_move,
@ -1101,7 +1100,7 @@ if ($is_allowed_to_edit ||
//Only teacher and all users into their group //Only teacher and all users into their group
if ($is_allowed_to_edit || if ($is_allowed_to_edit ||
$group_member_with_upload_rights || $group_member_with_upload_rights ||
is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) { ) {
if (isset($_POST['action']) && isset($_POST['ids'])) { if (isset($_POST['action']) && isset($_POST['ids'])) {
$files = $_POST['ids']; $files = $_POST['ids'];
@ -1218,7 +1217,7 @@ $dirForm = null;
//Only teacher and all users into their group and any user into his/her shared folder //Only teacher and all users into their group and any user into his/her shared folder
if ($is_allowed_to_edit || if ($is_allowed_to_edit ||
$group_member_with_upload_rights || $group_member_with_upload_rights ||
is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) { ) {
// Create directory with $_POST data // Create directory with $_POST data
if (isset($_POST['create_dir']) && $_POST['dirname'] != '') { if (isset($_POST['create_dir']) && $_POST['dirname'] != '') {
@ -1343,7 +1342,7 @@ $templateForm = null;
//Only teacher and all users into their group //Only teacher and all users into their group
if ($is_allowed_to_edit || if ($is_allowed_to_edit ||
$group_member_with_upload_rights || $group_member_with_upload_rights ||
is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) { ) {
if (isset($_GET['add_as_template']) && !isset($_POST['create_template'])) { if (isset($_GET['add_as_template']) && !isset($_POST['create_template'])) {
@ -1532,7 +1531,7 @@ $column_show = array();
if ($is_allowed_to_edit || if ($is_allowed_to_edit ||
$group_member_with_upload_rights || $group_member_with_upload_rights ||
is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) { ) {
// TODO:check enable more options for shared folders // TODO:check enable more options for shared folders
/* CREATE NEW DOCUMENT OR NEW DIRECTORY / GO TO UPLOAD / DOWNLOAD ZIPPED FOLDER */ /* CREATE NEW DOCUMENT OR NEW DIRECTORY / GO TO UPLOAD / DOWNLOAD ZIPPED FOLDER */
@ -1702,12 +1701,12 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
$user_info = UserManager::get_user_info_by_id($document_data['insert_user_id']); $user_info = UserManager::get_user_info_by_id($document_data['insert_user_id']);
$user_name = api_get_person_name($user_info['firstname'], $user_info['lastname']); $user_name = api_get_person_name($user_info['firstname'], $user_info['lastname']);
$user_link = '<div class="document_owner">'. $user_link = '<div class="document_owner">'.
get_lang('Owner').': '.display_user_link_document($document_data['insert_user_id'], $user_name).'</div>'; get_lang('Owner').': '.DocumentManager::display_user_link_document($document_data['insert_user_id'], $user_name).'</div>';
} }
} }
// Icons (clickable) // Icons (clickable)
$row[] = create_document_link($document_data, true, $count, $is_visible); $row[] = DocumentManager::create_document_link($document_data, true, $count, $is_visible);
$path_info = pathinfo($document_data['path']); $path_info = pathinfo($document_data['path']);
@ -1719,7 +1718,7 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
$session_img = api_get_session_image($document_data['session_id'], $_user['status']); $session_img = api_get_session_image($document_data['session_id'], $_user['status']);
// Document title with link // Document title with link
$row[] = create_document_link($document_data, false, null, $is_visible). $row[] = DocumentManager::create_document_link($document_data, false, null, $is_visible).
$session_img.'<br />'.$invisibility_span_open. $session_img.'<br />'.$invisibility_span_open.
'<i>'.nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, $charset)).'</i>'. '<i>'.nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, $charset)).'</i>'.
$invisibility_span_close. $invisibility_span_close.
@ -1743,12 +1742,12 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
// Admins get an edit column // Admins get an edit column
if ($is_allowed_to_edit || $group_member_with_upload_rights || if ($is_allowed_to_edit || $group_member_with_upload_rights ||
is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) { ) {
$is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false; $is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false;
// If readonly, check if it the owner of the file or if the user is an admin // If readonly, check if it the owner of the file or if the user is an admin
if ($document_data['insert_user_id'] == api_get_user_id() || api_is_platform_admin()) { if ($document_data['insert_user_id'] == api_get_user_id() || api_is_platform_admin()) {
$edit_icons = build_edit_icons( $edit_icons = DocumentManager::build_edit_icons(
$document_data, $document_data,
$key, $key,
$is_template, $is_template,
@ -1756,7 +1755,7 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
$is_visible $is_visible
); );
} else { } else {
$edit_icons = build_edit_icons( $edit_icons = DocumentManager::build_edit_icons(
$document_data, $document_data,
$key, $key,
$is_template, $is_template,
@ -1799,7 +1798,7 @@ if (!is_null($documentAndFolders)) {
) )
) { ) {
//for student does not show icon into other shared folder, and does not show into main path (root) //for student does not show icon into other shared folder, and does not show into main path (root)
if (is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) if (DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
&& $curdirpath != '/' && $curdirpath != '/'
|| api_is_allowed_to_edit() || api_is_allowed_to_edit()
|| api_is_platform_admin() || api_is_platform_admin()
@ -1844,7 +1843,7 @@ if (isset($_GET['createdir']) && isset($_POST['dirname']) && $_POST['dirname'] !
$selector = null; $selector = null;
if (!$is_certificate_mode) { if (!$is_certificate_mode) {
$selector = build_directory_selector( $selector = DocumentManager::build_directory_selector(
$folders, $folders,
$document_id, $document_id,
(isset($group_properties['directory']) ? $group_properties['directory'] : array()), (isset($group_properties['directory']) ? $group_properties['directory'] : array()),
@ -1865,7 +1864,7 @@ $column_show[] = 1;
if ($is_allowed_to_edit if ($is_allowed_to_edit
|| $group_member_with_upload_rights || $group_member_with_upload_rights
|| is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) || DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) { ) {
$column_show[] = 1; $column_show[] = 1;
} }
@ -1924,7 +1923,7 @@ $table->set_header($column++, get_lang('Date'), true, array('style' => 'width:15
// Admins get an edit column // Admins get an edit column
if ($is_allowed_to_edit if ($is_allowed_to_edit
|| $group_member_with_upload_rights || $group_member_with_upload_rights
|| is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)) { || DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)) {
$table->set_header($column++, get_lang('Actions'), false, array('class' => 'td_actions')); $table->set_header($column++, get_lang('Actions'), false, array('class' => 'td_actions'));
} }

@ -17,7 +17,6 @@ $language_file = array('document', 'slideshow', 'gradebook', 'create_course');
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
require_once 'document.inc.php';
$lib_path = api_get_path(LIBRARY_PATH); $lib_path = api_get_path(LIBRARY_PATH);
api_protect_course_script(true); api_protect_course_script(true);
@ -88,8 +87,8 @@ switch ($action) {
$document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id()); $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
//filter when I am into shared folder, I can donwload only my shared folder //filter when I am into shared folder, I can donwload only my shared folder
if (is_any_user_shared_folder($document_data['path'], $session_id)) { if (DocumentManager::is_any_user_shared_folder($document_data['path'], $session_id)) {
if (is_my_shared_folder(api_get_user_id(), $document_data['path'], $session_id) || api_is_allowed_to_edit() || api_is_platform_admin()){ if (DocumentManager::is_my_shared_folder(api_get_user_id(), $document_data['path'], $session_id) || api_is_allowed_to_edit() || api_is_platform_admin()){
require 'downloadfolder.inc.php'; require 'downloadfolder.inc.php';
} }
} else { } else {
@ -350,7 +349,9 @@ if (isset($_GET['action']) && $_GET['action'] == 'copytomyfiles' && api_get_sett
/* MOVE FILE OR DIRECTORY */ /* MOVE FILE OR DIRECTORY */
//Only teacher and all users into their group and each user into his/her shared folder //Only teacher and all users into their group and each user into his/her shared folder
if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id) || is_my_shared_folder(api_get_user_id(), Security::remove_XSS($_POST['move_to']), $session_id)) { if ($is_allowed_to_edit || $group_member_with_upload_rights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id) ||
DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($_POST['move_to']), $session_id)) {
if (isset($_GET['move']) && $_GET['move'] != '') { if (isset($_GET['move']) && $_GET['move'] != '') {
$my_get_move = intval($_REQUEST['move']); $my_get_move = intval($_REQUEST['move']);
@ -373,7 +374,7 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
$folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit || $group_member_with_upload_rights); $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit || $group_member_with_upload_rights);
//filter if is my shared folder. TODO: move this code to build_move_to_selector function //filter if is my shared folder. TODO: move this code to build_move_to_selector function
if (is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id) && !$is_allowed_to_edit){ if (DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id) && !$is_allowed_to_edit){
$main_user_shared_folder_main = '/shared_folder/sf_user_'.api_get_user_id();//only main user shared folder $main_user_shared_folder_main = '/shared_folder/sf_user_'.api_get_user_id();//only main user shared folder
$main_user_shared_folder_sub = '/shared_folder\/sf_user_'.api_get_user_id().'\//';//all subfolders $main_user_shared_folder_sub = '/shared_folder\/sf_user_'.api_get_user_id().'\//';//all subfolders
$user_shared_folders=array(); $user_shared_folders=array();
@ -384,11 +385,11 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
} }
} }
echo '<legend>'.get_lang('Move').'</legend>'; echo '<legend>'.get_lang('Move').'</legend>';
echo build_move_to_selector($user_shared_folders, $move_path, $my_get_move, $group_properties['directory']); echo DocumentManager::build_move_to_selector($user_shared_folders, $move_path, $my_get_move, $group_properties['directory']);
} else { } else {
echo '<legend>'.get_lang('Move').'</legend>'; echo '<legend>'.get_lang('Move').'</legend>';
echo build_move_to_selector($folders, $move_path, $my_get_move, $group_properties['directory']); echo DocumentManager::build_move_to_selector($folders, $move_path, $my_get_move, $group_properties['directory']);
} }
} }
} }
@ -459,7 +460,8 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
/* DELETE FILE OR DIRECTORY */ /* DELETE FILE OR DIRECTORY */
//Only teacher and all users into their group //Only teacher and all users into their group
if($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)){ if($is_allowed_to_edit || $group_member_with_upload_rights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)){
if (isset($_GET['delete'])) { if (isset($_GET['delete'])) {
if (!$is_allowed_to_edit) { if (!$is_allowed_to_edit) {
if (api_is_coach()) { if (api_is_coach()) {
@ -512,11 +514,11 @@ if($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folde
/* CREATE DIRECTORY */ /* CREATE DIRECTORY */
//Only teacher and all users into their group and any user into his/her shared folder //Only teacher and all users into their group and any user into his/her shared folder
if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) { if ($is_allowed_to_edit || $group_member_with_upload_rights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) {
// Create directory with $_POST data // Create directory with $_POST data
if (isset($_POST['create_dir']) && $_POST['dirname'] != '') { if (isset($_POST['create_dir']) && $_POST['dirname'] != '') {
// Needed for directory creation // Needed for directory creation
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
$post_dir_name = $_POST['dirname']; $post_dir_name = $_POST['dirname'];
if ($post_dir_name == '../' || $post_dir_name == '.' || $post_dir_name == '..') { if ($post_dir_name == '../' || $post_dir_name == '.' || $post_dir_name == '..') {
@ -549,7 +551,7 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
// Show them the form for the directory name // Show them the form for the directory name
if (isset($_GET['createdir'])) { if (isset($_GET['createdir'])) {
echo create_dir_form($document_id); echo DocumentManager::create_dir_form($document_id);
} }
} }
@ -623,8 +625,6 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
} }
// Upload the file // Upload the file
if (!empty($_FILES['template_image']['name'])) { if (!empty($_FILES['template_image']['name'])) {
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
$upload_ok = process_uploaded_file($_FILES['template_image']); $upload_ok = process_uploaded_file($_FILES['template_image']);
if ($upload_ok) { if ($upload_ok) {
@ -699,7 +699,7 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
$row = array(); $row = array();
$row['id'] = $document_data['id']; $row['id'] = $document_data['id'];
//$row['type'] = $document_data['filetype']; //$row['type'] = $document_data['filetype'];
$row['type'] = create_document_link($document_data, true, $count, $is_visible); $row['type'] = DocumentManager::create_document_link($document_data, true, $count, $is_visible);
// If the item is invisible, wrap it in a span with class invisible // If the item is invisible, wrap it in a span with class invisible
@ -720,7 +720,7 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
$document_name = basename($document_data['path']); $document_name = basename($document_data['path']);
} }
$row['name'] = $document_name; $row['name'] = $document_name;
$row['name'] = create_document_link($document_data, false, null, $is_visible).$session_img.'<br />'.$invisibility_span_open.'<i>'.nl2br(htmlspecialchars($document_data['comment'],ENT_QUOTES,$charset)).'</i>'.$invisibility_span_close.$user_link; $row['name'] = DocumentManager::create_document_link($document_data, false, null, $is_visible).$session_img.'<br />'.$invisibility_span_open.'<i>'.nl2br(htmlspecialchars($document_data['comment'],ENT_QUOTES,$charset)).'</i>'.$invisibility_span_close.$user_link;
// Data for checkbox // Data for checkbox
if (($is_allowed_to_edit || $group_member_with_upload_rights) && count($docs_and_folders) > 1) { if (($is_allowed_to_edit || $group_member_with_upload_rights) && count($docs_and_folders) > 1) {
@ -754,12 +754,12 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
if (!empty($document_data['insert_user_id'])) { if (!empty($document_data['insert_user_id'])) {
$user_info = UserManager::get_user_info_by_id($document_data['insert_user_id']); $user_info = UserManager::get_user_info_by_id($document_data['insert_user_id']);
$user_name = api_get_person_name($user_info['firstname'], $user_info['lastname']); $user_name = api_get_person_name($user_info['firstname'], $user_info['lastname']);
$user_link = '<div class="document_owner">'.get_lang('Owner').': '.display_user_link_document($document_data['insert_user_id'], $user_name).'</div>'; $user_link = '<div class="document_owner">'.get_lang('Owner').': '.DocumentManager::display_user_link_document($document_data['insert_user_id'], $user_name).'</div>';
} }
} }
// Icons (clickable) // Icons (clickable)
$row[] = create_document_link($document_data, true, $count, $is_visible); $row[] = DocumentManager::create_document_link($document_data, true, $count, $is_visible);
$path_info = pathinfo($document_data['path']); $path_info = pathinfo($document_data['path']);
@ -771,7 +771,7 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
$session_img = api_get_session_image($document_data['session_id'], $_user['status']); $session_img = api_get_session_image($document_data['session_id'], $_user['status']);
// Document title with link // Document title with link
$row[] = create_document_link($document_data, false, null, $is_visible).$session_img.'<br />'.$invisibility_span_open.'<i>'.nl2br(htmlspecialchars($document_data['comment'],ENT_QUOTES,$charset)).'</i>'.$invisibility_span_close.$user_link; $row[] = DocumentManager::create_document_link($document_data, false, null, $is_visible).$session_img.'<br />'.$invisibility_span_open.'<i>'.nl2br(htmlspecialchars($document_data['comment'],ENT_QUOTES,$charset)).'</i>'.$invisibility_span_close.$user_link;
// Comments => display comment under the document name // Comments => display comment under the document name
$display_size = format_file_size($size); $display_size = format_file_size($size);
@ -785,13 +785,14 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
$row[] = $invisibility_span_open.$display_date.$invisibility_span_close; $row[] = $invisibility_span_open.$display_date.$invisibility_span_close;
// Admins get an edit column // Admins get an edit column
if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) { if ($is_allowed_to_edit || $group_member_with_upload_rights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) {
$is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false; $is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false;
// If readonly, check if it the owner of the file or if the user is an admin // If readonly, check if it the owner of the file or if the user is an admin
if ($document_data['insert_user_id'] == api_get_user_id() || api_is_platform_admin()) { if ($document_data['insert_user_id'] == api_get_user_id() || api_is_platform_admin()) {
$edit_icons = build_edit_icons($document_data, $key, $is_template, 0, $is_visible); $edit_icons = DocumentManager::build_edit_icons($document_data, $key, $is_template, 0, $is_visible);
} else { } else {
$edit_icons = build_edit_icons($document_data, $key, $is_template, $document_data['readonly'], $is_visible); $edit_icons = DocumentManager::build_edit_icons($document_data, $key, $is_template, $document_data['readonly'], $is_visible);
} }
$row[] = $edit_icons; $row[] = $edit_icons;
} }
@ -855,7 +856,7 @@ if (!is_null($docs_and_folders)) {
if (!$is_certificate_mode && $total_size != 0 && (api_get_setting('students_download_folders') == 'true' || api_is_allowed_to_edit() || api_is_platform_admin())) { if (!$is_certificate_mode && $total_size != 0 && (api_get_setting('students_download_folders') == 'true' || api_is_allowed_to_edit() || api_is_platform_admin())) {
//for student does not show icon into other shared folder, and does not show into main path (root) //for student does not show icon into other shared folder, and does not show into main path (root)
if (is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id) && $curdirpath!='/' || api_is_allowed_to_edit() || api_is_platform_admin()) { if (DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id) && $curdirpath!='/' || api_is_allowed_to_edit() || api_is_platform_admin()) {
$link = '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=downloadfolder&amp;id='.$document_id.'">'.Display::return_icon('save_pack.png', get_lang('Save').' (ZIP)','',ICON_SIZE_MEDIUM).'</a>'; $link = '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=downloadfolder&amp;id='.$document_id.'">'.Display::return_icon('save_pack.png', get_lang('Save').' (ZIP)','',ICON_SIZE_MEDIUM).'</a>';
} }
} }

@ -69,8 +69,6 @@ $_SESSION['whereami'] = 'document/create';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
$lib_path = api_get_path(LIBRARY_PATH); $lib_path = api_get_path(LIBRARY_PATH);
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
$course_info = api_get_course_info(); $course_info = api_get_course_info();
$group_id = api_get_group_id(); $group_id = api_get_group_id();
@ -143,7 +141,8 @@ if ($is_certificate_mode) {
$html_editor_config['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir; $html_editor_config['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir;
} }
$is_allowed_to_edit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights']|| is_my_shared_folder(api_get_user_id(), $dir, $sessionId); $is_allowed_to_edit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights']||
DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $sessionId);
$noPHP_SELF = true; $noPHP_SELF = true;
/* Other initialization code */ /* Other initialization code */
@ -398,7 +397,7 @@ if ($owner_id == api_get_user_id() ||
} }
} }
if (!$group_document && !is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) { if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) {
$metadata_link = '<a href="../metadata/index.php?eid='.urlencode('Document.'.$document_data['id']).'">'.get_lang('AddMetadata').'</a>'; $metadata_link = '<a href="../metadata/index.php?eid='.urlencode('Document.'.$document_data['id']).'">'.get_lang('AddMetadata').'</a>';
//Updated on field //Updated on field

@ -17,8 +17,6 @@ require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'document/editdraw'; $_SESSION['whereami'] = 'document/editdraw';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
api_protect_course_script(); api_protect_course_script();
api_block_anonymous_users(); api_block_anonymous_users();
@ -110,7 +108,8 @@ if (empty($document_data['parents'])) {
} }
} }
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
if (!$is_allowedToEdit) { if (!$is_allowedToEdit) {
api_not_allowed(true); api_not_allowed(true);

@ -17,8 +17,6 @@ require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'document/editpaint'; $_SESSION['whereami'] = 'document/editpaint';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
api_protect_course_script(); api_protect_course_script();
api_block_anonymous_users(); api_block_anonymous_users();
$groupId = api_get_group_id(); $groupId = api_get_group_id();
@ -115,7 +113,8 @@ if (empty($document_data['parents'])) {
} }
} }
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
if (!$is_allowedToEdit) { if (!$is_allowedToEdit) {
api_not_allowed(true); api_not_allowed(true);

@ -18,9 +18,6 @@ require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'document/voicerecord'; $_SESSION['whereami'] = 'document/voicerecord';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
$nameTools = get_lang('VoiceRecord'); $nameTools = get_lang('VoiceRecord');
api_protect_course_script(); api_protect_course_script();
@ -84,7 +81,8 @@ if (!$is_allowed_in_course) {
api_not_allowed(true); api_not_allowed(true);
} }
if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) { if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) {
api_not_allowed(true); api_not_allowed(true);
} }

@ -18,9 +18,6 @@ require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'document/voicerecord'; $_SESSION['whereami'] = 'document/voicerecord';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
$nameTools = get_lang('VoiceRecord'); $nameTools = get_lang('VoiceRecord');
api_protect_course_script(); api_protect_course_script();
@ -91,7 +88,8 @@ if (!$is_allowed_in_course) {
api_not_allowed(true); api_not_allowed(true);
} }
if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) { if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) {
api_not_allowed(true); api_not_allowed(true);
} }

@ -40,9 +40,7 @@ $language_file = array('document','gradebook');
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
// Including additional libraries // Including additional libraries
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
require_once 'document.inc.php';
// Adding extra javascript to the form // Adding extra javascript to the form
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui', 'jquery-upload')); $htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui', 'jquery-upload'));
@ -150,7 +148,8 @@ if (!empty($groupId)) {
} else { } else {
api_not_allowed(true); api_not_allowed(true);
} }
} elseif ($is_allowed_to_edit || is_my_shared_folder(api_get_user_id(), $path, api_get_session_id())) { } elseif ($is_allowed_to_edit ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $path, api_get_session_id())) {
} else { } else {
// No course admin and no group member... // No course admin and no group member...
@ -239,7 +238,7 @@ echo '</div>';
// Form to select directory // Form to select directory
$folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit); $folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit);
if (!$is_certificate_mode) { if (!$is_certificate_mode) {
echo build_directory_selector( echo DocumentManager::build_directory_selector(
$folders, $folders,
$document_id, $document_id,
(isset($group_properties['directory']) ? $group_properties['directory'] : array()) (isset($group_properties['directory']) ? $group_properties['directory'] : array())

@ -17,10 +17,6 @@ require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'document/webcamclip'; $_SESSION['whereami'] = 'document/webcamclip';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
$nameTools = get_lang('WebCamClip'); $nameTools = get_lang('WebCamClip');
api_protect_course_script(); api_protect_course_script();
@ -91,7 +87,8 @@ if (!$is_allowed_in_course) {
api_not_allowed(true); api_not_allowed(true);
} }
if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) { if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) {
api_not_allowed(true); api_not_allowed(true);
} }

@ -142,13 +142,6 @@ require_once 'dropbox_functions.inc.php';
// protecting the script // protecting the script
api_protect_course_script(); api_protect_course_script();
/* Libraries */
// including some libraries that are also used in the documents tool
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php'; // we use a function build_document_icon_tag
/* Virtual course support */
$user_id = api_get_user_id(); $user_id = api_get_user_id();
$course_code = api_get_course_id(); $course_code = api_get_course_id();
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);

@ -364,7 +364,7 @@ if ($action != 'add') {
} }
$link_open = '<a href="dropbox_download.php?'.api_get_cidreq().'&amp;id='.$dropbox_file->id.'">'; $link_open = '<a href="dropbox_download.php?'.api_get_cidreq().'&amp;id='.$dropbox_file->id.'">';
$dropbox_file_data[] = $link_open.build_document_icon_tag('file', $dropbox_file->title).'</a>'; $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
$dropbox_file_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download">'.Display::return_icon('save.png', get_lang('Download'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a>'.$new_icon.'<br />'.$dropbox_file->description; $dropbox_file_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download">'.Display::return_icon('save.png', get_lang('Download'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a>'.$new_icon.'<br />'.$dropbox_file->description;
$file_size = $dropbox_file->filesize; $file_size = $dropbox_file->filesize;
$dropbox_file_data[] = format_file_size($file_size); $dropbox_file_data[] = format_file_size($file_size);
@ -411,7 +411,7 @@ if ($action != 'add') {
$dropbox_category_data[] = $category['cat_id']; $dropbox_category_data[] = $category['cat_id'];
// The icon of the category // The icon of the category
$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'">'; $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'">';
$dropbox_category_data[] = $link_open.build_document_icon_tag('folder', $category['cat_name']).'</a>'; $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', $category['cat_name']).'</a>';
$dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>'; $dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>';
$dropbox_category_data[] = ''; $dropbox_category_data[] = '';
$dropbox_category_data[] = ''; $dropbox_category_data[] = '';
@ -525,7 +525,7 @@ if ($action != 'add') {
if ($view_dropbox_category_sent == $dropbox_file->category) { if ($view_dropbox_category_sent == $dropbox_file->category) {
$dropbox_file_data[] = $dropbox_file->id; $dropbox_file_data[] = $dropbox_file->id;
$link_open = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'; $link_open = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
$dropbox_file_data[] = $link_open.build_document_icon_tag('file', $dropbox_file->title).'</a>'; $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
$dropbox_file_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download">'.Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a><br />'.$dropbox_file->description; $dropbox_file_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download">'.Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a><br />'.$dropbox_file->description;
$file_size = $dropbox_file->filesize; $file_size = $dropbox_file->filesize;
$dropbox_file_data[] = format_file_size($file_size); $dropbox_file_data[] = format_file_size($file_size);
@ -571,7 +571,7 @@ if ($action != 'add') {
$moveList[$category['cat_id']] = $category['cat_name']; $moveList[$category['cat_id']] = $category['cat_name'];
$dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear. $dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear.
$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$category['cat_id'].'&amp;view='.$view.'">'; $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$category['cat_id'].'&amp;view='.$view.'">';
$dropbox_category_data[] = $link_open.build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>'; $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>';
$dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>'; $dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>';
//$dropbox_category_data[] = ''; //$dropbox_category_data[] = '';
$dropbox_category_data[] = ''; $dropbox_category_data[] = '';

@ -63,13 +63,8 @@ $submitted = isset($_POST['submitted'])?$_POST['submitted']:'';
if ($submitted==1) { if ($submitted==1) {
Display :: display_confirmation_message(get_lang('GradebookWeightUpdated')) . '<br /><br />'; Display :: display_confirmation_message(get_lang('GradebookWeightUpdated')) . '<br /><br />';
if (isset($_POST['evaluation'])) { if (isset($_POST['evaluation'])) {
require_once 'lib/be/evaluation.class.php';
$eval_log = new Evaluation(); $eval_log = new Evaluation();
} }
if (isset($_POST['link'])) {
require_once 'lib/be/abstractlink.class.php';
//$eval_link_log = new AbstractLink();
}
} }
$output=''; $output='';

@ -206,8 +206,6 @@ if (!empty($_GET['export_report']) && $_GET['export_report'] == 'export_report')
if (!api_is_allowed_to_edit(false, false) and !api_is_course_tutor()) { if (!api_is_allowed_to_edit(false, false) and !api_is_course_tutor()) {
$user_id = api_get_user_id(); $user_id = api_get_user_id();
} }
require_once 'gradebook_result.class.php';
$printable_data = GradebookUtils::get_printable_data( $printable_data = GradebookUtils::get_printable_data(
$cat[0], $cat[0],
$users, $users,

@ -4,7 +4,6 @@
* Responses to AJAX calls for the document upload * Responses to AJAX calls for the document upload
*/ */
require_once '../global.inc.php'; require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
$action = $_REQUEST['a']; $action = $_REQUEST['a'];
switch ($action) { switch ($action) {
@ -19,7 +18,7 @@ switch ($action) {
} else { } else {
exit; exit;
} }
} elseif ($is_allowed_to_edit || is_my_shared_folder(api_get_user_id(), $_POST['curdirpath'], api_get_session_id())) { } elseif ($is_allowed_to_edit || DocumentManager::is_my_shared_folder(api_get_user_id(), $_POST['curdirpath'], api_get_session_id())) {
} else { } else {
// No course admin and no group member... // No course admin and no group member...
exit; exit;

@ -9,7 +9,6 @@ require 'global.inc.php';
/* Libraries */ /* Libraries */
require_once api_get_path(LIBRARY_PATH).'course_document.lib.php'; require_once api_get_path(LIBRARY_PATH).'course_document.lib.php';
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
//if(!$is_in_admin){ //if(!$is_in_admin){
if (!api_is_platform_admin()){ if (!api_is_platform_admin()){
@ -201,7 +200,7 @@ if ($docs_and_folders) {
} }
*/ */
// icons with hyperlinks // icons with hyperlinks
$row[]= '<a href="#" onclick="javascript: OpenFile(\''.$http_www.'/'.$id['title'].'\', \''.$sType.'\');return false;">'.build_document_icon_tag($id['filetype'],$id['path']).'</a>'; $row[]= '<a href="#" onclick="javascript: OpenFile(\''.$http_www.'/'.$id['title'].'\', \''.$sType.'\');return false;">'.DocumentManager::build_document_icon_tag($id['filetype'],$id['path']).'</a>';
//document title with hyperlink //document title with hyperlink
$row[] = '<a href="#" onclick="javascript: OpenFile(\''.$http_www.'/'.$id['title'].'\', \''.$sType.'\');return false;">'.$id['title'].'</a>'; $row[] = '<a href="#" onclick="javascript: OpenFile(\''.$http_www.'/'.$id['title'].'\', \''.$sType.'\');return false;">'.$id['title'].'</a>';
//comments => display comment under the document name //comments => display comment under the document name

@ -5,10 +5,7 @@
* @author Christian Fasanando <christian1827@gmail.com> * @author Christian Fasanando <christian1827@gmail.com>
* @package chamilo.dashboard * @package chamilo.dashboard
*/ */
/**
* Code
*/
// required files
/** /**
* DashboardManager can be used to manage dashboard * DashboardManager can be used to manage dashboard
* @package chamilo.dashboard * @package chamilo.dashboard

File diff suppressed because it is too large Load Diff

@ -21,9 +21,6 @@ if (!function_exists('api_get_path')) {
header('location: upload.php'); header('location: upload.php');
die; die;
} }
require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
require_once '../document/document.inc.php';
$courseDir = $_course['path'] . "/document"; $courseDir = $_course['path'] . "/document";
$sys_course_path = api_get_path(SYS_COURSE_PATH); $sys_course_path = api_get_path(SYS_COURSE_PATH);

@ -14,8 +14,6 @@ use ChamiloSession as Session;
* @todo this lib should be convert in a static class and moved to main/inc/lib * @todo this lib should be convert in a static class and moved to main/inc/lib
*/ */
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
$addDocumentToWork = api_get_configuration_value('add_document_to_work'); $addDocumentToWork = api_get_configuration_value('add_document_to_work');
define('ADD_DOCUMENT_TO_WORK', $addDocumentToWork); define('ADD_DOCUMENT_TO_WORK', $addDocumentToWork);
$workUserComments = api_get_configuration_value('work_user_comments'); $workUserComments = api_get_configuration_value('work_user_comments');
@ -2362,7 +2360,7 @@ function get_work_user_list(
} }
// Type. // Type.
$work['type'] = build_document_icon_tag('file', $work['url']); $work['type'] = DocumentManager::build_document_icon_tag('file', $work['url']);
// File name. // File name.
$link_to_download = null; $link_to_download = null;

Loading…
Cancel
Save