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 | |
| 17 | if(!isset($_SESSION['project'])){ |
| 18 | return array(); |
| 19 | } |
| 20 | |
droy | 8ade936 | 2008-05-14 15:58:39 +0000 | [diff] [blame^] | 21 | $language = ""; |
| 22 | if(isset($_SESSION['language'])) { |
| 23 | $language = $_SESSION['language']; |
| 24 | } |
| 25 | |
| 26 | |
droy | d664f91 | 2008-05-14 15:45:10 +0000 | [diff] [blame] | 27 | $query = "select DISTINCT |
| 28 | f.version, |
| 29 | f.project_id, |
| 30 | IF(ISNULL(pct_complete),0,ROUND(pct_complete,1)) AS pct_complete |
| 31 | from |
| 32 | project_versions AS v |
| 33 | 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^] | 34 | 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] | 35 | where |
| 36 | v.is_active = 1 |
| 37 | and v.project_id = '".addslashes($_SESSION['project'])."'"; |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 38 | |
| 39 | //print $query."\n"; |
| 40 | |
| 41 | $res = mysql_query($query,$dbh); |
| 42 | |
gobrien | 4b7797e | 2008-01-31 20:10:02 +0000 | [diff] [blame] | 43 | $return = array(); |
| 44 | |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 45 | while($line = mysql_fetch_array($res, MYSQL_ASSOC)){ |
| 46 | $ret = Array(); |
| 47 | $ret['version'] = $line['version']; |
droy | d664f91 | 2008-05-14 15:45:10 +0000 | [diff] [blame] | 48 | $ret['pct'] = $line['pct_complete']; |
| 49 | |
gobrien | da3a450 | 2008-01-28 23:43:26 +0000 | [diff] [blame] | 50 | if(isset($_SESSION['version']) and $line['version'] == $_SESSION['version']){ |
gobrien | e4a39c8 | 2008-01-11 00:06:14 +0000 | [diff] [blame] | 51 | $ret['current'] = true; |
| 52 | } |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 53 | $return[] = $ret; |
| 54 | } |
| 55 | |
| 56 | print json_encode($return); |
| 57 | |
| 58 | ?> |