Skip to content

Commit

Permalink
#7 [Mod] add: ModuleBuilder implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Dec 2, 2022
1 parent 60a8d4a commit 041851a
Show file tree
Hide file tree
Showing 14 changed files with 1,340 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated binaries
/build/*.zip
/bin/*.zip
# Doxygen generated documentation
/build/doxygen/doxygen_warnings.log
/doc/code/doxygen
# Composer managed dependencies
/vendor
/dev/bin
# PHPdocumentor generated files
/build/phpdoc
/doc/code/phpdoc
# Sphinx generated files
/doc/user/build
/.settings/
/.buildpath
/.project
# Other
*.back
/.editorconfig
/.gitattributes
621 changes: 621 additions & 0 deletions COPYING

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CHANGELOG DOLIOCR FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)

## 1.0

Initial version
46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,44 @@
# DoliOCR
DoliOCR
# DoliOCR sur [DOLIBARR ERP CRM](https://www.dolibarr.org)

## Informations

- Numéro du module : 436312
- Version : 1.0.0
- Dernière mise à jour : 02/12/2022
- Éditeur : [Evarisk](https://www.evarisk.com)
- Compatibilité : Dolibarr 15.0.0 - 16.0.3
- Thème : Eldy Menu
- Licence : GPLv3
- Disponible sur : Windows - MacOS - Linux

## Liens

- Support & Assistance : [Forum www.dolibarr.fr](https://www.dolibarr.fr) / Par mail à [email protected]
- Demo : [Demo DoliOCR](https://www.demodoli.digirisk.com) - ID: demo - Password: demo
- Documentation : [Wiki DoliOCR](https://wiki.dolibarr.org/index.php/Module_DoliOCR)
- Projet Github : [Projet DoliOCR](https://github.com/orgs/Evarisk/projects/17)
- D'autres modules développés par Evarisk disponible sur [Dolistore.com](https://www.dolistore.com)

## Fonctionnalités

Corrigez vos problèmes de sécurité facilement et rapidement

## Traductions

- Français
- Anglais

## Installation

### Méthode 1 :

- Depuis le menu "Déployer/Installer un module externe" de Dolibarr :
- Glisser l'archive ZIP 'module_doliocr-X.Y.Z' et cliquer sur "ENVOYER FICHIER"
- Activer le module dans la liste des Modules/Applications installés

### Méthode 2 :

- Dans le dossier "dolibarr/htdocs/custom" copier la ligne suivante :
```
git clone https://github.com/Evarisk/doliocr.git
```
96 changes: 96 additions & 0 deletions admin/about.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php
/* Copyright (C) 2022 EVARISK <[email protected]>
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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, see <https://www.gnu.org/licenses/>.
*/

/**
* \file doliocr/admin/about.php
* \ingroup doliocr
* \brief About page of module DoliOCR.
*/

// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER['CONTEXT_DOCUMENT_ROOT'])) {
$res = @include $_SERVER['CONTEXT_DOCUMENT_ROOT']. '/main.inc.php';
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)). '/main.inc.php')) {
$res = @include substr($tmp, 0, ($i + 1)). '/main.inc.php';
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))). '/main.inc.php')) {
$res = @include dirname(substr($tmp, 0, ($i + 1))). '/main.inc.php';
}
// Try main.inc.php using relative path
if (!$res && file_exists('../../main.inc.php')) {
$res = @include '../../main.inc.php';
}
if (!$res && file_exists('../../../main.inc.php')) {
$res = @include '../../../main.inc.php';
}
if (!$res) {
die('Include of main fails');
}

// Libraries
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';

require_once __DIR__ . '/../lib/doliocr.lib.php';
require_once __DIR__ . '/../core/modules/modDoliOCR.class.php';

// Global variables definitions
global $db, $langs, $user;

// Translations
$langs->loadLangs(['errors', 'admin', 'doliocr@doliocr']);

// Initialize technical objects
$modDoliOCR = new modDoliOCR($db);

// Access control
$permissiontoread = $user->rights->doliocr->adminpage->read;
if (empty($conf->doliocr->enabled)) accessforbidden();
if (!$permissiontoread) accessforbidden();

/*
* View
*/

$help_url = 'FR:Module_DoliOCR';
$title = $langs->trans('DoliOCRAbout');

llxHeader('', $title, $help_url);

// Subheader
$linkback = '<a href="' . DOL_URL_ROOT.'/admin/modules.php' . '">'.$langs->trans('BackToModuleList') . '</a>';

print load_fiche_titre($title, $linkback, 'doliocr_color@doliocr');

// Configuration header
$head = doliocrAdminPrepareHead();
print dol_get_fiche_head($head, 'about', $title, 0, 'doliocr_color@doliocr');

print $modDoliOCR->getDescLong();

// Page end
print dol_get_fiche_end();
llxFooter();
$db->close();
95 changes: 95 additions & 0 deletions admin/setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/* Copyright (C) 2022 EVARISK <[email protected]>
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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, see <https://www.gnu.org/licenses/>.
*/

/**
* \file doliocr/admin/setup.php
* \ingroup doliocr
* \brief DoliOCR setup page.
*/

// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER['CONTEXT_DOCUMENT_ROOT'])) {
$res = @include $_SERVER['CONTEXT_DOCUMENT_ROOT']. '/main.inc.php';
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)). '/main.inc.php')) {
$res = @include substr($tmp, 0, ($i + 1)). '/main.inc.php';
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))). '/main.inc.php')) {
$res = @include dirname(substr($tmp, 0, ($i + 1))). '/main.inc.php';
}
// Try main.inc.php using relative path
if (!$res && file_exists('../../main.inc.php')) {
$res = @include '../../main.inc.php';
}
if (!$res && file_exists('../../../main.inc.php')) {
$res = @include '../../../main.inc.php';
}
if (!$res) {
die('Include of main fails');
}

// Libraries
require_once DOL_DOCUMENT_ROOT. '/core/lib/admin.lib.php';

require_once __DIR__ . '/../lib/doliocr.lib.php';

// Global variables definitions
global $db, $langs, $hookmanager, $user;

// Translations
$langs->loadLangs(['admin', 'doliocr@doliocr']);

// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(['doliocrsetup', 'globalsetup']);

// Access control
$permissiontoread = $user->rights->doliocr->adminpage->read;
if (empty($conf->doliocr->enabled)) accessforbidden();
if (!$permissiontoread) accessforbidden();

/*
* View
*/

$help_url = 'FR:Module_DoliOCR';
$title = $langs->trans('DoliOCRSetup');

llxHeader('', $title, $help_url);

// Subheader
$linkback = '<a href="' . DOL_URL_ROOT.'/admin/modules.php' . '">'.$langs->trans('BackToModuleList') . '</a>';

print load_fiche_titre($title, $linkback, 'doliocr_color@doliocr');

// Configuration header
$head = doliocrAdminPrepareHead();
print dol_get_fiche_head($head, 'settings', $title, 0, 'doliocr_color@doliocr');

// Setup page goes here
print '<span class="opacitymedium">' . $langs->trans('DoliOCRSetupPage') . '</span>';

// Page end
print dol_get_fiche_end();
llxFooter();
$db->close();
Loading

0 comments on commit 041851a

Please sign in to comment.