Skip to content

Commit

Permalink
Merge branch 'release/2.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Jan 2, 2018
2 parents afa94f3 + 51b7dbd commit 0072d44
Show file tree
Hide file tree
Showing 83 changed files with 10,411 additions and 5,033 deletions.
17 changes: 9 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ env:
- GLPI_SOURCE="https://github.com/glpi-project/glpi -b 9.2/bugfixes"
- PHPUNIT_ARGS="--verbose --debug"

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

before_script:
- mysql -u root -e 'create database glpitest;'
- git clone https://github.com/glpi-project/glpi --depth 1 -b 9.2/bugfixes ../glpi && cd ../glpi
Expand All @@ -24,9 +17,17 @@ before_script:

script:
- vendor/bin/phpunit $PHPUNIT_ARGS
- vendor/bin/robo --no-interaction code:cs
- if [[ "$CS" == "true" ]]; then vendor/bin/robo --no-interaction code:cs; fi

matrix:
include:
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
env: CS=true
- php: nightly

allow_failures:
- php: nightly

Expand Down
66 changes: 64 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,67 @@
GLPI Formcreator ChangeLog
===============================
<a name="2.6.1"></a>
## [2.6.1](https://github.com-btry/pluginsGLPI/formcreator/compare/2.6.0...2.6.1) (2018-01-02)


### Bug Fixes

* avoid duplicated form having the uuid of the source one ([464757e](https://github.com-btry/pluginsGLPI/formcreator/commit/464757e))
* form duplication issue when source form contains access restriction ([ec40d9f](https://github.com-btry/pluginsGLPI/formcreator/commit/ec40d9f))
* misconceptions in duplication process ([06c2430](https://github.com-btry/pluginsGLPI/formcreator/commit/06c2430))
* **locales:** fix missing locales, update them ([33cbe5e](https://github.com-btry/pluginsGLPI/formcreator/commit/33cbe5e))
* rich description encoding in ticket ([#775](https://github.com-btry/pluginsGLPI/formcreator/issues/775)) ([f739c54](https://github.com-btry/pluginsGLPI/formcreator/commit/f739c54))
* **answer:** HTML entity decode for older textarea answers ([3612c3c](https://github.com-btry/pluginsGLPI/formcreator/commit/3612c3c))
* **condition:** fix inconsistency when checking question conditions ([a820e55](https://github.com-btry/pluginsGLPI/formcreator/commit/a820e55)), closes [#829](https://github.com-btry/pluginsGLPI/formcreator/issues/829)
* **field:** avoid html entitization of accented chars ([a973f7b](https://github.com-btry/pluginsGLPI/formcreator/commit/a973f7b))
* **form:** duplicate target changes when duplicating form ([7f78de9](https://github.com-btry/pluginsGLPI/formcreator/commit/7f78de9))
* **form:** fix escaping and logic issues in duplication ([236effd](https://github.com-btry/pluginsGLPI/formcreator/commit/236effd))
* **form:** repair massive acions ([7221644](https://github.com-btry/pluginsGLPI/formcreator/commit/7221644))
* **form:** update target settings depending on questions ([7acbc11](https://github.com-btry/pluginsGLPI/formcreator/commit/7acbc11))
* **form_answer:** restrict display of form answers to requesters and valdators ([8909e4e](https://github.com-btry/pluginsGLPI/formcreator/commit/8909e4e)), closes [#869](https://github.com-btry/pluginsGLPI/formcreator/issues/869)
* **install:** detect version 2.6 without schema version, see [#794](https://github.com-btry/pluginsGLPI/formcreator/issues/794) ([decaafe](https://github.com-btry/pluginsGLPI/formcreator/commit/decaafe))
* **install:** fix inconsistencies in install process" ([99eb790](https://github.com-btry/pluginsGLPI/formcreator/commit/99eb790))
* **install:** fresh 2.6.0 install inconsistent ([903a13a](https://github.com-btry/pluginsGLPI/formcreator/commit/903a13a))
* **install:** fresh installation does not saves current schema version ([8eadd7d](https://github.com-btry/pluginsGLPI/formcreator/commit/8eadd7d)), closes [#794](https://github.com-btry/pluginsGLPI/formcreator/issues/794)
* **install:** inconsistency in fresh 2.6.0 install ([e41a86d](https://github.com-btry/pluginsGLPI/formcreator/commit/e41a86d)), closes [#822](https://github.com-btry/pluginsGLPI/formcreator/issues/822)
* **install:** restore lost JSON type creation ([40afda3](https://github.com-btry/pluginsGLPI/formcreator/commit/40afda3))
* **install:** run issues synchronization after install ([2441d02](https://github.com-btry/pluginsGLPI/formcreator/commit/2441d02))
* **issue:** bad search option ([bc4bec8](https://github.com-btry/pluginsGLPI/formcreator/commit/bc4bec8))
* **issue:** issue not updated to refused status ([8b1e3b8](https://github.com-btry/pluginsGLPI/formcreator/commit/8b1e3b8))
* **issue:** wrong ticket disdplay ([5e33407](https://github.com-btry/pluginsGLPI/formcreator/commit/5e33407)), closes [#859](https://github.com-btry/pluginsGLPI/formcreator/issues/859)
* **locale:** bad domain for some locales ([1d9ff65](https://github.com-btry/pluginsGLPI/formcreator/commit/1d9ff65))
* **locales:** add missing strings; update locales ([792a6c2](https://github.com-btry/pluginsGLPI/formcreator/commit/792a6c2))
* **locales:** follow change of a localizable string from GLPI 9.1 ([75a1057](https://github.com-btry/pluginsGLPI/formcreator/commit/75a1057))
* **locales:** harmonize and fix locales ([62076ed](https://github.com-btry/pluginsGLPI/formcreator/commit/62076ed))
* **question:** fix duplicate code ([779a5c3](https://github.com-btry/pluginsGLPI/formcreator/commit/779a5c3))
* **question:** fix escaping issues with regexes ([c807936](https://github.com-btry/pluginsGLPI/formcreator/commit/c807936))
* **question:** fix typo breaking duplication ([e7d2b0e](https://github.com-btry/pluginsGLPI/formcreator/commit/e7d2b0e))
* **question:** remove abusive encoding ([f183091](https://github.com-btry/pluginsGLPI/formcreator/commit/f183091))
* **rule:** location affectation on ticket via business rule ([06d6461](https://github.com-btry/pluginsGLPI/formcreator/commit/06d6461)), closes [#795](https://github.com-btry/pluginsGLPI/formcreator/issues/795)
* **section:** delete a section displays an error ([1d1eb93](https://github.com-btry/pluginsGLPI/formcreator/commit/1d1eb93))
* **selectfield:** workaround GLPI issue 3308 ([d086006](https://github.com-btry/pluginsGLPI/formcreator/commit/d086006))
* **target:** do not mention the absence of an uploaded document in targets ([f1ac36b](https://github.com-btry/pluginsGLPI/formcreator/commit/f1ac36b))
* **target:** fix HTML issues in generated tickets ([278c628](https://github.com-btry/pluginsGLPI/formcreator/commit/278c628))
* **target:** fix typo preventing requester groups being added to targets ([ececfe3](https://github.com-btry/pluginsGLPI/formcreator/commit/ececfe3)), closes [#767](https://github.com-btry/pluginsGLPI/formcreator/issues/767)
* **target:** fix warnings in timeline when no fiel uploaded ([9c94128](https://github.com-btry/pluginsGLPI/formcreator/commit/9c94128))
* **target:** rename a target overriden by a global var ([f5b14a9](https://github.com-btry/pluginsGLPI/formcreator/commit/f5b14a9))
* **target-change:** nug handling the comment field of a target change ([5371da5](https://github.com-btry/pluginsGLPI/formcreator/commit/5371da5))
* **targetchange:** fix reversed condition ([e2288bf](https://github.com-btry/pluginsGLPI/formcreator/commit/e2288bf))
* **targetticket:** fix entity of generated ticket ([1ea5325](https://github.com-btry/pluginsGLPI/formcreator/commit/1ea5325))
* **targetticket:** follow change in GLPI for due date ([efa5fcb](https://github.com-btry/pluginsGLPI/formcreator/commit/efa5fcb))
* **targetticket,targetchange:** ticket and change rendering without rich text mode ([d723a47](https://github.com-btry/pluginsGLPI/formcreator/commit/d723a47)), closes [#847](https://github.com-btry/pluginsGLPI/formcreator/issues/847)
* **ui:** css ([c907214](https://github.com-btry/pluginsGLPI/formcreator/commit/c907214))
* **ui:** dont force layout for service catalog ([617e8f1](https://github.com-btry/pluginsGLPI/formcreator/commit/617e8f1))
* **ui:** pqselect enabled not loaded every time it is needed ([#768](https://github.com-btry/pluginsGLPI/formcreator/issues/768)) ([22f3508](https://github.com-btry/pluginsGLPI/formcreator/commit/22f3508))
* **ui:** tinymce may ot load ([86893f4](https://github.com-btry/pluginsGLPI/formcreator/commit/86893f4))
* **ui:** too long localized string ([c83323d](https://github.com-btry/pluginsGLPI/formcreator/commit/c83323d))
* **wizard:** bookmark was renamed into saved search i GLPI 9.2 ([02c2877](https://github.com-btry/pluginsGLPI/formcreator/commit/02c2877)), closes [#799](https://github.com-btry/pluginsGLPI/formcreator/issues/799)


### Features

* **file:** use enhanced file field ([988136a](https://github.com-btry/pluginsGLPI/formcreator/commit/988136a))
* **install:** prepare upgrade code ([0c8c64f](https://github.com-btry/pluginsGLPI/formcreator/commit/0c8c64f))



Version 2.6.0
-------------
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ 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
## Mise à jour vers 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
Expand Down
131 changes: 116 additions & 15 deletions RoboFile.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
use Robo\Task\Docker\Commit;

/**
* This is project's console commands configuration for Robo task runner.
*
Expand Down Expand Up @@ -26,16 +28,16 @@ class RoboFile extends RoboFilePlugin
'save.sql',
];

protected function getPluginPath() {
protected function getProjectPath() {
return __DIR__;
}

protected function getPluginName() {
return basename($this->getPluginPath());
return basename($this->getProjectPath());
}

protected function getVersion() {
$setupFile = $this->getPluginPath(). "/setup.php";
$setupFile = $this->getProjectPath(). "/setup.php";
$setupContent = file_get_contents($setupFile);
$pluginName = $this->getPluginName();
$constantName = "PLUGIN_" . strtoupper($this->getPluginName()) . "_VERSION";
Expand All @@ -48,7 +50,7 @@ protected function getVersion() {
}

protected function getGLPIMinVersion() {
$setupFile = $this->getPluginPath(). "/setup.php";
$setupFile = $this->getProjectPath(). "/setup.php";
$setupContent = file_get_contents($setupFile);
$pluginName = $this->getPluginName();
$constantName = "PLUGIN_" . strtoupper($this->getPluginName()) . "_GLPI_MIN_VERSION";
Expand Down Expand Up @@ -77,25 +79,34 @@ public function archiveBuild() {
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->tagExists($version)) {
throw new Exception("The tag $version already exists");
}

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

// update version in package.json
$this->sourceUpdatePackageJson($version);
$this->sourceUpdateComposerJson($version);

$this->updateChangelog();

$this->gitCommit(['package.json', 'composer.json'], "docs: bump version in JSON files");
$this->gitCommit(['CHANGELOG.md'], "docs(changelog): update changelog");

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

protected function getTrackedFiles($version) {
Expand Down Expand Up @@ -208,9 +219,43 @@ protected function isTagMatchesCurrentCommit($tag) {
return false;
}

/**
* @param array $files files to commit
* @param string $commitMessage commit message
*/
protected function gitCommit(array $files, $commitMessage) {
if (count($files) < 1) {
$arg = '-u';
} else {
$arg = '"' . implode('" "', $files) . '"';
}
exec("git add $arg", $output, $retCode);
if ($retCode > 0) {
throw new Exception("Failed to add files for $commitMessage");
}

exec("git commit -m \"$commitMessage\"", $output, $retCode);
if ($retCode > 0) {
throw new Exception("Failed to commit $commitMessage");
}

return true;
}

/**
*/
protected function updateChangelog() {
exec("node_modules/.bin/conventional-changelog -p angular -i CHANGELOG.md -s", $output, $retCode);
if ($retCode > 0) {
throw new Exception("Failed to update the changelog");
}

return true;
}

public function localesExtract() {
$potfile = strtolower($this->getPluginName()) . ".pot";
$phpSources = "*.php ajax/*.php front/*.php inc/*.php install/*.php";
$potfile = strtolower("glpi.pot");
$phpSources = "*.php ajax/*.php front/*.php inc/*.php inc/fields/*.php install/*.php js/*.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";
Expand All @@ -219,4 +264,60 @@ public function localesExtract() {
return $this;
}

}
/**
* Build MO files
*
* @return void
*/
public function localesMo() {
$localesPath = $this->getProjectPath() . '/locales';
if ($handle = opendir($localesPath)) {
while (($file = readdir($handle)) !== false) {
if ($file != "." && $file != "..") {
$poFile = "$localesPath/$file";
if (pathinfo($poFile, PATHINFO_EXTENSION) == 'po') {
$moFile = str_replace('.po', '.mo', $poFile);
$command = "msgfmt $poFile -o $moFile";
$this->_exec($command);
}
}
}
closedir($handle);
}
return $this;
}

/**
*
* @param string $filename
* @param string $version
*/
protected function updateJsonFile($filename, $version) {
// get Package JSON
$filename = __DIR__ . "/$filename";
$jsonContent = file_get_contents($filename);
$jsonContent = json_decode($jsonContent, true);

// update version
if (empty($version)) {
echo "Version not found in setup.php\n";
return;
}
$jsonContent['version'] = $version;
file_put_contents($filename, json_encode($jsonContent, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n");
}

/**
* @param $version
*/
protected function sourceUpdatePackageJson($version) {
$this->updateJsonFile('package.json', $version);
}

/**
* @param string $version
*/
protected function sourceUpdateComposerJson($version) {
$this->updateJsonFile('composer.json', $version);
}
}
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
},
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.0",
"glpi-project/tools": "^0.1.0"
}
"glpi-project/tools": "^0.1.0",
"glpi-project/coding-standard": "0.5.0"
},
"version": "2.6.1"
}
9 changes: 6 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion front/form_answer.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
$_POST['plugin_formcreator_forms_id'] = intval($_POST['formcreator_form']);
$_POST['status'] = 'waiting';
$formanswer->saveAnswers($_POST);
$formanswer->redirectToList();
if (plugin_formcreator_replaceHelpdesk()) {
$issue = new PluginFormcreatorIssue();
$issue->redirectToList();
} else {
$formanswer->redirectToList();
}

// Show target ticket form
} else {
Expand Down
7 changes: 7 additions & 0 deletions front/issue.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
Html::displayNotFoundError();
}

// force layout of glpi
$layout = $_SESSION['glpilayout'];
$_SESSION['glpilayout'] = "lefttab";

$issue = new PluginFormcreatorIssue();
if (isset($_POST['save_formanswer'])) {
$_POST['plugin_formcreator_forms_id'] = intval($_POST['formcreator_form']);
Expand All @@ -33,3 +37,6 @@
Html::footer();
}
}

// restore layout
$_SESSION['glpilayout'] = $layout;
2 changes: 1 addition & 1 deletion front/question.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
} else if (isset($_POST["set_required"])) {
// Set a Question required
$question = new PluginFormcreatorQuestion();
$question->gtFromDB((int) $_POST['id']);
$question->getFromDB((int) $_POST['id']);
$question->update(['required' => $_POST['value']] + $question->fields);

} else if (isset($_POST["move"])) {
Expand Down
Loading

0 comments on commit 0072d44

Please sign in to comment.