Format code.

1.9.x
Julio Montoya 10 years ago
parent 5a6acf8113
commit 65ff3d32c1
  1. 4
      main/work/add_document.php
  2. 8
      main/work/add_user.php
  3. 6
      main/work/download.php
  4. 18
      main/work/download_comment_file.php
  5. 34
      main/work/downloadfolder.inc.php
  6. 39
      main/work/edit.php
  7. 6
      main/work/edit_work.php
  8. 2
      main/work/student_work.php
  9. 9
      main/work/upload.php
  10. 6
      main/work/upload_from_template.php
  11. 4
      main/work/work.lib.php
  12. 20
      main/work/work_list.php
  13. 34
      main/work/work_list_all.php
  14. 22
      main/work/work_list_others.php
  15. 10
      main/work/work_missing.php

@ -74,7 +74,7 @@ if (empty($docId)) {
echo '</div>';
}
$document_tree = DocumentManager::get_document_preview(
$documentTree = DocumentManager::get_document_preview(
$courseInfo,
null,
null,
@ -84,7 +84,7 @@ if (empty($docId)) {
api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId.'&'.api_get_cidreq()
);
echo Display::page_subheader(get_lang('Documents'));
echo $document_tree;
echo $documentTree;
echo '<hr /><div class="clear"></div>';
} else {

@ -79,7 +79,13 @@ if (!empty($items)) {
echo '</div>';
}
$userList = CourseManager::get_user_list_from_course_code($courseInfo['code'], api_get_session_id(), null, null, STUDENT);
$userList = CourseManager::get_user_list_from_course_code(
$courseInfo['code'],
api_get_session_id(),
null,
null,
STUDENT
);
$userToAddList = array();
foreach ($userList as $user) {

@ -20,13 +20,13 @@ api_protect_course_script(true);
$id = intval($_GET['id']);
$course_info = api_get_course_info();
$courseInfo = api_get_course_info();
if (empty($course_info)) {
if (empty($courseInfo)) {
api_not_allowed(true);
}
$result = downloadFile($id, $course_info);
$result = downloadFile($id, $courseInfo);
if ($result == false) {
api_not_allowed(true);
}

@ -33,9 +33,21 @@ if (!empty($workData)) {
$work = get_work_data_by_id($workData['work_id']);
allowOnlySubscribedUser(api_get_user_id(), $work['parent_id'], $courseInfo['real_id']);
if (user_is_author($workData['work_id']) || $courseInfo['show_score'] == 0 && $work['active'] == 1 && $work['accepted'] == 1) {
if (Security::check_abs_path($workData['file_path'], api_get_path(SYS_COURSE_PATH).api_get_course_path().'/')) {
DocumentManager::file_send_for_download($workData['file_path'], true, $workData['file_name_to_show']);
if (user_is_author($workData['work_id']) ||
$courseInfo['show_score'] == 0 &&
$work['active'] == 1 &&
$work['accepted'] == 1
) {
if (Security::check_abs_path(
$workData['file_path'],
api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/'
)
) {
DocumentManager::file_send_for_download(
$workData['file_path'],
true,
$workData['file_name_to_show']
);
}
} else {
api_not_allowed(true);

@ -61,8 +61,16 @@ if (array_key_exists('filename', $work_data)) {
if (api_is_allowed_to_edit()) {
//Search for all files that are not deleted => visibility != 2
$sql = "SELECT DISTINCT url, title, description, insert_user_id, insert_date, contains_file $filenameCondition
FROM $tbl_student_publication AS work INNER JOIN $prop_table AS props
$sql = "SELECT DISTINCT
url,
title,
description,
insert_user_id,
insert_date,
contains_file
$filenameCondition
FROM $tbl_student_publication AS work
INNER JOIN $prop_table AS props
INNER JOIN $tableUser as u
ON (
props.c_id = $course_id AND
@ -96,8 +104,16 @@ if (api_is_allowed_to_edit()) {
}
//for other users, we need to create a zipfile with only visible files and folders
$sql = "SELECT DISTINCT url, title, description, insert_user_id, insert_date, contains_file $filenameCondition
FROM $tbl_student_publication AS work INNER JOIN $prop_table AS props
$sql = "SELECT DISTINCT
url,
title,
description,
insert_user_id,
insert_date,
contains_file
$filenameCondition
FROM $tbl_student_publication AS work
INNER JOIN $prop_table AS props
ON (props.c_id = $course_id AND
work.c_id = $course_id AND
work.id = props.ref)
@ -130,7 +146,9 @@ while ($not_deleted_file = Database::fetch_assoc($query)) {
$filename = $insert_date.'_'.$user_info['username'].'_'.$title;
// File exists
if (file_exists($sys_course_path.$_course['path'].'/'.$not_deleted_file['url']) && !empty($not_deleted_file['url'])) {
if (file_exists($sys_course_path.$_course['path'].'/'.$not_deleted_file['url']) &&
!empty($not_deleted_file['url'])
) {
$files[basename($not_deleted_file['url'])] = $filename;
$addStatus = $zip_folder->add(
$sys_course_path.$_course['path'].'/'.$not_deleted_file['url'],
@ -179,8 +197,10 @@ function my_pre_add_callback($p_event, &$p_header)
global $files;
if (isset($files[basename($p_header['stored_filename'])])) {
$p_header['stored_filename'] = $files[basename($p_header['stored_filename'])];
return 1;
}
return 0;
}
@ -190,7 +210,8 @@ function my_pre_add_callback($p_event, &$p_header)
*
* @param array $arr1 first array
* @param array $arr2 second array
* @return difference between the two arrays
*
* @return array difference between the two arrays
*/
function diff($arr1, $arr2)
{
@ -202,5 +223,6 @@ function diff($arr1, $arr2)
$r++;
}
}
return $res;
}

@ -20,7 +20,6 @@ $this_section = SECTION_COURSES;
$work_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
$item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$is_allowed_to_edit = api_is_allowed_to_edit();
@ -40,7 +39,12 @@ if (empty($parent_data)) {
api_not_allowed(true);
}
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $course_code, $session_id);
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course(
$user_id,
$course_code,
$session_id
);
$is_course_member = $is_course_member || api_is_platform_admin();
if ($is_course_member == false) {
@ -72,10 +76,14 @@ if (!api_is_allowed_to_edit()) {
if (!empty($my_folder_data)) {
$homework = get_work_assignment_by_id($my_folder_data['id']);
if ($homework['expires_on'] != '0000-00-00 00:00:00' || $homework['ends_on'] != '0000-00-00 00:00:00') {
if ($homework['expires_on'] != '0000-00-00 00:00:00' ||
$homework['ends_on'] != '0000-00-00 00:00:00'
) {
$time_now = time();
if (!empty($homework['expires_on']) && $homework['expires_on'] != '0000-00-00 00:00:00') {
if (!empty($homework['expires_on']) &&
$homework['expires_on'] != '0000-00-00 00:00:00'
) {
$time_expires = api_strtotime($homework['expires_on'], 'UTC');
$difference = $time_expires - $time_now;
if ($difference < 0) {
@ -83,11 +91,15 @@ if (!empty($my_folder_data)) {
}
}
if (empty($homework['expires_on']) || $homework['expires_on'] == '0000-00-00 00:00:00') {
if (empty($homework['expires_on']) ||
$homework['expires_on'] == '0000-00-00 00:00:00'
) {
$has_expired = false;
}
if (!empty($homework['ends_on']) && $homework['ends_on'] != '0000-00-00 00:00:00') {
if (!empty($homework['ends_on']) &&
$homework['ends_on'] != '0000-00-00 00:00:00'
) {
$time_ends = api_strtotime($homework['ends_on'], 'UTC');
$difference2 = $time_ends - $time_now;
if ($difference2 < 0) {
@ -148,12 +160,22 @@ $form->addElement('hidden', 'id', $work_id);
$form->addElement('hidden', 'item_id', $item_id);
$form->addElement('text', 'title', get_lang('Title'), array('id' => 'file_upload', 'class' => 'span4'));
if ($is_allowed_to_edit && !empty($item_id)) {
$sql = "SELECT contains_file, url FROM $work_table WHERE c_id = $course_id AND id ='$item_id' ";
$sql = "SELECT contains_file, url
FROM $work_table
WHERE c_id = $course_id AND id ='$item_id' ";
$result = Database::query($sql);
if ($result !== false && Database::num_rows($result) > 0) {
$row = Database::fetch_array($result);
if ($row['contains_file'] || !empty($row['url'])) {
$form->addElement('html', '<div class="control-group"><label class="control-label">'.get_lang('Download').'</label><div class="controls"><a href="'.api_get_path(WEB_CODE_PATH).'work/download.php?id='.$item_id.'&'.api_get_cidreq().'">'.Display::return_icon('save.png', get_lang('Save'),array(), ICON_SIZE_MEDIUM).'</a></div></div>');
$form->addElement(
'html',
'<div class="control-group">
<label class="control-label">'.get_lang('Download').'</label>
<div class="controls"><a href="'.api_get_path(WEB_CODE_PATH).'work/download.php?id='.$item_id.'&'.api_get_cidreq().'">'.
Display::return_icon('save.png', get_lang('Save'),array(), ICON_SIZE_MEDIUM).'</a>
</div>
</div>'
);
}
}
}
@ -211,6 +233,7 @@ if ($form->validate()) {
}
$description = isset($_POST['description']) ? $_POST['description'] : $work_data['description'];
$add_to_update = null;
if ($is_allowed_to_edit && ($_POST['qualification'] !='' )) {
$add_to_update = ', qualificator_id ='."'".api_get_user_id()."', ";
$add_to_update .= ' qualification = '."'".Database::escape_string($_POST['qualification'])."',";

@ -53,7 +53,11 @@ $defaults['new_dir'] = Security::remove_XSS($title);
$there_is_a_end_date = false;
if (Gradebook::is_active()) {
$link_info = is_resource_in_course_gradebook(api_get_course_id(), LINK_STUDENTPUBLICATION, $workId);
$link_info = is_resource_in_course_gradebook(
api_get_course_id(),
LINK_STUDENTPUBLICATION,
$workId
);
if (!empty($link_info)) {
$defaults['weight'] = $link_info['weight'];
$defaults['category_id'] = $link_info['category_id'];

@ -69,8 +69,8 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
switch ($action) {
case 'export_to_pdf':
exportAllWork($studentId, $courseInfo, 'pdf');
break;
exit;
break;
case 'download':
if (api_is_allowed_to_edit()) {
downloadAllFilesPerUser($studentId, $courseInfo);

@ -93,7 +93,14 @@ if ($form->validate()) {
if ($student_can_edit_in_session && $check) {
$values = $form->getSubmitValues();
// Process work
$error_message = processWorkForm($workInfo, $values, $course_info, $session_id, $group_id, $user_id);
$error_message = processWorkForm(
$workInfo,
$values,
$course_info,
$session_id,
$group_id,
$user_id
);
$script = 'work_list.php';
if ($is_allowed_to_edit) {
$script = 'work_list_all.php';

@ -42,7 +42,11 @@ if (empty($workInfo)) {
allowOnlySubscribedUser($user_id, $work_id, $course_id);
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $course_code, $session_id);
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course(
$user_id,
$course_code,
$session_id
);
$is_course_member = $is_course_member || api_is_platform_admin();
if ($is_course_member == false) {

@ -13,9 +13,7 @@ use ChamiloSession as Session;
* @author Julio Montoya <gugli100@gmail.com> BeezNest 2011 LOTS of bug fixes
* @todo this lib should be convert in a static class and moved to main/inc/lib
*/
/**
* Initialization
*/
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';

@ -49,15 +49,19 @@ if (!empty($group_id)) {
$show_work = true;
} else {
// you are not a teacher
$show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK);
$show_work = GroupManager::user_has_access(
$user_id,
$group_id,
GroupManager::GROUP_TOOL_WORK
);
}
if (!$show_work) {
api_not_allowed();
}
$interbreadcrumb[] = array ('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
}
$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
@ -157,13 +161,13 @@ $extra_params['height'] = 'auto';
$extra_params['sortname'] = 'firstname';
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$workId.'&type='.$type;
?>
<script>
$(function() {
<script>
$(function() {
<?php
echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
?>
});
</script>
?>
});
</script>
<?php
echo Display::grid_html('results');

@ -45,19 +45,36 @@ if (!empty($group_id)) {
$show_work = true;
} else {
// you are not a teacher
$show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK);
$show_work = GroupManager::user_has_access(
$user_id,
$group_id,
GroupManager::GROUP_TOOL_WORK
);
}
if (!$show_work) {
api_not_allowed();
}
$interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'group/group.php',
'name' => get_lang('Groups')
);
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id,
'name' => get_lang('GroupSpace').' '.$group_properties['name']
);
}
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId, 'name' => $my_folder_data['title']);
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications')
);
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
'name' => $my_folder_data['title']
);
$error_message = null;
@ -102,7 +119,8 @@ if ($is_allowed_to_edit && $action == 'make_invisible') {
$documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_session_edit(false, true) && !empty($workId)) {
/*echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'">';
echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';*/
@ -140,7 +158,8 @@ if (!empty($error_message)) {
}
if (!empty($my_folder_data['description'])) {
echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.
Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
}
$check_qualification = intval($my_folder_data['qualification']);
@ -158,6 +177,7 @@ if (!empty($work_data['enable_qualification']) && !empty($check_qualification))
get_lang('Status'),
get_lang('Actions')
);
$column_model = array (
array('name'=>'type', 'index'=>'file', 'width'=>'8', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),

@ -45,15 +45,19 @@ if (!empty($group_id)) {
$show_work = true;
} else {
// you are not a teacher
$show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK);
$show_work = GroupManager::user_has_access(
$user_id,
$group_id,
GroupManager::GROUP_TOOL_WORK
);
}
if (!$show_work) {
api_not_allowed();
}
$interbreadcrumb[] = array ('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
}
$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
@ -99,7 +103,7 @@ if (!empty($work_data['enable_qualification']) && !empty($check_qualification))
$columns = array(
get_lang('Type'), get_lang('FirstName'), get_lang('LastName'), get_lang('Title'), get_lang('Date'), get_lang('Actions')
);
$column_model = array (
$column_model = array(
array('name'=>'type', 'index'=>'file', 'width'=>'12', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
@ -115,13 +119,13 @@ $extra_params['height'] = 'auto';
$extra_params['sortname'] = 'firstname';
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list_others&work_id='.$workId.'&type='.$type;
?>
<script>
$(function() {
<script>
$(function() {
<?php
echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
?>
});
</script>
?>
});
</script>
<?php
echo Display::grid_html('results');

@ -66,15 +66,19 @@ if (!empty($group_id)) {
$show_work = true;
} else {
// you are not a teacher
$show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK);
$show_work = GroupManager::user_has_access(
$user_id,
$group_id,
GroupManager::GROUP_TOOL_WORK
);
}
if (!$show_work) {
api_not_allowed();
}
$interbreadcrumb[] = array ('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
}
$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));

Loading…
Cancel
Save