Minor - making a query readable!

1.9.x
Julio Montoya 12 years ago
parent 5aeeba5b4e
commit 64e8f29b03
  1. 25
      main/work/work.lib.php

@ -1446,8 +1446,7 @@ function get_count_work($work_id, $onlyMeUserId = null, $notMeUserId = null)
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$session_id = api_get_session_id();
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$course_id = api_get_course_int_id();
@ -1484,13 +1483,20 @@ function get_count_work($work_id, $onlyMeUserId = null, $notMeUserId = null)
$where_condition .= " AND u.user_id = ".intval($onlyMeUserId);
}
$sql = "SELECT count(*) as count ".
" FROM ".$iprop_table." prop INNER JOIN ".$work_table." work ".
" ON (prop.ref=work.id AND prop.c_id = $course_id ".
" AND prop.tool='work' AND work.active = 1 ".
" AND prop.visibility <> 2 AND work.c_id = $course_id ) ".
" INNER JOIN $user_table u ON (work.user_id = u.user_id) ".
" WHERE $extra_conditions $where_condition $condition_session ";
$sql = "SELECT count(*) as count
FROM $iprop_table prop
INNER JOIN $work_table work
ON (
prop.ref = work.id AND
prop.c_id = $course_id AND
prop.tool='work' AND
work.active = 1 AND
prop.visibility <> 2 AND
work.c_id = $course_id
)
INNER JOIN $user_table u ON (work.user_id = u.user_id)
WHERE $extra_conditions $where_condition $condition_session";
$result = Database::query($sql);
$users_with_work = 0;
@ -1657,7 +1663,6 @@ function getWorkListTeacher($start, $limit, $column, $direction, $where_conditio
$work['title'] = basename($work['url']);
}
$work['title'] = Display::url($work['title'], $url.'&id='.$workId);
$work['title'] .= ' '.Display::label(get_count_work($work['id']), 'success');
$work['sent_date'] = date_to_str_ago($work['sent_date']).' <br />'.api_get_local_time($work['sent_date']);

Loading…
Cancel
Save