Example #1
0
<?php

$app['controllers']['tag/getall'] = function ($app, $request) {
    $idProject = !empty($request['id_project']) ? (int) $request['id_project'] : null;
    if (!is_null($idProject)) {
        $tags = $app['bugmanager']->getAllTagsFromProject($idProject);
        Response::responseWithSuccess(['tags' => $tags]);
    } else {
        Response::responseWithError($app['i18n']['errors']['empty_id_project']);
    }
};
Example #2
0
<?php

$app['controllers']['tag/setstatus'] = function ($app, $request) {
    $idTag = !empty($request['id_tag']) ? $request['id_tag'] : null;
    $status = !empty($request['status']) ? $request['status'] : null;
    if (empty($status)) {
        $result = false;
        $errorMsg = $app['i18n']['errors']['empty_tag_status'];
    } elseif (empty($idTag)) {
        $result = false;
        $errorMsg = $app['i18n']['errors']['empty_id_tag'];
    } else {
        $result = $app['bugmanager']->setTagStatus($idTag, $status);
        $errorMsg = $app['i18n']['errors']['cannot_update_tag_status'];
    }
    if ($result) {
        Response::responseWithSuccess([], $app['i18n']['bugmanager']['tag_status_updated']);
    } else {
        Response::responseWithError($errorMsg);
    }
};
Example #3
0
<?php

$app['controllers']['issue/getall'] = function ($app, $request) {
    $idProject = !empty($request['id_project']) ? (int) $request['id_project'] : null;
    if (!is_null($idProject)) {
        $issues = $app['bugmanager']->getAllIssuesFromProject($idProject);
        Response::responseWithSuccess(['issues' => $issues]);
    } else {
        Response::responseWithError($app['i18n']['errors']['empty_id_project']);
    }
};
Example #4
0
<?php

$app['controllers']['project/save'] = function ($app, $request) {
    parse_str($request['form'], $form);
    $idProject = !empty($form['id_project']) ? $form['id_project'] : null;
    if (empty($form['name'])) {
        $result = false;
        $errorMsg = $app['i18n']['errors']['empty_project_name'];
    } else {
        $result = $app['bugmanager']->saveProject($form['name'], $idProject);
        $error = $app['bugmanager']->getError();
        $errorMsg = $error[2];
    }
    if ($result) {
        Response::responseWithSuccess(['id_project' => $result], $app['i18n']['bugmanager']['project_saved']);
    } else {
        Response::responseWithError($errorMsg);
    }
};
Example #5
0
<?php

$app['controllers']['issue/getone'] = function ($app, $request) {
    $idProject = !empty($request['id_project']) ? $request['id_project'] : null;
    $idIssue = !empty($request['id_issue']) ? $request['id_issue'] : null;
    $result = true;
    $response = [];
    $response['issue_types'] = $app['config']['issue_types'];
    if (empty($idProject)) {
        $result = false;
        $errorMsg = $app['i18n']['errors']['empty_id_project'];
    }
    $response['tags'] = !empty($idProject) ? $app['bugmanager']->getAllTagsFromProject($idProject) : [];
    $response['issue'] = !empty($idIssue) ? $app['bugmanager']->getIssue($idIssue) : [];
    if ($result) {
        Response::responseWithSuccess($response);
    } else {
        Response::responseWithError($errorMsg);
    }
};
Example #6
0
<?php

$app['controllers']['tag/delete'] = function ($app, $request) {
    $idTag = !empty($request['id_tag']) ? $request['id_tag'] : null;
    if (empty($idTag)) {
        $result = false;
        $errorMsg = $app['i18n']['errors']['empty_id_tag'];
    } else {
        $result = $app['bugmanager']->deleteTag($idTag);
        $error = $app['bugmanager']->getError();
        $errorMsg = $error[2];
    }
    if ($result) {
        Response::responseWithSuccess([], $app['i18n']['bugmanager']['tag_removed']);
    } else {
        Response::responseWithError($errorMsg);
    }
};
Example #7
0
<?php

$app['controllers']['project/getall'] = function ($app, $request) {
    $projects = $app['bugmanager']->getAllProjects();
    Response::responseWithSuccess(['projects' => $projects]);
};
Example #8
0
<?php

$app['controllers']['issue/save'] = function ($app, $request) {
    parse_str(urldecode($request['form']), $arr);
    $idIssue = !empty($arr['id_issue']) ? $arr['id_issue'] : null;
    $arr['id_project'] = !empty($request['id_project']) ? (int) $request['id_project'] : null;
    if (empty($arr['id_project'])) {
        $result = false;
        $errorMsg = $app['i18n']['errors']['empty_id_project'];
    } else {
        $result = $app['bugmanager']->saveIssue($arr, $arr['id_project'], $idIssue);
        $error = $app['bugmanager']->getError();
        $errorMsg = $error[2];
    }
    if ($result) {
        Response::responseWithSuccess([], $app['i18n']['bugmanager']['issue_saved']);
    } else {
        Response::responseWithError($errorMsg);
    }
};
Example #9
0
<?php

$app['controllers']['tag/save'] = function ($app, $request) {
    parse_str($request['form'], $form);
    $idTag = !empty($form['id_tag']) ? $form['id_tag'] : null;
    $version = !empty($form['version']) ? $form['version'] : null;
    $idProject = !empty($request['id_project']) ? (int) $request['id_project'] : null;
    if (empty($version)) {
        $result = false;
        $errorMsg = $app['i18n']['errors']['empty_tag_version'];
    } elseif (empty($idProject)) {
        $result = false;
        $errorMsg = $app['i18n']['errors']['empty_id_project'];
    } else {
        $result = $app['bugmanager']->saveTag($version, $idProject, $idTag);
        $error = $app['bugmanager']->getError();
        $errorMsg = $error[2];
    }
    if ($result) {
        Response::responseWithSuccess(['id_tag' => $result], $app['i18n']['bugmanager']['tag_saved']);
    } else {
        Response::responseWithError($errorMsg);
    }
};
Example #10
0
<?php

$app['controllers']['tag/getone'] = function ($app, $request) {
    $idTag = !empty($request['id_tag']) ? (int) $request['id_tag'] : null;
    if (!is_null($idTag)) {
        $tag = $app['bugmanager']->getTag($idTag);
        Response::responseWithSuccess(['tag' => $tag]);
    } else {
        Response::responseWithError($app['i18n']['errors']['empty_id_tag']);
    }
};
Example #11
0
    parse_str(urldecode($request['form']), $form);
    $idProject = !empty($form['id_project']) ? $form['id_project'] : null;
    $code = !empty($form['code']) ? $form['code'] : null;
    $arr = !empty($form['translation']) ? $form['translation'] : array();
    if (empty($idProject)) {
        $result = false;
        $errorMsg = $app['i18n']['errors']['empty_id_project'];
    } elseif (empty($code) || $isCodeValid($code) === false) {
        $result = false;
        $errorMsg = $app['i18n']['errors']['not_valid_project_code'];
    } else {
        $result = $app['foler']->saveTranslation($idProject, $code, $arr);
        $errorMsg = $app['foler']->getError();
    }
    if ($result) {
        Response::responseWithSuccess(array(), $app['i18n']['foler']['translation_saved']);
    } else {
        Response::responseWithError($errorMsg);
    }
};
// Source: config/footer.php
$app['foler'] = new Foler($app['config']['db']['dsn'], $app['config']['db']['user'], $app['config']['db']['password'], $app['i18n']);
try {
    $app['foler']->connect();
} catch (Exception $exc) {
    Response::responseWithError($exc->getMessage());
}
$i18n = $app['i18n'] = $app['i18n'][$app['locale']];
if (!empty($_REQUEST['action']) && isset($app['controllers'][$_REQUEST['action']])) {
    $app['controllers'][$_REQUEST['action']]($app, $_REQUEST);
    die;