parent
3d730ace32
commit
b0e020cf40
@ -0,0 +1,126 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
use ChamiloSession as Session; |
||||
|
||||
$language_file = array('exercice', 'work', 'document', 'admin', 'gradebook'); |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
// Including necessary files |
||||
require_once 'work.lib.php'; |
||||
|
||||
if (ADD_DOCUMENT_TO_WORK == false) { |
||||
exit; |
||||
} |
||||
|
||||
$current_course_tool = TOOL_STUDENTPUBLICATION; |
||||
|
||||
$workId = isset($_GET['id']) ? intval($_GET['id']) : null; |
||||
$docId = isset($_GET['document_id']) ? intval($_GET['document_id']) : null; |
||||
$action = isset($_GET['action']) ? $_GET['action'] : null; |
||||
|
||||
if (empty($workId)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$my_folder_data = get_work_data_by_id($workId); |
||||
if (empty($my_folder_data)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$work_data = get_work_assignment_by_id($workId); |
||||
|
||||
if (!api_is_allowed_to_edit()) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$courseInfo = api_get_course_info(); |
||||
|
||||
$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' => '#', 'name' => get_lang('AddDocument')); |
||||
|
||||
$error_message = null; |
||||
|
||||
switch ($action) { |
||||
case 'delete': |
||||
if (!empty($workId) && !empty($docId)) { |
||||
deleteDocumentToWork($docId, $workId, api_get_course_int_id()); |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId; |
||||
header('Location: '.$url); |
||||
exit; |
||||
} |
||||
break; |
||||
} |
||||
|
||||
Display :: display_header(null); |
||||
|
||||
if (empty($docId)) { |
||||
echo Display::page_subheader(get_lang('DocumentsAdded')); |
||||
|
||||
$documents = getAllDocumentToWork($workId, api_get_course_int_id()); |
||||
if (!empty($documents)) { |
||||
echo '<div class="well">'; |
||||
foreach ($documents as $doc) { |
||||
$documentId = $doc['document_id']; |
||||
$docData = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']); |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_document.php?action=delete&id='.$workId.'&document_id='.$documentId; |
||||
$link = Display::url(get_lang('Delete'), $url); |
||||
echo $docData['title'].' '.$link.'<br />'; |
||||
} |
||||
echo '</div>'; |
||||
} |
||||
|
||||
$document_tree = DocumentManager::get_document_preview($courseInfo, null, null, 0, false, '/', api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId); |
||||
echo Display::page_subheader(get_lang('DocumentToAdd')); |
||||
echo $document_tree; |
||||
echo '<hr /><div class="clear"></div>'; |
||||
|
||||
} else { |
||||
|
||||
$documentInfo = DocumentManager::get_document_data_by_id($docId, $courseInfo['code']); |
||||
$form = new FormValidator('add_doc', 'post', api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId.'&document_id='.$docId); |
||||
$form->addElement('header', get_lang('AddDocument')); |
||||
$form->addElement('hidden', 'add_doc', '1'); |
||||
$form->addElement('hidden', 'id', $workId); |
||||
$form->addElement('hidden', 'document_id', $docId); |
||||
$form->addElement('label', get_lang('File'), $documentInfo['title']); |
||||
$form->addElement('style_submit_button', 'submit', get_lang('Add')); |
||||
$form->display(); |
||||
|
||||
if ($form->validate()) { |
||||
$values = $form->exportValues(); |
||||
$workId = $values['id']; |
||||
$docId = $values['document_id']; |
||||
$data = getDocumentToWork($docId, $workId, api_get_course_int_id()); |
||||
|
||||
if (empty($data)) { |
||||
addDocumentToWork($docId, $workId, api_get_course_int_id()); |
||||
Display::display_confirmation_message(get_lang('Added')); |
||||
} else { |
||||
Display::display_warning_message(get_lang('DocumentAlreadyAdded')); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* |
||||
* |
||||
CREATE TABLE IF NOT EXISTS c_student_publication_rel_document ( |
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, |
||||
work_id INT NOT NULL, |
||||
document_id INT NOT NULL, |
||||
c_id INT NOT NULL |
||||
); |
||||
|
||||
CREATE TABLE IF NOT EXISTS c_student_publication_rel_user ( |
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, |
||||
work_id INT NOT NULL, |
||||
user_id INT NOT NULL, |
||||
c_id INT NOT NULL |
||||
); |
||||
|
||||
|
||||
|
||||
*/ |
||||
|
||||
|
||||
@ -0,0 +1,96 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
use ChamiloSession as Session; |
||||
|
||||
$language_file = array('exercice', 'work', 'document', 'admin', 'gradebook'); |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
// Including necessary files |
||||
require_once 'work.lib.php'; |
||||
|
||||
if (ADD_DOCUMENT_TO_WORK == false) { |
||||
exit; |
||||
} |
||||
|
||||
$current_course_tool = TOOL_STUDENTPUBLICATION; |
||||
|
||||
$workId = isset($_GET['id']) ? intval($_GET['id']) : null; |
||||
$userId = isset($_GET['user_id']) ? intval($_GET['user_id']) : null; |
||||
$action = isset($_GET['action']) ? $_GET['action'] : null; |
||||
|
||||
if (empty($workId)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$my_folder_data = get_work_data_by_id($workId); |
||||
if (empty($my_folder_data)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$work_data = get_work_assignment_by_id($workId); |
||||
|
||||
if (!api_is_allowed_to_edit()) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$courseInfo = api_get_course_info(); |
||||
|
||||
$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' => '#', 'name' => get_lang('AddUser')); |
||||
|
||||
$error_message = null; |
||||
|
||||
switch ($action) { |
||||
case 'add': |
||||
|
||||
addUserToWork($userId, $workId, api_get_course_int_id()); |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?id='.$workId; |
||||
header('Location: '.$url); |
||||
exit; |
||||
|
||||
break; |
||||
case 'delete': |
||||
if (!empty($workId) && !empty($userId)) { |
||||
deleteUserToWork($userId, $workId, api_get_course_int_id()); |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?id='.$workId; |
||||
header('Location: '.$url); |
||||
exit; |
||||
} |
||||
break; |
||||
} |
||||
|
||||
Display :: display_header(null); |
||||
|
||||
echo Display::page_subheader(get_lang('UsersAdded')); |
||||
|
||||
$items = getAllUserToWork($workId, api_get_course_int_id()); |
||||
if (!empty($items)) { |
||||
echo '<div class="well">'; |
||||
foreach ($items as $data) { |
||||
$myUserId = $data['user_id']; |
||||
$userInfo = api_get_user_info($myUserId); |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?action=delete&id='.$workId.'&user_id='.$myUserId; |
||||
$link = Display::url(get_lang('Delete'), $url); |
||||
echo $userInfo['complete_name'].' '.$link.'<br />'; |
||||
} |
||||
echo '</div>'; |
||||
} |
||||
|
||||
$userList = CourseManager::get_user_list_from_course_code($courseInfo['code'], api_get_session_id(), null, null, STUDENT); |
||||
|
||||
echo Display::page_subheader(get_lang('UserToAdd')); |
||||
if (!empty($userList)) { |
||||
echo '<div class="well">'; |
||||
foreach ($userList as $user) { |
||||
$userName = api_get_person_name($user['firstname'], $user['lastname']); |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?action=add&id='.$workId.'&user_id='.$user['user_id']; |
||||
$link = Display::url(get_lang('Add'), $url); |
||||
echo $userName.' '.$link.'<br />'; |
||||
} |
||||
echo '</div>'; |
||||
} |
||||
|
||||
|
||||
echo '<hr /><div class="clear"></div>'; |
||||
Loading…
Reference in new issue