|
@@ -470,12 +470,7 @@ class DocumentManager {
|
|
$to_user_id = Database::escape_string($to_user_id);
|
|
$to_user_id = Database::escape_string($to_user_id);
|
|
$to_value = Database::escape_string($to_value);
|
|
$to_value = Database::escape_string($to_value);
|
|
|
|
|
|
- //if they can't see invisible files, they can only see files with visibility 1
|
|
|
|
- //$visibility_bit = ' = 1';
|
|
|
|
- //if they can see invisible files, only deleted files (visibility 2) are filtered out
|
|
|
|
- //if ($can_see_invisible) {
|
|
|
|
$visibility_bit = ' <> 2';
|
|
$visibility_bit = ' <> 2';
|
|
- //}
|
|
|
|
|
|
|
|
//the given path will not end with a slash, unless it's the root '/'
|
|
//the given path will not end with a slash, unless it's the root '/'
|
|
//so no root -> add slash
|
|
//so no root -> add slash
|
|
@@ -485,10 +480,6 @@ class DocumentManager {
|
|
$current_session_id = api_get_session_id();
|
|
$current_session_id = api_get_session_id();
|
|
$condition_session = " AND (id_session = '$current_session_id' OR id_session = '0')";
|
|
$condition_session = " AND (id_session = '$current_session_id' OR id_session = '0')";
|
|
|
|
|
|
- if (!$can_see_invisible) {
|
|
|
|
- //$condition_session = " AND (id_session = '$current_session_id' ) ";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
//condition for search (get ALL folders and documents)
|
|
//condition for search (get ALL folders and documents)
|
|
|
|
|
|
$sql = "SELECT docs.id,
|
|
$sql = "SELECT docs.id,
|
|
@@ -504,14 +495,12 @@ class DocumentManager {
|
|
last.visibility,
|
|
last.visibility,
|
|
last.insert_user_id
|
|
last.insert_user_id
|
|
FROM ".$TABLE_ITEMPROPERTY." AS last INNER JOIN ".$TABLE_DOCUMENT." AS docs
|
|
FROM ".$TABLE_ITEMPROPERTY." AS last INNER JOIN ".$TABLE_DOCUMENT." AS docs
|
|
- ON (docs.id = last.ref AND docs.c_id = {$_course['real_id']} AND last.c_id = {$_course['real_id']})
|
|
|
|
|
|
+ ON (docs.id = last.ref AND last.tool = '".TOOL_DOCUMENT."' AND docs.c_id = {$_course['real_id']} AND last.c_id = {$_course['real_id']})
|
|
WHERE
|
|
WHERE
|
|
docs.path LIKE '".$path.$added_slash."%' AND
|
|
docs.path LIKE '".$path.$added_slash."%' AND
|
|
- docs.path NOT LIKE '".$path.$added_slash."%/%' AND
|
|
|
|
- last.tool = '".TOOL_DOCUMENT."' AND
|
|
|
|
|
|
+ docs.path NOT LIKE '".$path.$added_slash."%/%' AND
|
|
".$to_field." = ".$to_value." AND
|
|
".$to_field." = ".$to_value." AND
|
|
- last.visibility".$visibility_bit.$condition_session;
|
|
|
|
-
|
|
|
|
|
|
+ last.visibility".$visibility_bit.$condition_session;
|
|
$result = Database::query($sql);
|
|
$result = Database::query($sql);
|
|
|
|
|
|
$doc_list = array();
|
|
$doc_list = array();
|
|
@@ -569,8 +558,7 @@ class DocumentManager {
|
|
//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 ) {
|
|
- if ($id == $row['id']) {
|
|
|
|
- //var_dump($row['visibility'].' - '.$row['session_id'].' - '.$row['item_property_session_id']);
|
|
|
|
|
|
+ if ($id == $row['id']) {
|
|
if ($row['visibility'] == 0 && $row['item_property_session_id'] == 0) {
|
|
if ($row['visibility'] == 0 && $row['item_property_session_id'] == 0) {
|
|
$delete_repeated[$id] = true;
|
|
$delete_repeated[$id] = true;
|
|
}
|
|
}
|
|
@@ -581,18 +569,13 @@ class DocumentManager {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //var_dump($delete_repeated);
|
|
|
|
-
|
|
|
|
- foreach($doc_list as $key=>$row) {
|
|
|
|
- //&& !in_array($row['id'],$my_repeat_ids)
|
|
|
|
- //var_dump($row['id'].' - '.$row['visibility']);
|
|
|
|
|
|
+ foreach($doc_list as $key=>$row) {
|
|
if (in_array($row['visibility'], array('0','2')) && !in_array($row['id'],$my_repeat_ids) ) {
|
|
if (in_array($row['visibility'], array('0','2')) && !in_array($row['id'],$my_repeat_ids) ) {
|
|
$ids_to_remove[] = $row['id'];
|
|
$ids_to_remove[] = $row['id'];
|
|
unset($doc_list[$key]);
|
|
unset($doc_list[$key]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //var_dump($ids_to_remove);
|
|
|
|
-
|
|
|
|
|
|
+
|
|
foreach($document_data as $row) {
|
|
foreach($document_data as $row) {
|
|
if (in_array($row['id'], $ids_to_remove)) {
|
|
if (in_array($row['id'], $ids_to_remove)) {
|
|
unset($document_data[$row['id']]);
|
|
unset($document_data[$row['id']]);
|
|
@@ -607,12 +590,12 @@ class DocumentManager {
|
|
foreach ($document_data as $row) {
|
|
foreach ($document_data as $row) {
|
|
$is_visible = DocumentManager::check_visibility_tree($row['id'], $_course['code'], $current_session_id, api_get_user_id());
|
|
$is_visible = DocumentManager::check_visibility_tree($row['id'], $_course['code'], $current_session_id, api_get_user_id());
|
|
if ($is_visible) {
|
|
if ($is_visible) {
|
|
- $final_document_data[$row['id']]=$row;
|
|
|
|
|
|
+ $final_document_data[$row['id']] = $row;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
$final_document_data = $document_data;
|
|
$final_document_data = $document_data;
|
|
- }
|
|
|
|
|
|
+ }
|
|
return $final_document_data;
|
|
return $final_document_data;
|
|
} else {
|
|
} else {
|
|
//display_error("Error getting document info from database (".Database::error().")!");
|
|
//display_error("Error getting document info from database (".Database::error().")!");
|
|
@@ -638,19 +621,21 @@ class DocumentManager {
|
|
//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);
|
|
- $sql = "SELECT DISTINCT docs.id, path FROM ".$TABLE_ITEMPROPERTY." AS last, ".$TABLE_DOCUMENT." AS docs
|
|
|
|
- WHERE docs.id = last.ref AND
|
|
|
|
- docs.filetype = 'folder' AND
|
|
|
|
- last.tool = '".TOOL_DOCUMENT."' AND
|
|
|
|
|
|
+ $sql = "SELECT DISTINCT docs.id, path
|
|
|
|
+ FROM $TABLE_ITEMPROPERTY AS last INNER JOIN $TABLE_DOCUMENT AS docs
|
|
|
|
+ ON (docs.id = last.ref AND last.tool = '".TOOL_DOCUMENT."' AND last.c_id = {$_course['real_id']} AND docs.c_id = {$_course['real_id']} )
|
|
|
|
+ WHERE
|
|
|
|
+ docs.filetype = 'folder' AND
|
|
last.to_group_id = ".$to_group_id." AND
|
|
last.to_group_id = ".$to_group_id." AND
|
|
- last.visibility <> 2 $condition_session AND
|
|
|
|
- last.c_id = {$_course['real_id']} AND
|
|
|
|
- docs.c_id = {$_course['real_id']} ";
|
|
|
|
|
|
+ last.visibility <> 2 $condition_session ";
|
|
|
|
|
|
$result = Database::query($sql);
|
|
$result = Database::query($sql);
|
|
|
|
|
|
if ($result && Database::num_rows($result) != 0) {
|
|
if ($result && Database::num_rows($result) != 0) {
|
|
while ($row = Database::fetch_array($result, 'ASSOC')) {
|
|
while ($row = Database::fetch_array($result, 'ASSOC')) {
|
|
|
|
+ if (DocumentManager::is_folder_to_avoid($row['path'])) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
$document_folders[$row['id']] = $row['path'];
|
|
$document_folders[$row['id']] = $row['path'];
|
|
}
|
|
}
|
|
//sort($document_folders);
|
|
//sort($document_folders);
|
|
@@ -3153,5 +3138,45 @@ class DocumentManager {
|
|
public static function get_web_odf_extension_list(){
|
|
public static function get_web_odf_extension_list(){
|
|
return array('ods', 'odt');
|
|
return array('ods', 'odt');
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static function is_folder_to_avoid($path) {
|
|
|
|
+ $folders_to_avoid = array(
|
|
|
|
+ '/HotPotatoes_files',
|
|
|
|
+ '/certificates',
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if (basename($path) == 'css') {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //Skip hotpotatoes results
|
|
|
|
+ if (strstr($path, 'HotPotatoes_files')) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //Admin setting for Hide/Show the folders of all users
|
|
|
|
+ if (api_get_setting('show_users_folders') == 'false') {
|
|
|
|
+ $folders_to_avoid[] = '/shared_folder';
|
|
|
|
+
|
|
|
|
+ if (strstr($path, 'shared_folder_session_')) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //Admin setting for Hide/Show Default folders to all users
|
|
|
|
+ if (api_get_setting('show_default_folders') == 'false') {
|
|
|
|
+ $folders_to_avoid[] = '/images';
|
|
|
|
+ $folders_to_avoid[] = '/flash';
|
|
|
|
+ $folders_to_avoid[] = '/audio';
|
|
|
|
+ $folders_to_avoid[] = '/video';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //Admin setting for Hide/Show chat history folder
|
|
|
|
+ if (api_get_setting('show_chat_folder') == 'false') {
|
|
|
|
+ $folders_to_avoid[] = '/chat_files';
|
|
|
|
+ }
|
|
|
|
+ return in_array($path, $folders_to_avoid);
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//end class DocumentManager
|
|
//end class DocumentManager
|