Skip to content

Commit

Permalink
pre-release 2.6.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Sep 29, 2017
2 parents d5552a4 + 7f4a5cb commit bdb6092
Show file tree
Hide file tree
Showing 143 changed files with 12,729 additions and 12,312 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
language: php

env:
global:
- GLPI_SOURCE="https://github.com/glpi-project/glpi -b 9.2/bugfixes"
- PHPUNIT_ARGS="--verbose --debug"

php:
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- nightly

before_script:
- git clone https://github.com/glpi-project/glpi --depth 1 -b 9.1.2 ../glpi && cd ../glpi
- mysql -u root -e 'create database glpitest;'
- git clone https://github.com/glpi-project/glpi --depth 1 -b 9.2/bugfixes ../glpi && cd ../glpi
- mv ../formcreator plugins/formcreator
- composer install --no-dev
- php tools/cliinstall.php --db=glpi-test --user=travis --tests
- php tools/cliinstall.php --db=glpitest --user=root --tests
- cd plugins/formcreator
- rm composer.lock
- composer install

script:
- vendor/bin/phpunit --verbose
- vendor/bin/phpunit $PHPUNIT_ARGS
- vendor/bin/robo --no-interaction code:cs

matrix:
Expand Down
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
GLPI Formcreator ChangeLog
===============================

Version 2.6.0 Release Candidate 1
---------------------------------

## Bugfixes
* limit displayed columns on form answers tab of a form (#686)
* fix bulleted lists for IE
* fix bad display of a dropdown
* fix loss of input when validating requester's answers and form is incomplete
* fix ticket categories displayed in helpdesk when they should not
* fix rejected entity dropdown answer if choosing root entity
* fix newlines lost in textareas
* fix rich text rendering of a textarea
* fix broken multiselect field
* fix inconsistent foreign key in the schema and code
* fix move up / down questions
* association of a document to all generated tickets

## Features
* update slinky JS library
* many code cleanup and refactor
* simplify string escaping code
* give more power to form designers when using regex (#701)
* limit display of ticket categories by tree depth and type criteria
* location of tickets can be set from a question


Version 2.5.2
-------------

## Bugfixes
* blank or nearly blank view of form when displaying it for print
* output name instead of ID for some fields when generating target tickets
* fix use of a non existent class Ticket_Supplier
* fix search options of form answers
* fix loss of forn answers in screen when reject then accept a form
* fix regression of not displayed tab for forms on helpdesk
* fix bulleted and numbered lists in generated ticket followup
* fix a bad SQL query

## Features:
* many code cleanup
* simplify string escaping code in some places


Version 2.5.1
-------------

Expand Down
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,21 @@ For more information you can visit the [documentation](http://glpi-plugins.readt

## Translations


If you want Formcreator to be available in your native language and have a little time , you can help us :
If you want Formcreator to be available in your native language and have a little time, you can help us:

Join us on [Transifex](https://www.transifex.com/teclib/glpi-project-plugin-formcreator)

## Upgrade to 2.6.0

When a form contains several target tickets and a file upload field, the uploaded file was attached to all generated tickets.
Starting from the version 2.6.0 a document is attached to a generated ticket in two cases:
* if the tag ##FULLFORM## is used
* if the tag representing the file upload field is used.

When the tag of the answer itself is used, the description of the generated ticket contains a mention of an attached document.

Please take these changes into consideration to review forms containing a file upload field before production.

## Upgrade from 1.x to 2.4.0 or later

After upgrade of FormCreator to version 2.4.0 or later, users may encounteer display issues. This is due to major changes on CSS of the plugin. You may need to refresh the cache of your browser with Ctrl+R or Ctrl+F5. If you plan to communicate about the new presentation of the plugin or the service catalog, introduce this simple manipulation to ensure all your users have a clean cache.
Expand Down Expand Up @@ -65,6 +75,16 @@ Formcreator est un plugin permettant la création de formulaires personalisés s

Pour plus d'informations, visitez la [documentation (en anglais)](http://glpi-plugins.readthedocs.io/fr/latest/formcreator/)

## Upgrade to 2.6.0

Quand un formulaire contient plusieurs tickets destination et un champ d'envoi de fichier, le document téléversé était rattaché à t ous les tickets générés. A partir de la version 2.6.0 un document est rattaché à un ticket généré dans deux cas :
* si la balise ##FULLFORM## est utilisée
* si la balise représentant la réponse du champ d'envoi de fichier est utilisée.

Quand la balise du champ est utilisée, la descrition du ticket généré contient une mention faisant référence à un document joint.

Veuillez prendre ces changements en considération pour réviser tout formulaire contenant un champ d'envoi de fichier avant mise en production.

# Mise à jour depuis 1.x vers 2.4.0 ou supérieur

Après la mise à jour de FormCreator vers la version 2.4.0 ou supérieur, les utilisateurs peuvent rencontrer des problèmes d'affichage. Cela est dû aux changemetns majeurs de CSS dans le plugin. Vous pourriez avoir besoin de rafraichir le cache de votre navigateur avec Ctrl+R ou Ctrl+F5. Si vous prévoyez de communiquer à propos de la nouvelle présentation du plugin ou du catalogue de services, introduisez cette manipulation simple pour vous assurer que tous vos utilisateurs ont un cache à jour.
Expand Down
219 changes: 213 additions & 6 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,219 @@
*
* @see http://robo.li/
*/
require_once 'RoboFilePlugin.php';
class RoboFile extends RoboFilePlugin
{
protected static $banned = [
'dist',
'vendor',
'.git',
'.gitignore',
'.tx',
'.settings',
'.project',
'.buildpath',
'tools',
'tests',
'screenshot*.png',
'RoboFile*.php',
'plugin.xml',
'phpunit.xml.*',
'.travis.yml',
'save.sql',
];

require_once 'vendor/autoload.php';
protected function getPluginPath() {
return __DIR__;
}

class RoboFile extends Glpi\Tools\RoboFile
{
protected function getPluginName() {
return basename($this->getPluginPath());
}

protected function getVersion() {
$setupFile = $this->getPluginPath(). "/setup.php";
$setupContent = file_get_contents($setupFile);
$pluginName = $this->getPluginName();
$constantName = "PLUGIN_" . strtoupper($this->getPluginName()) . "_VERSION";
$pattern = "#^define\('$constantName', '([^']*)'\);$#m";
preg_match($pattern, $setupContent, $matches);
if (isset($matches[1])) {
return $matches[1];
}
throw new Exception("Could not determine version of the plugin");
}

protected function getGLPIMinVersion() {
$setupFile = $this->getPluginPath(). "/setup.php";
$setupContent = file_get_contents($setupFile);
$pluginName = $this->getPluginName();
$constantName = "PLUGIN_" . strtoupper($this->getPluginName()) . "_GLPI_MIN_VERSION";
$pattern = "#^define\('$constantName', '([^']*)'\);$#m";
preg_match($pattern, $setupContent, $matches);
if (isset($matches[1])) {
return $matches[1];
}

throw new Exception("Could not determine version of the plugin");
}

/**
* Override to change the banned list
* @return array
*/
protected function getBannedFiles() {
return static::$banned;
}

//Own plugin's robo stuff
public function archiveBuild() {
$version = $this->getVersion();

if (!$this->isSemVer($version)) {
throw new Exception("$version is not semver compliant. See http://semver.org/");
}

if (!$this->tagExists($version)) {
//throw new Exception("The tag $version does not exists yet");
}

if (!$this->isTagMatchesCurrentCommit($version)) {
//throw new Exception("HEAD is not pointing to the tag of the version to build");
}

$versionTag = $this->getVersionTagFromXML($version);
if (!is_array($versionTag)) {
throw new Exception("The version does not exists in the XML file");
}

$pluginName = $this->getPluginName();
$pluginPath = $this->getPluginPath();
$targetFile = $pluginPath. "/dist/glpi-" . $this->getPluginName() . "-$version.tar.bz2";
$toArchive = implode(' ', $this->getFileToArchive($version));
@mkdir($pluginPath. "/dist");
$this->_exec("git archive --prefix=$pluginName/ $version $toArchive | bzip2 > $targetFile");
}

protected function getTrackedFiles($version) {
$output = [];
exec("git ls-tree -r '$version' --name-only", $output, $retCode);
if ($retCode != '0') {
throw new Exception("Unable to get tracked files");
}
return $output;
}

protected function getFileToArchive($version) {
$filesToArchive = $this->getTrackedFiles($version);

// prepare banned items for regex
$patterns = [];
foreach ($this->getBannedFiles() as $bannedItem) {
$pattern = "#" . preg_quote("$bannedItem", "#") . "#";
$pattern = str_replace("\\?", ".", $pattern);
$pattern = str_replace("\\*", ".*", $pattern);
$patterns[] = $pattern;
}

// remove banned files from the list
foreach ($patterns as $pattern) {
$filteredFiles = [];
foreach ($filesToArchive as $file) {
if (preg_match($pattern, $file) == 0) {
//Include the tracked file
$filteredFiles[] = $file;
}
}

// Repeat filtering from result with next banned files pattern
$filesToArchive = $filteredFiles;
}

return $filesToArchive;
}

protected function getAllTags() {
exec("git tag -l", $output, $retCode);
if ($retCode != '0') {
// An error occured
throw new Exception("Unable to get tags from the repository");
}
return $output;
}

protected function tagExists($version) {
$tags = $this->getAllTags();
return in_array($version, $tags);
}

/**
* Check the version is made of numbers separated by dots
*
* Returns true if the version is well formed, false otherwise
*
* @param string $version
* @return boolean
*/
protected function isSemVer($version) {
$semverPattern = '#\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?\b#i';
if (preg_match($semverPattern, $version) !== 1) {
return false;
}

return true;
}

protected function getPluginXMLDescription() {
$pluginXML = 'plugin.xml';
if (!is_file($pluginXML) || !is_readable($pluginXML)) {
throw Exception("plugin.xml file not found");
}

$xml = simplexml_load_string(file_get_contents($pluginXML));
$json = json_encode($xml);
return json_decode($json, true);
}

protected function getVersionTagFromXML($versionToSearch) {
$xml = $this->getPluginXMLDescription();
foreach ($xml['versions']['version'] as $version) {
if ($version['num'] == $versionToSearch) {
// version found
return $version;
}
}

return null;
}

protected function getCurrentCommitHash() {
exec('git rev-parse HEAD', $output, $retCode);
if ($retCode != '0') {
throw new Exception("failed to get curent commit hash");
}
return $output[0];
}

protected function isTagMatchesCurrentCommit($tag) {
$commitHash = $this->getCurrentCommitHash();
exec("git tag -l --contains $commitHash", $output, $retCode);
if (isset($output[0]) && $output[0] == $tag) {
return true;
}

return false;
}

public function localesExtract() {
$potfile = strtolower($this->getPluginName()) . ".pot";
$phpSources = "*.php ajax/*.php front/*.php inc/*.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);
return $this;
}

protected $csignore = ['/vendor/', '/lib/'];
//Own plugin's robo stuff
}
}
10 changes: 5 additions & 5 deletions ajax/dropdown_values.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
Session::checkRight("entity", UPDATE);

if ($_REQUEST['dropdown_itemtype'] == '0' || !class_exists($_REQUEST['dropdown_itemtype'])) {
Dropdown::showFromArray("dropdown_default_value", array(), array('display_emptychoice' => true));
Dropdown::showFromArray("dropdown_default_value", [], ['display_emptychoice' => true]);
} else {
Dropdown::show($_REQUEST['dropdown_itemtype'], array(
'name' => 'dropdown_default_value',
'rand' => mt_rand(),
));
Dropdown::show($_REQUEST['dropdown_itemtype'], [
'name' => 'dropdown_default_value',
'rand' => mt_rand(),
]);
}
Loading

0 comments on commit bdb6092

Please sign in to comment.