Skip to content

Commit

Permalink
Merge branch 'release/2.6.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Apr 30, 2018
2 parents 59c931c + 3acad96 commit 9567484
Show file tree
Hide file tree
Showing 169 changed files with 15,724 additions and 9,927 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
<a name="2.6.3"></a>
## [2.6.3](https://github.com-btry/pluginsGLPI/formcreator/compare/2.6.2...2.6.3) (2018-04-30)


### Bug Fixes

* **condition:** escape quote in import ([b10134e](https://github.com-btry/pluginsGLPI/formcreator/commit/b10134e))
* **condition:** fix show hide issues ([411b998](https://github.com-btry/pluginsGLPI/formcreator/commit/411b998))
* **docs:** fix bad domain for locales ([47788ff](https://github.com-btry/pluginsGLPI/formcreator/commit/47788ff))
* **field:** some fields output a duplicate HTML div ([c4d1a4c](https://github.com-btry/pluginsGLPI/formcreator/commit/c4d1a4c))
* **file:** fix multiple file fields ([a9798d2](https://github.com-btry/pluginsGLPI/formcreator/commit/a9798d2)), closes [#937](https://github.com-btry/pluginsGLPI/formcreator/issues/937)
* **locales:** invalid domain ([7be6ef1](https://github.com-btry/pluginsGLPI/formcreator/commit/7be6ef1)), closes [#872](https://github.com-btry/pluginsGLPI/formcreator/issues/872)
* **question:** filtering out tag question type broken ([86b5a10](https://github.com-btry/pluginsGLPI/formcreator/commit/86b5a10))
* **section:** fix creation of section with abusive escape ([6057cad](https://github.com-btry/pluginsGLPI/formcreator/commit/6057cad)), closes [#940](https://github.com-btry/pluginsGLPI/formcreator/issues/940) [#940](https://github.com-btry/pluginsGLPI/formcreator/issues/940)
* **section:** single quote escaping issue ([b298505](https://github.com-btry/pluginsGLPI/formcreator/commit/b298505)), closes [#940](https://github.com-btry/pluginsGLPI/formcreator/issues/940)
* **target:** distinguish fields content ([326315c](https://github.com-btry/pluginsGLPI/formcreator/commit/326315c))
* **target ticket:** backquote in ticket ticle ([1296925](https://github.com-btry/pluginsGLPI/formcreator/commit/1296925)), closes [#951](https://github.com-btry/pluginsGLPI/formcreator/issues/951)
* **target ticket:** observer groups from template added in assigned ones ([f09e685](https://github.com-btry/pluginsGLPI/formcreator/commit/f09e685))
* **target ticket:** quote escaping for ticket title ([cd070ea](https://github.com-btry/pluginsGLPI/formcreator/commit/cd070ea))
* **ticket:** use default values to set actors of tickets ([fa3f816](https://github.com-btry/pluginsGLPI/formcreator/commit/fa3f816)), closes [#629](https://github.com-btry/pluginsGLPI/formcreator/issues/629)
* **ui:** compatibility issue with internet explorer 11 ([fb2c711](https://github.com-btry/pluginsGLPI/formcreator/commit/fb2c711)), closes [#936](https://github.com-btry/pluginsGLPI/formcreator/issues/936)
* **ui:** responsive design of service catalog ([0f6e466](https://github.com-btry/pluginsGLPI/formcreator/commit/0f6e466))



<a name="2.6.2"></a>
## [2.6.2](https://github.com-btry/pluginsGLPI/formcreator/compare/2.6.1...2.6.2) (2018-02-12)

Expand Down
132 changes: 131 additions & 1 deletion RoboFile.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
use Robo\Task\Docker\Commit;

/**
* This is project's console commands configuration for Robo task runner.
Expand Down Expand Up @@ -320,4 +319,135 @@ protected function sourceUpdatePackageJson($version) {
protected function sourceUpdateComposerJson($version) {
$this->updateJsonFile('composer.json', $version);
}

/**
* Update headers in source files
*/
public function codeHeadersUpdate() {
$toUpdate = $this->getTrackedFiles('HEAD');
foreach ($toUpdate as $file) {
$this->replaceSourceHeader($file);
}
}

/**
* Read the header template from a file
* @throws Exception
* @return string
*/
protected function getHeaderTemplate() {
if (empty($this->headerTemplate)) {
$this->headerTemplate = file_get_contents(__DIR__ . '/tools/HEADER');
if (empty($this->headerTemplate)) {
throw new Exception('Header template file not found');
}
}

$copyrightRegex = "#Copyright (\(c\)|©) (\d{4}-)?(\d{4}) #iUm";
$year = date("Y");
$replacement = 'Copyright © ${2}' . $year . ' ';
$this->headerTemplate = preg_replace($copyrightRegex, $replacement, $this->headerTemplate);

return $this->headerTemplate;
}

/**
* Format header template for a file type based on extension
*
* @param string $extension
* @param string $template
* @return string
*/
protected function getFormatedHeaderTemplate($extension, $template) {
switch ($extension) {
case 'php':
case 'css':
$lines = explode("\n", $template);
foreach ($lines as &$line) {
$line = rtrim(" * $line");
}
return implode("\n", $lines);
break;

default:
return $template;
}
}

/**
* Update source code header in a source file
* @param string $filename
*/
protected function replaceSourceHeader($filename) {
$filename = __DIR__ . "/$filename";

// define regex for the file type
$ext = pathinfo($filename, PATHINFO_EXTENSION);
switch ($ext) {
case 'php':
$prefix = "\<\?php\\n/\*(\*)?\\n";
$replacementPrefix = "<?php\n/**\n";
$suffix = "\\n( )?\*/";
$replacementSuffix = "\n */";
break;

case 'css':
$prefix = "/\*(\*)?\\n";
$replacementPrefix = "/**\n";
$suffix = "\\n( )?\*/";
$replacementSuffix = "\n */";
break;
default:
// Unhandled file format
return;
}

// format header template for the file type
$header = trim($this->getHeaderTemplate());
$formatedHeader = $replacementPrefix . $this->getFormatedHeaderTemplate($ext, $header) . $replacementSuffix;

// get the content of the file to update
$source = file_get_contents($filename);

// update authors in formated template
$headerMatch = [];
$originalAuthors = [];
$authors = [];
$authorsRegex = "#^.*(\@author .*)$#Um";
preg_match('#^' . $prefix . '(.*)' . $suffix . '#Us', $source, $headerMatch);
if (isset($headerMatch[0])) {
$originalHeader = $headerMatch[0];
preg_match_all($authorsRegex, $originalHeader, $originalAuthors);
if (!is_array($originalAuthors)) {
$originalAuthors = [$originalAuthors];
}
if (isset($originalAuthors[1])) {
$originalAuthors[1] = array_unique($originalAuthors[1]);
$originalAuthors = $this->getFormatedHeaderTemplate($ext, implode("\n", $originalAuthors[1]));
$countOfAuthors = preg_match_all($authorsRegex, $formatedHeader);
if ($countOfAuthors !== false) {
// Empty all author lines except the last one
$formatedHeader = preg_replace($authorsRegex, '', $formatedHeader, $countOfAuthors - 1);
// remove the lines previously reduced to zero
$lines = explode("\n", $formatedHeader);
$formatedHeader = [];
foreach ($lines as $line) {
if ($line !== '') {
$formatedHeader[] = $line;
};
}
$formatedHeader = implode("\n", $formatedHeader);
$formatedHeader = preg_replace($authorsRegex, $originalAuthors, $formatedHeader, 1);
}
}
}

// replace the header if it exists
$source = preg_replace('#^' . $prefix . '(.*)' . $suffix . '#Us', $formatedHeader, $source, 1);
if (empty($source)) {
throw new Exception("An error occurred while processing $filename");
}

file_put_contents($filename, $source);
}
}
32 changes: 30 additions & 2 deletions RoboFilePlugin.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
<?php
/**
* This is project's console commands configuration for Robo task runner.
* LICENSE
*
* @see http://robo.li/
* Copyright © 2011-2018 Teclib'
*
* This file is part of Formcreator Plugin for GLPI.
*
* Formcreator is a plugin that allow creation of custom, easy to access forms
* for users when they want to create one or more GLPI tickets.
*
* Formcreator Plugin for GLPI 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 Plugin for GLPI 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* If not, see http://www.gnu.org/licenses/.
* ------------------------------------------------------------------------------
* @author Thierry Bugier
* @author Jérémy Moreau
* @copyright Copyright © 2018 Teclib
* @license GPLv2 https://www.gnu.org/licenses/gpl2.txt
* @link https://github.com/pluginsGLPI/formcreator/
* @link http://plugins.glpi-project.org/#/plugin/formcreator
* ------------------------------------------------------------------------------
*/
class RoboFilePlugin extends \Robo\Tasks
{
Expand Down
33 changes: 33 additions & 0 deletions ajax/dropdown_values.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
<?php
/**
* LICENSE
*
* Copyright © 2011-2018 Teclib'
*
* This file is part of Formcreator Plugin for GLPI.
*
* Formcreator is a plugin that allow creation of custom, easy to access forms
* for users when they want to create one or more GLPI tickets.
*
* Formcreator Plugin for GLPI 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 Plugin for GLPI 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* If not, see http://www.gnu.org/licenses/.
* ------------------------------------------------------------------------------
* @author Thierry Bugier
* @author Jérémy Moreau
* @copyright Copyright © 2018 Teclib
* @license GPLv2 https://www.gnu.org/licenses/gpl2.txt
* @link https://github.com/pluginsGLPI/formcreator/
* @link http://plugins.glpi-project.org/#/plugin/formcreator
* ------------------------------------------------------------------------------
*/
include ('../../../inc/includes.php');

Session::checkRight("entity", UPDATE);
Expand Down
33 changes: 33 additions & 0 deletions ajax/homepage_forms.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
<?php
/**
* LICENSE
*
* Copyright © 2011-2018 Teclib'
*
* This file is part of Formcreator Plugin for GLPI.
*
* Formcreator is a plugin that allow creation of custom, easy to access forms
* for users when they want to create one or more GLPI tickets.
*
* Formcreator Plugin for GLPI 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 Plugin for GLPI 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* If not, see http://www.gnu.org/licenses/.
* ------------------------------------------------------------------------------
* @author Thierry Bugier
* @author Jérémy Moreau
* @copyright Copyright © 2018 Teclib
* @license GPLv2 https://www.gnu.org/licenses/gpl2.txt
* @link https://github.com/pluginsGLPI/formcreator/
* @link http://plugins.glpi-project.org/#/plugin/formcreator
* ------------------------------------------------------------------------------
*/
include ('../../../inc/includes.php');

$form = new PluginFormcreatorForm();
Expand Down
33 changes: 33 additions & 0 deletions ajax/homepage_link.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
<?php
/**
* LICENSE
*
* Copyright © 2011-2018 Teclib'
*
* This file is part of Formcreator Plugin for GLPI.
*
* Formcreator is a plugin that allow creation of custom, easy to access forms
* for users when they want to create one or more GLPI tickets.
*
* Formcreator Plugin for GLPI 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 Plugin for GLPI 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* If not, see http://www.gnu.org/licenses/.
* ------------------------------------------------------------------------------
* @author Thierry Bugier
* @author Jérémy Moreau
* @copyright Copyright © 2018 Teclib
* @license GPLv2 https://www.gnu.org/licenses/gpl2.txt
* @link https://github.com/pluginsGLPI/formcreator/
* @link http://plugins.glpi-project.org/#/plugin/formcreator
* ------------------------------------------------------------------------------
*/
include ('../../../inc/includes.php');

echo '<li id="menu5">";
Expand Down
33 changes: 33 additions & 0 deletions ajax/homepage_wizard.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
<?php
/**
* LICENSE
*
* Copyright © 2011-2018 Teclib'
*
* This file is part of Formcreator Plugin for GLPI.
*
* Formcreator is a plugin that allow creation of custom, easy to access forms
* for users when they want to create one or more GLPI tickets.
*
* Formcreator Plugin for GLPI 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 Plugin for GLPI 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* If not, see http://www.gnu.org/licenses/.
* ------------------------------------------------------------------------------
* @author Thierry Bugier
* @author Jérémy Moreau
* @copyright Copyright © 2018 Teclib
* @license GPLv2 https://www.gnu.org/licenses/gpl2.txt
* @link https://github.com/pluginsGLPI/formcreator/
* @link http://plugins.glpi-project.org/#/plugin/formcreator
* ------------------------------------------------------------------------------
*/
include ('../../../inc/includes.php');

if (!isset($_SESSION['glpiactiveprofile']['id'])) {
Expand Down
33 changes: 33 additions & 0 deletions ajax/ldap_filter.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
<?php
/**
* LICENSE
*
* Copyright © 2011-2018 Teclib'
*
* This file is part of Formcreator Plugin for GLPI.
*
* Formcreator is a plugin that allow creation of custom, easy to access forms
* for users when they want to create one or more GLPI tickets.
*
* Formcreator Plugin for GLPI 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 Plugin for GLPI 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* If not, see http://www.gnu.org/licenses/.
* ------------------------------------------------------------------------------
* @author Thierry Bugier
* @author Jérémy Moreau
* @copyright Copyright © 2018 Teclib
* @license GPLv2 https://www.gnu.org/licenses/gpl2.txt
* @link https://github.com/pluginsGLPI/formcreator/
* @link http://plugins.glpi-project.org/#/plugin/formcreator
* ------------------------------------------------------------------------------
*/
include ('../../../inc/includes.php');

Session::checkRight("entity", UPDATE);
Expand Down
Loading

0 comments on commit 9567484

Please sign in to comment.