Skip to content

Commit

Permalink
feat: big update
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Nov 17, 2021
1 parent bf34506 commit b60fbe4
Show file tree
Hide file tree
Showing 161 changed files with 34,599 additions and 19,421 deletions.
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.

**GLPI / Plugins (please complete the following information):**
- GLPI version
- list of all plugins (available in GLPI > Setup > General > tab System > bottom of the page)

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
ATOUM_ARG: --force-terminal
NOCOVERAGE: -ncc
COVERAGE: --nccfc CommonTreeDropdown CommonDropdown CommonDBTM CommonGLPI CommonDBConnexity CommonDBRelation CommonDBChild
PANTHER_CHROME_DRIVER_BINARY: chromedriver
CHROME_DRIVER_BINARY: chromedriver

jobs:
tests:
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
composer --version
chromium-browser --version
ls -l /usr/bin/chromium*
$PANTHER_CHROME_DRIVER_BINARY --version
$CHROME_DRIVER_BINARY --version
- name: "Checkout"
uses: actions/checkout@v2
- name: "Run tests"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ vendor/
.buildpath
.project
/.gtm/
lib/

# Ignore content of data except for the index
data/*
Expand All @@ -17,3 +18,5 @@ tests/logs/

# Ignore code coverage
development/

node_modules/
55 changes: 55 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
image: composer

services:
- mysql:latest

variables:
DB_HOST: mysql
MYSQL_ROOT_USER: root
MYSQL_ROOT_PASSWORD: root
GLPI_SOURCE: "https://github.com/glpi-project/glpi"
GLPI_BRANCH: master
CS: "7.4"
DB_USER: "glpi"
DB_PASSWD: "glpi"
DB_NAME: "glpitest"
OLD_DB_NAME: "glpiupgradetest"
PLUGINNAME: "formcreator"
AFTER_SUCCESS_BRANCH: "master"
ATOUM_ARG: "--force-terminal --use-light-report"
NOCOVERAGE: "-ncc"
COVERAGE: "--nccfc CommonTreeDropdown CommonDropdown CommonDBTM CommonGLPI CommonDBConnexity CommonDBRelation CommonDBChild"
PANTHER_CHROME_DRIVER_BINARY: "chromedriver"
SKIP_INIT: "false"
SKIP_FRESH_GLPI_INSTALL: "false"
SKIP_UPGRADE_GLPI_INSTALL: "false"
SKIP_INSTALL_PLUGIN_DEPENDENCIES: "false"
SKIP_UPGRADE_TESTS: "false"
SKIP_INSTALL_TESTS: "false"
SKIP_TESTS: "false"
SKIP_FUNCTIONAL_TESTS: "true"
SKIP_UNINSTALLL_TESTS: "false"
SKIP_LINT_TESTS: "false"
SKIP_CS_TESTS: "false"
SKIP_PANTHER_INSTALL: "true"

stages:
- test

test:
image: php:7.4-cli
stage: test
before_script:
- tests/docker_install.sh
- tests/yarn.sh
- tests/composer.sh
- php --version
- composer --version
- mysql --version
- yarn --version
- composer install

variables:

script:
- tests/testall.sh
2 changes: 1 addition & 1 deletion .tx/config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[main]
host = https://www.transifex.com

[glpi-project-plugin-formcreator.v2_11_0]
[glpi-project-plugin-formcreator.v2_13_0]
file_filter = locales/<lang>.po
source_file = locales/glpi.pot
source_lang = en_GB
Expand Down
677 changes: 677 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ At the same time, the plugin allow the creation of one or more tickets when the

| **LTS** | **Beta** | **Bleeding Edge** |
|:---:|:---:|:---:|
| ![unit tests](https://github.com/pluginsGLPI/formcreator/workflows/unit%20tests/badge.svg?branch=support%2F2.10.0) | ![unit tests](https://github.com/pluginsGLPI/formcreator/workflows/unit%20tests/badge.svg?branch=support%2F2.11.0) |![unit tests](https://github.com/pluginsGLPI/formcreator/workflows/unit%20tests/badge.svg?branch=develop) |
| ![unit tests](https://github.com/pluginsGLPI/formcreator/workflows/unit%20tests/badge.svg?branch=master) | ![unit tests](https://github.com/pluginsGLPI/formcreator/workflows/unit%20tests/badge.svg?branch=support%2F2.12.0) |![unit tests](https://github.com/pluginsGLPI/formcreator/workflows/unit%20tests/badge.svg?branch=develop) |

## Documentation

Expand Down Expand Up @@ -85,7 +85,6 @@ To build the plugin you need [Composer](http://getcomposer.org) and an internet

After dowloading the source of Formcreator, go in its folder and run the following
* composer install
* php vendor/bin/robo build:fa-data

## Contribute

Expand Down
7 changes: 6 additions & 1 deletion RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,17 @@ public function updateChangelog() {

public function localesExtract() {
$potfile = strtolower("glpi.pot");
$phpSources = "*.php ajax/*.php front/*.php inc/*.php inc/field/*.php install/*.php js/*.php";
$phpSources = "*.php ajax/*.php front/*.php inc/*.php inc/field/*.php install/*.php";
// extract locales from source code
$command = "xgettext $phpSources -o locales/$potfile -L PHP --add-comments=TRANS --from-code=UTF-8 --force-po";
$command.= " --keyword=_n:1,2,4t --keyword=__s:1,2t --keyword=__:1,2t --keyword=_e:1,2t --keyword=_x:1c,2,3t --keyword=_ex:1c,2,3t";
$command.= " --keyword=_sx:1c,2,3t --keyword=_nx:1c,2,3,5t";
$this->_exec($command);
$jsSources = "js/*.js";
$command = "xgettext $jsSources -o locales/$potfile -j -L javascript --add-comments=TRANS --from-code=UTF-8 --force-po";
$command.= " --keyword=_n:1,2,4t --keyword=__s:1,2t --keyword=__:1,2t --keyword=_e:1,2t --keyword=_x:1c,2,3t --keyword=_ex:1c,2,3t";
$command.= " --keyword=_sx:1c,2,3t --keyword=_nx:1c,2,3,5t";
$this->_exec($command);
return $this;
}

Expand Down
10 changes: 5 additions & 5 deletions ajax/commontree.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
include ('../../../inc/includes.php');

// Check required parameters
if (ctype_digit($_GET['itemtype']) || !isset($_GET['itemtype']) || !isset($_GET['root']) || !isset($_GET['maxDepth'])) {
if (ctype_digit($_REQUEST['itemtype']) || !isset($_REQUEST['itemtype']) || !isset($_REQUEST['root']) || !isset($_REQUEST['maxDepth'])) {
http_response_code(400);
die;
}

// Load parameters
$itemtype = $_GET['itemtype'];
$root = $_GET['root'];
$depth = $_GET['maxDepth'];
$selectableRoot = $_GET['selectableRoot'];
$itemtype = $_REQUEST['itemtype'];
$root = $_REQUEST['root'];
$depth = $_REQUEST['maxDepth'];
$selectableRoot = $_REQUEST['selectableRoot'];

// This should only be used for dropdowns
if (!is_a($itemtype, CommonTreeDropdown::class, true)) {
Expand Down
50 changes: 50 additions & 0 deletions ajax/counter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* ---------------------------------------------------------------------
* Formcreator is a plugin which allows creation of custom forms of
* easy access.
* ---------------------------------------------------------------------
* LICENSE
*
* This file is part of Formcreator.
*
* Formcreator is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Formcreator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Formcreator. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
* @copyright Copyright © 2011 - 2021 Teclib'
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+
* @link https://github.com/pluginsGLPI/formcreator/
* @link https://pluginsglpi.github.io/formcreator/
* @link http://plugins.glpi-project.org/#/plugin/formcreator
* ---------------------------------------------------------------------
*/

include ('../../../inc/includes.php');
// Check a user is logged in
if (Session::getLoginUserID() === false) {
http_response_code(403);
die();
}
// Immediately close session to allow parallelization
session_write_close();

$counter = $_GET['counter'] ?? null;

// Validate parameters
if (!in_array($counter, [null, 'incoming', 'waiting', 'to_validate', 'solved'])) {
http_response_code(400);
die();
};

$status = PluginFormcreatorIssue::getTicketSummary($counter);
echo json_encode($status);
2 changes: 1 addition & 1 deletion ajax/form_toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
include ('../../../inc/includes.php');
Session::checkRight('entity', UPDATE);

$form = new PluginFormcreatorForm();
$form = PluginFormcreatorCommon::getForm();

$success = $form->update([
'id' => $_POST['id'],
Expand Down
2 changes: 1 addition & 1 deletion ajax/homepage_forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
*/
include ('../../../inc/includes.php');

$form = new PluginFormcreatorForm();
$form = PluginFormcreatorCommon::getForm();
$form->showForCentral();
2 changes: 1 addition & 1 deletion ajax/homepage_wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function plugin_formcreator_showWizardCategories() {
}

function plugin_formcreator_showWizardForms($rootCategory = 0, $keywords = '', $helpdeskHome = false) {
$form = new PluginFormcreatorForm();
$form = PluginFormcreatorCommon::getForm();
$formList = $form->showFormList($rootCategory, $keywords, $helpdeskHome);
echo json_encode($formList, JSON_UNESCAPED_SLASHES);
}
1 change: 1 addition & 0 deletions ajax/question_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
http_response_code(400);
exit;
}
$question->getFromDB($question->getID()); // To remove if GLPI #9210 merged
$json = [
'y' => $question->fields['row'],
'x' => $question->fields['col'],
Expand Down
6 changes: 1 addition & 5 deletions ajax/question_toggle_required.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@
exit;
}

$success = $question->update([
'id' => $questionId,
'_skip_checks' => true,
'required' => ($_REQUEST['required'] ? '1' : '0'),
]);
$success = $question->setRequired($_REQUEST['required'] ? '1' : '0');
if (!$success) {
http_response_code(500);
exit();
Expand Down
1 change: 1 addition & 0 deletions ajax/question_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@
http_response_code(500);
exit();
}
$question->getFromDB($question->getID()); // To remove if GLPI #9210 merged
echo $question->fields['name'];
1 change: 1 addition & 0 deletions ajax/section_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@
echo __('Could not add the section', 'formcreator');
exit;
}
$section->getFromDB($section->getID()); // To remove if GLPI #9210 merged
echo $section->getDesignHtml();
1 change: 1 addition & 0 deletions ajax/section_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@
echo __('Could not update the section', 'formcreator');
exit;
}
$section->getFromDB($section->getID()); // To remove if GLPI #9210 merged
echo $section->fields['name'];
24 changes: 24 additions & 0 deletions ajax/showfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@

include ('../../../inc/includes.php');

// Check if plugin is activated...
if (!(new Plugin())->isActivated('formcreator')) {
http_response_code(404);
exit();
}

$formFk = PluginFormcreatorForm::getForeignKeyField();
if (!isset($_POST[$formFk])) {
http_response_code(403);
exit();
}

$form = PluginFormcreatorCommon::getForm();
$form->getFromDB((int) $_POST['plugin_formcreator_forms_id']);
if (!Session::haveRight('entity', UPDATE) && ($form->isDeleted() || $form->fields['is_active'] == '0')) {
http_response_code(403);
exit();
}

if (!$form->canViewForRequest()) {
http_response_code(403);
exit();
}

try {
$visibility = PluginFormcreatorFields::updateVisibility($_POST);
} catch (Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion ajax/target.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
$formId = $_REQUEST['plugin_formcreator_forms_id'];

$form = new PluginFormcreatorForm();
$form = PluginFormcreatorCommon::getForm();
if (!$form->getFromDB($formId)) {
http_response_code(400);
exit;
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"php": ">= 7.2",
"ext-xml": "*",
"gregwar/captcha": "^1.1",
"xylemical/php-expressions": "^1.0.3"
"xylemical/php-expressions": "^1.0.3",
"laminas/laminas-eventmanager": "^3.2"
},
"require-dev": {
"ext-bz2": "*",
Expand All @@ -27,7 +28,8 @@
"php-parallel-lint/php-parallel-lint": "^1.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"phpcsstandards/phpcsutils": "^1.0@alpha",
"scssphp/scssphp": "^1.5"
"scssphp/scssphp": "^1.5",
"symfony/panther": "^1.1"
},
"autoload-dev": {
"psr-4": {
Expand Down
Loading

0 comments on commit b60fbe4

Please sign in to comment.