Minor - format code.

1.9.x
Julio Montoya 12 years ago
parent d7bdfda7b3
commit 9261512b84
  1. 2
      main/work/edit.php
  2. 11
      main/work/view.php
  3. 43
      main/work/work.lib.php

@ -8,7 +8,7 @@ $current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
// Including necessary files
// Including files
require_once 'work.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';

@ -14,6 +14,7 @@ $work = get_work_data_by_id($id);
if (empty($id) || empty($work)) {
api_not_allowed();
}
$interbreadcrumb[] = array ('url' => 'work.php', 'name' => get_lang('StudentPublications'));
$my_folder_data = get_work_data_by_id($work['parent_id']);
@ -29,6 +30,7 @@ if (user_is_author($id) || $course_info['show_score'] == 0 && $work['active'] ==
}
$interbreadcrumb[] = array('url' => $url_dir, 'name' => $my_folder_data['title']);
$interbreadcrumb[] = array('url' => '#','name' => $work['title']);
if (($course_info['show_score'] == 0 && $work['active'] == 1 && $work['accepted'] == 1) ||
api_is_allowed_to_edit() || user_is_author($id)
) {
@ -39,20 +41,19 @@ if (user_is_author($id) || $course_info['show_score'] == 0 && $work['active'] ==
header('Location: '.$url);
exit;
}
$tpl = new Template();
$tpl->assign('work', $work);
$tpl->assign('work_comment_enabled', ALLOW_USER_COMMENTS);
$comments = getWorkComments($work);
$commentForm = getWorkCommentForm($work);
$tpl = new Template();
$tpl->assign('work', $work);
$tpl->assign('work_comment_enabled', ALLOW_USER_COMMENTS);
$tpl->assign('comments', $comments);
$tpl->assign('form', $commentForm);
$template = $tpl->get_template('work/view.tpl');
$content = $tpl->fetch($template);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
} else {
api_not_allowed(true);

@ -2465,35 +2465,50 @@ function get_date_from_select($prefix, $array = array())
/**
* Check if a user is the author of the item
* @param int $item_id
* @param int $user_id
* @param int $itemId
* @param int $userId
* @param int $courseId
* @param int $sessionId
* @return bool
*/
function user_is_author($item_id, $user_id = null)
function user_is_author($itemId, $userId = null, $courseId = null, $sessionId = null)
{
if (empty($item_id)) {
if (empty($itemId)) {
return false;
}
if (empty($user_id)) {
$user_id = api_get_user_id();
if (empty($userId)) {
$userId = api_get_user_id();
}
$is_author = false;
$data = api_get_item_property_info(api_get_course_int_id(), 'work', $item_id, api_get_session_id());
$isAuthor = false;
$is_allowed_to_edit = api_is_allowed_to_edit();
if ($is_allowed_to_edit) {
$is_author = true;
$isAuthor = true;
} else {
if ($data['insert_user_id'] == $user_id) {
$is_author = true;
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
if (empty($sessionId)) {
$sessionId = api_get_session_id();
}
$data = api_get_item_property_info($courseId, 'work', $itemId, $sessionId);
if ($data['insert_user_id'] == $userId) {
$isAuthor = true;
}
/*$workData = get_work_data_by_id($itemId);
if ($workData['user_id'] == $userId) {
$isAuthor = true;
}*/
}
if (!$is_author) {
//api_not_allowed();
if (!$isAuthor) {
return false;
}
return $is_author;
return $isAuthor;
}
/**

Loading…
Cancel
Save