gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
| 3 | * Copyright (c) 2007 Eclipse Foundation and others. |
| 4 | * 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: |
| 10 | * Paul Colton (Aptana)- initial API and implementation |
| 11 | |
| 12 | *******************************************************************************/ |
| 13 | require_once("cb_global.php"); |
| 14 | |
| 15 | |
gobrien | da3a450 | 2008-01-28 23:43:26 +0000 | [diff] [blame] | 16 | |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 17 | $return = ""; |
droy | 8ade936 | 2008-05-14 15:58:39 +0000 | [diff] [blame] | 18 | $language = ""; |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 19 | if(isset($_SESSION['language']) && isset($_SESSION['project'])) { |
droy | 8ade936 | 2008-05-14 15:58:39 +0000 | [diff] [blame] | 20 | $language = $_SESSION['language']; |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 21 | $query = "select DISTINCT |
droy | d664f91 | 2008-05-14 15:45:10 +0000 | [diff] [blame] | 22 | f.version, |
| 23 | f.project_id, |
| 24 | IF(ISNULL(pct_complete),0,ROUND(pct_complete,1)) AS pct_complete |
| 25 | from |
| 26 | project_versions AS v |
| 27 | INNER JOIN files as f on (f.project_id = v.project_id AND f.version = v.version) |
droy | 8ade936 | 2008-05-14 15:58:39 +0000 | [diff] [blame] | 28 | LEFT JOIN project_progress AS p ON (p.project_id = v.project_id AND p.version = v.version and p.language_id = " . addslashes($language) . ") |
droy | d664f91 | 2008-05-14 15:45:10 +0000 | [diff] [blame] | 29 | where |
kitlo | 6cfe513 | 2009-03-15 13:58:21 +0000 | [diff] [blame] | 30 | v.is_active = 1 |
kitlo | 22f4e52 | 2009-03-15 14:00:16 +0000 | [diff] [blame] | 31 | and f.version != 'unspecified' |
kitlo | 6cfe513 | 2009-03-15 13:58:21 +0000 | [diff] [blame] | 32 | and v.project_id = '".addslashes($_SESSION['project'])."' |
| 33 | order by |
| 34 | f.version desc"; |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 35 | |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 36 | $res = mysqli_query($dbh, $query); |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 37 | |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 38 | $return = array(); |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 39 | |
droy | a3815a5 | 2019-09-25 12:49:18 -0400 | [diff] [blame] | 40 | while($line = mysqli_fetch_array($res, MYSQLI_ASSOC)){ |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 41 | $ret = Array(); |
| 42 | $ret['version'] = $line['version']; |
| 43 | $ret['pct'] = $line['pct_complete']; |
droy | d664f91 | 2008-05-14 15:45:10 +0000 | [diff] [blame] | 44 | |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 45 | if(isset($_SESSION['version']) and $line['version'] == $_SESSION['version']){ |
| 46 | $ret['current'] = true; |
| 47 | } |
| 48 | $return[] = $ret; |
gobrien | e4a39c8 | 2008-01-11 00:06:14 +0000 | [diff] [blame] | 49 | } |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 50 | } |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 51 | //print $query."\n"; |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 52 | print json_encode($return); |
| 53 | |
| 54 | ?> |