summaryrefslogtreecommitdiffstats
path: root/non-puppet/qtmetrics2/index.php
diff options
context:
space:
mode:
authorJuha Sippola <juhasippola@outlook.com>2015-09-21 16:20:56 +0300
committerTony Sarajärvi <tony.sarajarvi@theqtcompany.com>2015-09-23 09:39:14 +0000
commit0624492bcf28308982e4e3116adcfbc8da29799e (patch)
treeaa64d2e5df3cd8114ccbbb0de95b112ab60782d9 /non-puppet/qtmetrics2/index.php
parent2eca1988760d8ab51d0cb2a2616ffa022a1647ea (diff)
Qt Metrics 2 (v0.28): Branch archiving
Added buttons to archive (and restore) a branch on the admin pages. Added field 'archived' to the branch table in the database. Change-Id: Idefddd15df02014ce70c5c4f981eb5938c4bf5f7 Reviewed-by: Tony Sarajärvi <tony.sarajarvi@theqtcompany.com>
Diffstat (limited to 'non-puppet/qtmetrics2/index.php')
-rw-r--r--non-puppet/qtmetrics2/index.php50
1 files changed, 49 insertions, 1 deletions
diff --git a/non-puppet/qtmetrics2/index.php b/non-puppet/qtmetrics2/index.php
index 02a232f..fc4e3fb 100644
--- a/non-puppet/qtmetrics2/index.php
+++ b/non-puppet/qtmetrics2/index.php
@@ -34,7 +34,7 @@
/**
* Qt Metrics API
- * @since 15-09-2015
+ * @since 17-09-2015
* @author Juha Sippola
*/
@@ -713,6 +713,54 @@ $app->delete('/api/branch/:branch', function($branch) use($app)
})->name('delete_branch');
/**
+ * API route: /api/branch/archive (PUT) - authenticated
+ */
+
+$app->add(new HttpBasicAuthRoute('Protected Area', 'api/branch/archive'));
+$app->put('/api/branch/archive/:branch', function($branch) use($app)
+{
+ $branch = strip_tags($branch);
+ $branches = array();
+ $query = Factory::db()->getBranches();
+ foreach($query as $item) {
+ $branches[] = $item['name'];
+ }
+ if (in_array($branch, $branches)) {
+ $result = Factory::dbAdmin()->archiveBranch($branch);
+ if ($result)
+ $app->response()->status(200);
+ else
+ $app->response()->status(404);
+ } else {
+ $app->response()->status(404);
+ }
+})->name('archive_branch');
+
+/**
+ * API route: /api/branch/restore (PUT) - authenticated
+ */
+
+$app->add(new HttpBasicAuthRoute('Protected Area', 'api/branch/restore'));
+$app->put('/api/branch/restore/:branch', function($branch) use($app)
+{
+ $branch = strip_tags($branch);
+ $branches = array();
+ $query = Factory::db()->getBranches();
+ foreach($query as $item) {
+ $branches[] = $item['name'];
+ }
+ if (in_array($branch, $branches)) {
+ $result = Factory::dbAdmin()->restoreBranch($branch);
+ if ($result)
+ $app->response()->status(200);
+ else
+ $app->response()->status(404);
+ } else {
+ $app->response()->status(404);
+ }
+})->name('restore_branch');
+
+/**
* API route: /api/data (DELETE) - authenticated
*/