Save comment in edit page see #7769

1.10.x
Julio Montoya 10 years ago
parent aec5d69040
commit 9cf4f221e7
  1. 6
      main/work/edit.php
  2. 16
      main/work/view.php
  3. 7
      main/work/work.lib.php

@ -319,6 +319,12 @@ if (!empty($work_id)) {
$template = $tpl->get_template('work/comments.tpl');
$tpl->assign('comments', $comments);
$commentForm = getWorkCommentForm($work_item, 'edit');
if (api_is_allowed_to_session_edit()) {
$tpl->assign('form', $commentForm);
}
$content .= $form->returnForm();
$content .= $tpl->fetch($template);
}

@ -54,11 +54,20 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
$isDrhOfCourse
) {
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : null;
if ($page == 'edit') {
$url = api_get_path(WEB_CODE_PATH).'work/edit.php?id='.$my_folder_data['id'].'&item_id='.$work['id'].'&'.api_get_cidreq();
} else {
$url = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&'.api_get_cidreq();
}
switch ($action) {
case 'send_comment':
if (isset($_FILES["file"])) {
$_POST['file'] = $_FILES["file"];
}
addWorkComment(
api_get_course_info(),
api_get_user_id(),
@ -66,7 +75,9 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
$work,
$_POST
);
$url = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&'.api_get_cidreq();
Display::addFlash(Display::return_message(get_lang('CommentCreated')));
header('Location: '.$url);
exit;
break;
@ -75,7 +86,8 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
$_REQUEST['comment_id'],
api_get_course_info()
);
$url = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&'.api_get_cidreq();
Display::addFlash(Display::return_message(get_lang('DocDeleted')));
header('Location: '.$url);
exit;
break;

@ -3282,19 +3282,22 @@ function addWorkComment($courseInfo, $userId, $parentWork, $work, $data)
/**
* @param array $work
* @param string $page
* @return string
*/
function getWorkCommentForm($work)
function getWorkCommentForm($work, $page = 'view')
{
$url = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&action=send_comment&'.api_get_cidreq().'&page='.$page;
$form = new FormValidator(
'work_comment',
'post',
api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&action=send_comment&'.api_get_cidreq()
$url
);
$form->addElement('file', 'file', get_lang('Attachment'));
$form->addElement('textarea', 'comment', get_lang('Comment'), array('rows' => '8'));
$form->addElement('hidden', 'id', $work['id']);
$form->addElement('hidden', 'page', $page);
if (api_is_allowed_to_edit()) {
$form->addElement('checkbox', 'send_mail', null, get_lang('SendMail'));
}

Loading…
Cancel
Save