Skip to content

Commit

Permalink
New API to get db locales
Browse files Browse the repository at this point in the history
  • Loading branch information
DawoudIO committed May 15, 2021
1 parent 20d83b7 commit a06780d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api/index.php
Expand Up @@ -64,6 +64,7 @@
require __DIR__ . '/routes/system/system-register.php';
require __DIR__ . '/routes/system/system-upgrade.php';
require __DIR__ . '/routes/system/system-custom-menu.php';
require __DIR__ . '/routes/system/system-locale.php';

// other
require __DIR__ . '/routes/cart.php';
Expand Down
57 changes: 57 additions & 0 deletions src/api/routes/system/system-locale.php
@@ -0,0 +1,57 @@
<?php

use Slim\Http\Request;
use Slim\Http\Response;
use ChurchCRM\UserConfigQuery;
use ChurchCRM\PredefinedReportsQuery;
use ChurchCRM\QueryParameterOptionsQuery;
use ChurchCRM\QueryParametersQuery;
use ChurchCRM\Slim\Middleware\Request\Auth\AdminRoleAuthMiddleware;

$app->group('/locale', function () {
$this->get('/database/terms', 'getDBTerms');
})->add(new AdminRoleAuthMiddleware());


/**
* A method that gets locale terms from the db for po generation
*
* @param \Slim\Http\Request $p_request The request.
* @param \Slim\Http\Response $p_response The response.
* @param array $p_args Arguments
* @return \Slim\Http\Response The augmented response.
*/
function getDBTerms(Request $request, Response $response, array $p_args)
{
$terms = array();

$dbTerms = UserConfigQuery::create()->select(array('ucfg_tooltip'))->distinct()->find();
foreach ($dbTerms as $term) {
array_push($terms, $term);
}

$dbTerms = QueryParameterOptionsQuery::create()->select(array('qpo_Display'))->distinct()->find();
foreach ($dbTerms as $term) {
array_push($terms, $term);
}

$dbTerms = PredefinedReportsQuery::create()->select(array('qry_Name','qry_Description'))->distinct()->find();
foreach ($dbTerms as $term) {
array_push($terms, $term['qry_Name']);
array_push($terms, $term['qry_Description']);
}

$dbTerms = QueryParametersQuery::create()->select(array('qrp_Name','qrp_Description'))->distinct()->find();
foreach ($dbTerms as $term) {
array_push($terms, $term['qrp_Name']);
array_push($terms, $term['qrp_Description']);
}



return $response->withJson(['terms' => $terms]);

}



0 comments on commit a06780d

Please sign in to comment.