blob: 963d78cffbc8506101ccf77d63764f38433453d1 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2016 Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wayne Beaton (Eclipse Foundation)- initial API and implementation
*******************************************************************************/
/*
* Export information about a project. This exists primarily to
* feed data into slack.
*
* The script assumes that it is being invoked via GET.
*/
require_once(dirname(__FILE__) . "/../../eclipse.org-common/system/app.class.php");
$App = new App();
require_once(dirname(__FILE__) . "/../classes/Project.class.php");
require_once(dirname(__FILE__) . "/../classes/database.inc");
require_once(dirname(__FILE__) . "/../classes/common.php");
require_once(dirname(__FILE__) . "/../classes/debug.php");
function getProjectBaseUrl($id) {
return 'https://projects.eclipse.org/projects/' . $id;
}
if (!$id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['text'] : @$_POST['text']) {
$data = array(
'response_type' => 'ephemeral',
'text' => "Specify either the full id (e.g. technology.egit) or short name (e.g. egit) of a project." . join("\n", $_GET)
);
header('Content-Type: application/json');
echo json_encode($data);
exit;
}
// FIXME Use the Forge class.
$sql = "
select
ProjectID as id, Name as name
from Projects
where IsActive
and (ProjectID like '%:id%' or Name like '%:id%')
limit 10";
$projects = array();
query('foundation', $sql, array(':id' => $id), function($row) use (&$projects) {
$id = $row['id'];
if ($project = Project::getProject($id)) {
$name = $project->getFormalName();
$url = $project->getUrl();
$ipzilla = "https://dev.eclipse.org/ipzilla/buglist.cgi?component=$id";
$metrics = "https://www.eclipse.org/projects/tools/report.php?id=$id";
$projects[] = "$name [<$url|overview>|<$url/downloads|downloads>|<$url/who|who>|<$ipzilla|cqs>|<$metrics|metrics>]";
}
});
if (!$projects) {
$data = array(
'response_type' => 'ephemeral',
'text' => "No projects found."
);
header('Content-Type: application/json');
echo json_encode($data);
exit;
}
$data = array(
'response_type' => 'ephemeral',
'text' => join("\n", $projects)
);
header('Content-Type: application/json');
echo json_encode($data);
?>