Indefero

Indefero Commit Details


Date:2011-03-07 08:01:51 (13 years 9 months ago)
Author:William MARTIN
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.1, release-1.2, release-1.3
Commit:c3cd49438660e4bb8b7d6ea6d3a5d3fdbe4a8d61
Parents: fba5841bdc1fcd34207b775e093416d3470d23ef
Message:Add Project List API

Changes:

File differences

src/IDF/Precondition.php
190190
191191
192192
193
193
194
195
196
197
198
194199
195200
196201
......
256261
257262
258263
259
264
return true; // Again need authentication error
}
$request->user = $users[0];
IDF_Middleware::setRights($request);
// Don't try to load projects rights access if we are not in one
if ($request->query !== "/api/") {
IDF_Middleware::setRights($request);
}
return true;
}
$encrypted = trim($cr->encrypt($user->id.':'.$project->id), '~');
return substr(md5(Pluf::f('secret_key').$encrypted), 0, 2).$encrypted;
}
}
}
src/IDF/Views.php
3737
3838
3939
40
40
4141
4242
4343
44
45
4446
4547
4648
* Only the public projects are listed or the private with correct
* rights.
*/
public function index($request, $match)
public function index($request, $match, $api=false)
{
$projects = self::getProjects($request->user);
$stats = self::getProjectsStatistics ($projects);
if ($api == true) return $projects;
return Pluf_Shortcuts_RenderToResponse('idf/index.html',
array('page_title' => __('Projects'),
'projects' => $projects,
src/IDF/Views/Api.php
6464
6565
6666
67
67
6868
6969
7070
......
7676
7777
7878
79
79
8080
8181
82
82
8383
8484
8585
......
8787
8888
8989
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
90111
91112
92113
$out = array();
if ($request->method == 'GET') {
// We give the details of the form
$out['doc'] = 'A POST request against this url will allow you to create a new issue.';
$out['help'] = 'A POST request against this url will allow you to create a new issue.';
if ($request->user->hasPerm('IDF.project-owner', $request->project)
or $request->user->hasPerm('IDF.project-member', $request->project)) {
$out['status'] = array();
} else {
// We need to give back the results of the creation
if (is_object($p) and 'IDF_Issue' == get_class($p)) {
$out['mess'] = 'success';
$out['message'] = 'success';
$out['issue'] = $p->id;
} else {
$out['mess'] = 'error';
$out['message'] = 'error';
$out['errors'] = $p['form']->errors;
}
}
}
/**
* List all the projects
*/
public $projectIndex_precond = array('IDF_Precondition::apiSetUser');
public function projectIndex($request, $match)
{
$view = new IDF_Views();
$projects = $view->index($request, $match, true);
$data = array();
foreach ($projects as $p) {
$data[] = array("shortname" => $p->shortname, "name" => $p->name, "shortdesc" => $p->shortdesc, "private" => $p->private);
}
$out = array();
$out['message'] = 'success';
$out['projects'] = $data;
return new Pluf_HTTP_Response_Json($out);
}
/**
* Get the list of tags to give them to the end users when doing a
* GET request against a form. That way it is possible for them to
* know which tags/labels are available.
src/IDF/conf/urls.php
364364
365365
366366
367
368
369
370
371
367372
368373
369374
'model' => 'IDF_Views_Api',
'method' => 'issueCreate');
$ctl[] = array('regex' => '#^/api/$#',
'base' => $base,
'model' => 'IDF_Views_Api',
'method' => 'projectIndex');
// ---------- FORGE ADMIN --------------------------------
$ctl[] = array('regex' => '#^/admin/projects/$#',

Archive Download the corresponding diff file

Page rendered in 0.08784s using 13 queries.