38
38
$ parent_id = null ;
39
39
$ lib_path = api_get_path (LIBRARY_PATH );
40
40
$ actionsRight = '' ;
41
- $ action = isset ($ _REQUEST ['action ' ]) ? $ _REQUEST ['action ' ] : null ;
41
+ $ action = isset ($ _REQUEST ['action ' ]) ? $ _REQUEST ['action ' ] : '' ;
42
42
$ allowUseTool = false ;
43
43
44
44
if ($ allowDownloadDocumentsByApiKey ) {
49
49
50
50
$ username = isset ($ _GET ['username ' ]) ? Security::remove_XSS ($ _GET ['username ' ]) : null ;
51
51
$ apiKey = isset ($ _GET ['api_key ' ]) ? Security::remove_XSS ($ _GET ['api_key ' ]) : null ;
52
-
53
52
$ restApi = Rest::validate ($ username , $ apiKey );
54
-
55
53
$ allowUseTool = $ restApi ? true : false ;
56
54
} catch (Exception $ e ) {
57
55
$ allowUseTool = false ;
74
72
$ courseInfo = api_get_course_info ();
75
73
$ courseId = $ courseInfo ['real_id ' ];
76
74
$ course_dir = $ courseInfo ['directory ' ].'/document ' ;
77
- $ sys_course_path = api_get_path (SYS_COURSE_PATH );
78
- $ base_work_dir = $ sys_course_path .$ course_dir ;
79
- $ http_www = api_get_path (WEB_COURSE_PATH ).$ courseInfo ['directory ' ].'/document ' ;
80
- $ document_path = $ base_work_dir ;
81
75
$ usePpt2lp = api_get_setting ('service_ppt2lp ' , 'active ' ) == 'true ' ;
82
- $ course_dir = $ courseInfo ['directory ' ].'/document ' ;
83
76
$ sys_course_path = api_get_path (SYS_COURSE_PATH );
84
77
$ base_work_dir = $ sys_course_path .$ course_dir ;
85
78
$ http_www = api_get_path (WEB_COURSE_PATH ).$ courseInfo ['directory ' ].'/document ' ;
95
88
$ is_certificate_mode = true ;
96
89
}
97
90
91
+ $ certificateLink = '' ;
92
+ if ($ is_certificate_mode ) {
93
+ $ certificateLink = '&certificate=true ' ;
94
+ }
95
+
98
96
// Removing sessions
99
97
Session::erase ('draw_dir ' );
100
98
Session::erase ('paint_dir ' );
130
128
$ moveTo = isset ($ _POST ['move_to ' ]) ? Security::remove_XSS ($ _POST ['move_to ' ]) : null ;
131
129
$ moveFile = isset ($ _POST ['move_file ' ]) && is_int ($ _POST ['move_file ' ]) ? $ _POST ['move_file ' ] : null ;
132
130
133
- /* Constants and variables */
131
+ /* Constants and variables */
134
132
$ userId = api_get_user_id ();
135
133
$ userInfo = api_get_user_info ();
136
134
$ sessionId = api_get_session_id ();
164
162
165
163
// Let's assume the user cannot upload files for the group
166
164
$ group_member_with_upload_rights = false ;
167
-
168
165
if ($ group_properties ['doc_state ' ] == 2 ) {
169
166
// Documents are private
170
167
if ($ isAllowedToEdit || GroupManager::is_user_in_group ($ userId , $ group_properties )) {
202
199
$ group_member_with_upload_rights = true ;
203
200
}
204
201
}
205
-
206
202
Session::write ('group_member_with_upload_rights ' , $ group_member_with_upload_rights );
207
203
} else {
208
204
Session::write ('group_member_with_upload_rights ' , false );
211
207
// Actions.
212
208
$ document_id = isset ($ _REQUEST ['id ' ]) ? intval ($ _REQUEST ['id ' ]) : null ;
213
209
$ currentUrl = api_get_self ().'? ' .api_get_cidreq ().'&id= ' .$ document_id ;
214
-
215
- /*if (Portfolio::controller()->accept()) {
216
- Portfolio::controller()->run();
217
- }*/
218
-
219
210
$ curdirpath = isset ($ _GET ['curdirpath ' ]) ? Security::remove_XSS ($ _GET ['curdirpath ' ]) : null ;
220
211
221
212
switch ($ action ) {
748
739
}
749
740
}
750
741
751
- // Is the document tool visible?
752
- // Check whether the tool is actually visible
753
- /*$table_course_tool = Database::get_course_table(TABLE_TOOL_LIST);
754
- $course_id = api_get_course_int_id();
755
- $tool_sql = 'SELECT visibility FROM '.$table_course_tool.'
756
- WHERE c_id = '.$course_id.' AND name = "'.TOOL_DOCUMENT.'"
757
- LIMIT 1';
758
- $tool_result = Database::query($tool_sql);
759
- $tool_row = Database::fetch_array($tool_result);
760
- $tool_visibility = $tool_row['visibility'];*/
761
-
762
742
$ htmlHeadXtra [] = '<script>
763
743
function confirmation (name) {
764
744
if (confirm(" ' .addslashes (get_lang ('AreYouSureToDeleteJS ' )).' "+ name + " ?")) {
@@ -811,11 +791,8 @@ function convertModal (id, format) {
811
791
}
812
792
}
813
793
814
- /* Create shared folders */
794
+ /* Create shared folders */
815
795
DocumentManager::createUserSharedFolder (api_get_user_id (), $ courseInfo , $ sessionId );
816
-
817
- /* MAIN SECTION */
818
-
819
796
Session::write ('image_files_only ' , '' );
820
797
$ image_files_only = '' ;
821
798
if ($ is_certificate_mode ) {
@@ -956,14 +933,12 @@ function convertModal (id, format) {
956
933
// Lib for event log, stats & tracking & record of the access
957
934
Event::event_access_tool (TOOL_DOCUMENT );
958
935
959
- /* DISPLAY */
936
+ /* DISPLAY */
960
937
if ($ groupId != 0 ) { // Add group name after for group documents
961
938
$ add_group_to_title = ' ( ' .$ group_properties ['name ' ].') ' ;
962
939
}
963
-
964
940
$ moveForm = '' ;
965
-
966
- /* MOVE FILE OR DIRECTORY */
941
+ /* MOVE FILE OR DIRECTORY */
967
942
//Only teacher and all users into their group and each user into his/her shared folder
968
943
if ($ isAllowedToEdit || $ group_member_with_upload_rights ||
969
944
DocumentManager::is_my_shared_folder (api_get_user_id (), $ curdirpath , $ sessionId ) ||
@@ -1066,8 +1041,19 @@ function convertModal (id, format) {
1066
1041
$ doc_id = $ moveFile ;
1067
1042
DocumentManager::updateDBInfoCloudLink ($ document_to_move ['path ' ], $ moveTo .'/ ' , $ doc_id );
1068
1043
1069
- //update database item property
1070
- api_item_property_update ($ _course , TOOL_DOCUMENT , $ doc_id , 'FileMoved ' , api_get_user_id (), $ to_group_id , null , null , null , $ session_id );
1044
+ // Update database item property
1045
+ api_item_property_update (
1046
+ $ _course ,
1047
+ TOOL_DOCUMENT ,
1048
+ $ doc_id ,
1049
+ 'FileMoved ' ,
1050
+ api_get_user_id (),
1051
+ $ to_group_id ,
1052
+ null ,
1053
+ null ,
1054
+ null ,
1055
+ $ session_id
1056
+ );
1071
1057
Display::addFlash (
1072
1058
Display::return_message (
1073
1059
get_lang ('CloudLinkMoved ' ),
@@ -1157,7 +1143,7 @@ function convertModal (id, format) {
1157
1143
}
1158
1144
}
1159
1145
1160
- /* DELETE FILE OR DIRECTORY */
1146
+ /* DELETE FILE OR DIRECTORY */
1161
1147
//Only teacher and all users into their group
1162
1148
if ($ isAllowedToEdit ||
1163
1149
$ group_member_with_upload_rights ||
@@ -1294,8 +1280,7 @@ function convertModal (id, format) {
1294
1280
}
1295
1281
1296
1282
$ dirForm = '' ;
1297
-
1298
- /* CREATE DIRECTORY */
1283
+ /* CREATE DIRECTORY */
1299
1284
//Only teacher and all users into their group and any user into his/her shared folder
1300
1285
if ($ isAllowedToEdit ||
1301
1286
$ group_member_with_upload_rights ||
@@ -1305,7 +1290,6 @@ function convertModal (id, format) {
1305
1290
if (isset ($ _POST ['create_dir ' ]) && $ _POST ['dirname ' ] != '' ) {
1306
1291
// Needed for directory creation
1307
1292
$ post_dir_name = $ _POST ['dirname ' ];
1308
-
1309
1293
if ($ post_dir_name == '../ ' || $ post_dir_name == '. ' || $ post_dir_name == '.. ' ) {
1310
1294
$ message = Display::return_message (get_lang ('CannotCreateDir ' ), 'error ' );
1311
1295
} else {
@@ -1331,7 +1315,7 @@ function convertModal (id, format) {
1331
1315
}
1332
1316
$ curdirpath = $ document_data ['path ' ];
1333
1317
}
1334
- $ added_slash = ( $ curdirpath == '/ ' ) ? '' : '/ ' ;
1318
+ $ added_slash = $ curdirpath == '/ ' ? '' : '/ ' ;
1335
1319
$ dir_name = $ curdirpath .$ added_slash .api_replace_dangerous_char ($ post_dir_name );
1336
1320
$ dir_name = disable_dangerous_file ($ dir_name );
1337
1321
$ dir_check = $ base_work_dir .$ dir_name ;
@@ -1370,7 +1354,7 @@ function convertModal (id, format) {
1370
1354
}
1371
1355
}
1372
1356
1373
- /* VISIBILITY COMMANDS */
1357
+ /* VISIBILITY COMMANDS */
1374
1358
if ($ isAllowedToEdit ) {
1375
1359
if ((isset ($ _GET ['set_invisible ' ]) && !empty ($ _GET ['set_invisible ' ])) ||
1376
1360
(isset ($ _GET ['set_visible ' ]) && !empty ($ _GET ['set_visible ' ]))
@@ -1424,7 +1408,7 @@ function convertModal (id, format) {
1424
1408
}
1425
1409
$ templateForm = '' ;
1426
1410
1427
- /* TEMPLATE ACTION */
1411
+ /* TEMPLATE ACTION */
1428
1412
//Only teacher and all users into their group
1429
1413
if ($ isAllowedToEdit ||
1430
1414
$ group_member_with_upload_rights ||
@@ -1547,7 +1531,7 @@ function convertModal (id, format) {
1547
1531
}
1548
1532
}
1549
1533
1550
- /* GET ALL DOCUMENT DATA FOR CURDIRPATH */
1534
+ /* GET ALL DOCUMENT DATA FOR CURDIRPATH */
1551
1535
if (isset ($ _GET ['keyword ' ]) && !empty ($ _GET ['keyword ' ])) {
1552
1536
$ documentAndFolders = DocumentManager::get_all_document_data (
1553
1537
$ courseInfo ,
@@ -1597,23 +1581,21 @@ function convertModal (id, format) {
1597
1581
$ folders = [];
1598
1582
}
1599
1583
$ btngroup = ['class ' => 'btn btn-default ' ];
1600
-
1601
1584
/* GO TO PARENT DIRECTORY */
1602
1585
$ actionsLeft = '' ;
1603
-
1604
1586
if ($ curdirpath != '/ ' &&
1605
1587
$ curdirpath != $ group_properties ['directory ' ] &&
1606
1588
!$ is_certificate_mode
1607
1589
) {
1608
- $ actionsLeft = '<a href=" ' .api_get_self ().'? ' .api_get_cidreq ().'&id= ' .$ parent_id .'"> ' ;
1590
+ $ actionsLeft = '<a href=" ' .api_get_self ().'? ' .api_get_cidreq ().'&id= ' .$ parent_id .$ certificateLink . '"> ' ;
1609
1591
$ actionsLeft .= Display::return_icon ('folder_up.png ' , get_lang ('Up ' ), '' , ICON_SIZE_MEDIUM );
1610
1592
$ actionsLeft .= '</a> ' ;
1611
1593
}
1612
1594
1613
1595
if ($ is_certificate_mode && $ curdirpath != '/certificates ' ) {
1614
1596
$ actionsLeft .= Display::url (
1615
1597
Display::return_icon ('folder_up.png ' , get_lang ('Up ' ), '' , ICON_SIZE_MEDIUM ),
1616
- api_get_self ().'? ' .api_get_cidreq ().'&curdirpath = ' .$ curdirpath
1598
+ api_get_self ().'? ' .api_get_cidreq ().'&id = ' .$ parent_id . $ certificateLink
1617
1599
);
1618
1600
}
1619
1601
@@ -1722,10 +1704,7 @@ function convertModal (id, format) {
1722
1704
);
1723
1705
}
1724
1706
1725
- /*echo '<a href="#" id="jcapture">';
1726
- echo Display::display_icon('capture.png', get_lang('CatchScreenCasts'), '', ICON_SIZE_MEDIUM).'</a>';*/
1727
-
1728
- if ($ capturePluginInstalled ) {
1707
+ if ($ capturePluginInstalled && !$ is_certificate_mode ) {
1729
1708
$ actionsLeft .= '<span id="appletplace"></span> ' ;
1730
1709
$ actionsLeft .= Display::url (
1731
1710
Display::return_icon ('capture.png ' , get_lang ('CatchScreenCasts ' ), '' , ICON_SIZE_MEDIUM ),
@@ -1744,22 +1723,22 @@ function convertModal (id, format) {
1744
1723
1745
1724
// "Add cloud link" icon
1746
1725
$ fileLinkEnabled = api_get_configuration_value ('enable_add_file_link ' );
1747
- if ($ fileLinkEnabled ) {
1726
+ if ($ fileLinkEnabled && ! $ is_certificate_mode ) {
1748
1727
$ actionsLeft .= Display::url (
1749
1728
Display::return_icon ('clouddoc_new.png ' , get_lang ('AddCloudLink ' ), '' , ICON_SIZE_MEDIUM ),
1750
1729
api_get_path (WEB_CODE_PATH ).'document/add_link.php? ' .api_get_cidreq ().'&id= ' .$ document_id
1751
1730
);
1752
1731
}
1753
1732
}
1754
1733
require 'document_slideshow.inc.php ' ;
1755
- if (!isset ($ _GET ['keyword ' ])) {
1734
+ if (!isset ($ _GET ['keyword ' ]) && ! $ is_certificate_mode ) {
1756
1735
$ actionsLeft .= Display::url (
1757
1736
Display::return_icon ('slideshow.png ' , get_lang ('ViewSlideshow ' ), '' , ICON_SIZE_MEDIUM ),
1758
1737
api_get_path (WEB_CODE_PATH ).'document/slideshow.php? ' .api_get_cidreq ().'&curdirpath= ' .$ curdirpathurl
1759
1738
);
1760
1739
}
1761
1740
1762
- if ($ isAllowedToEdit ) {
1741
+ if ($ isAllowedToEdit && ! $ is_certificate_mode ) {
1763
1742
$ actionsLeft .= Display::url (
1764
1743
Display::return_icon ('percentage.png ' , get_lang ('DocumentQuota ' ), '' , ICON_SIZE_MEDIUM ),
1765
1744
api_get_path (WEB_CODE_PATH ).'document/document_quota.php? ' .api_get_cidreq ()
@@ -1777,9 +1756,9 @@ function convertModal (id, format) {
1777
1756
FormValidator::LAYOUT_INLINE
1778
1757
);
1779
1758
$ form ->addText ('keyword ' , '' , false , ['class ' => 'col-md-2 ' ]);
1780
- $ form ->addElement ( ' hidden ' , 'cidReq ' , api_get_course_id ());
1781
- $ form ->addElement ( ' hidden ' , 'id_session ' , api_get_session_id ());
1782
- $ form ->addElement ( ' hidden ' , 'gidReq ' , $ groupId );
1759
+ $ form ->addHidden ( 'cidReq ' , api_get_course_id ());
1760
+ $ form ->addHidden ( 'id_session ' , api_get_session_id ());
1761
+ $ form ->addHidden ( 'gidReq ' , $ groupId );
1783
1762
$ form ->addButtonSearch (get_lang ('Search ' ));
1784
1763
$ actionsRight = $ form ->returnForm ();
1785
1764
}
@@ -1794,7 +1773,6 @@ function convertModal (id, format) {
1794
1773
);
1795
1774
1796
1775
$ getSizeURL = api_get_path (WEB_AJAX_PATH ).'document.ajax.php?a=get_dir_size& ' .api_get_cidreq ();
1797
-
1798
1776
if (isset ($ documentAndFolders ) && is_array ($ documentAndFolders )) {
1799
1777
if ($ groupId == 0 || $ userAccess ) {
1800
1778
$ count = 1 ;
@@ -1813,19 +1791,15 @@ function convertModal (id, format) {
1813
1791
false ,
1814
1792
$ userIsSubscribed
1815
1793
);
1816
-
1817
1794
$ invisibility_span_open = ($ is_visible == 0 ) ? '<span class="muted"> ' : '' ;
1818
1795
$ invisibility_span_close = ($ is_visible == 0 ) ? '</span> ' : '' ;
1819
-
1820
1796
$ size = 1 ;
1821
-
1822
1797
// Get the title or the basename depending on what we're using
1823
1798
if ($ document_data ['title ' ] != '' ) {
1824
1799
$ document_name = $ document_data ['title ' ];
1825
1800
} else {
1826
1801
$ document_name = basename ($ document_data ['path ' ]);
1827
1802
}
1828
-
1829
1803
$ row ['name ' ] = $ document_name ;
1830
1804
// Data for checkbox
1831
1805
if (($ isAllowedToEdit || $ group_member_with_upload_rights ) && count ($ documentAndFolders ) > 1 ) {
@@ -1867,7 +1841,8 @@ function convertModal (id, format) {
1867
1841
$ count ,
1868
1842
$ is_visible ,
1869
1843
$ size ,
1870
- $ isAllowedToEdit
1844
+ $ isAllowedToEdit ,
1845
+ $ is_certificate_mode
1871
1846
);
1872
1847
1873
1848
$ path_info = pathinfo ($ document_data ['path ' ]);
@@ -1887,7 +1862,8 @@ function convertModal (id, format) {
1887
1862
null ,
1888
1863
$ is_visible ,
1889
1864
$ size ,
1890
- $ isAllowedToEdit
1865
+ $ isAllowedToEdit ,
1866
+ $ is_certificate_mode
1891
1867
);
1892
1868
1893
1869
// Document title with link
0 commit comments