blob: df0bf0e74f2bc1471fd53f10aca0f95515465904 [file] [log] [blame]
gobrienda265d32008-01-24 01:08:14 +00001<?php
2/*******************************************************************************
droy6b0166c2008-07-23 17:23:07 +00003 * Copyright (c) 2008 Eclipse Foundation and others.
gobrienda265d32008-01-24 01:08:14 +00004 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
droy6b0166c2008-07-23 17:23:07 +000010 * Eclipse Foundation - Initial API and implementation
gobrienda265d32008-01-24 01:08:14 +000011
12*******************************************************************************/
13require_once("cb_global.php");
14
gobrien0436d992008-01-31 00:08:04 +000015$return = array();
16
gobrien0436d992008-01-31 00:08:04 +000017if(!isset($_SESSION['project']) or !isset($_SESSION['version'])){
18 return $return;
19}
20
gobrien0f69b6d2008-02-29 19:14:21 +000021$language = "";
droy5d4b64c2008-02-29 15:22:10 +000022if(isset($_SESSION['language'])) {
23 $language = $_SESSION['language'];
24}
gobrienda265d32008-01-24 01:08:14 +000025
atoulme3e5e9342009-01-23 17:34:30 +000026$parameter = getHTTPParameter("order", "POST");
kitloa7c93ee2008-07-19 14:21:55 +000027
28if ($parameter == "name" or $parameter == "completion") {
29 $_SESSION['filesOrder'] = $parameter;
30}
31
32if (!isset($_SESSION['filesOrder'])) {
33 $_SESSION['filesOrder'] = "name";
34}
35
36if ($_SESSION['filesOrder'] == "name") {
37 $order = "f.name";
38} else {
39 $order = "pct_complete";
40}
41
droy5d4b64c2008-02-29 15:22:10 +000042$query = "SELECT
43 f.name,
44 IF(ISNULL(pct_complete),0,pct_complete) AS pct_complete
45FROM
46 files AS f
47 LEFT JOIN project_versions AS v ON v.project_id = f.project_id
48 AND v.version = f.version
49 LEFT JOIN file_progress as p ON p.file_id = f.file_id
50 AND p.language_id = '" . addslashes($language) . "'
51WHERE
droyc3eaa7a2009-01-21 21:32:06 +000052 v.is_active = 1
53 AND f.is_active = 1
droy5d4b64c2008-02-29 15:22:10 +000054 AND v.project_id = '".addslashes($_SESSION['project'])."'
55 AND f.version = '".addslashes($_SESSION['version'])."'
56 GROUP BY f.name
kitloa7c93ee2008-07-19 14:21:55 +000057 ORDER BY ".$order;
droy5d4b64c2008-02-29 15:22:10 +000058
59# print $query."\n";
gobrienda265d32008-01-24 01:08:14 +000060
61$res = mysql_query($query,$dbh);
62
gobrien0436d992008-01-31 00:08:04 +000063
gobrienda265d32008-01-24 01:08:14 +000064while($line = mysql_fetch_array($res, MYSQL_ASSOC)){
65 $ret = Array();
droy5d4b64c2008-02-29 15:22:10 +000066
gobrienda265d32008-01-24 01:08:14 +000067 $ret['name'] = $line['name'];
droy5d4b64c2008-02-29 15:22:10 +000068 $ret['pct'] = $line['pct_complete'];
69
gobrienda3a4502008-01-28 23:43:26 +000070
71 if(isset($_SESSION['file']) and $line['name'] == $_SESSION['file']){
gobrienda265d32008-01-24 01:08:14 +000072 $ret['current'] = true;
73 }
74 $return[] = $ret;
75}
76
gobrienda265d32008-01-24 01:08:14 +000077print json_encode($return);
78
79?>