remove unused files
This commit is contained in:
parent
8629651659
commit
13e05b875d
@ -72,7 +72,7 @@ class modWebhook extends DolibarrModules
|
||||
$this->editor_url = 'https://www.example.com';
|
||||
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
|
||||
$this->version = 'dolibarr';
|
||||
$this->version = 'development';
|
||||
// Url to the file with your last numberversion of this module
|
||||
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
|
||||
|
||||
|
||||
@ -2234,3 +2234,8 @@ TemplateforBusinessCards=Template for a business card in different size
|
||||
InventorySetup= Inventory Setup
|
||||
ExportUseLowMemoryMode=Use a low memory mode
|
||||
ExportUseLowMemoryModeHelp=Use the low memory mode to execute the exec of the dump (compression is done through a pipe instead of into the PHP memory). This method does not allow to check that file is completed and error message can't be reported if it fails.
|
||||
ModuleWebhookName = Webhook
|
||||
ModuleWebhookDesc = Interface to catch dolibarr triggers and send it to an URL
|
||||
WebhookSetup = Webhook setup
|
||||
Settings = Settings
|
||||
WebhookSetupPage = Webhook setup page
|
||||
@ -1,49 +0,0 @@
|
||||
# Copyright (C) 2022 SuperAdmin
|
||||
#
|
||||
# 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 .
|
||||
|
||||
#
|
||||
# Generic
|
||||
#
|
||||
|
||||
# Module label 'ModuleWebhookName'
|
||||
ModuleWebhookName = Webhook
|
||||
# Module description 'ModuleWebhookDesc'
|
||||
ModuleWebhookDesc = Interface to catch dolibarr triggers and send it to an URL
|
||||
|
||||
#
|
||||
# Admin page
|
||||
#
|
||||
WebhookSetup = Webhook setup
|
||||
Settings = Settings
|
||||
WebhookSetupPage = Webhook setup page
|
||||
WEBHOOK_AUTOVALIDATE = Allow targets automatic validation
|
||||
|
||||
|
||||
#
|
||||
# About page
|
||||
#
|
||||
About = About
|
||||
WebhookAbout = About Webhook
|
||||
WebhookAboutPage = Webhook about page
|
||||
|
||||
#
|
||||
# Sample page
|
||||
#
|
||||
|
||||
#
|
||||
# Sample widget
|
||||
#
|
||||
MyWidget = My widget
|
||||
MyWidgetDescription = My widget description
|
||||
@ -56,7 +56,7 @@ class Target extends CommonObject
|
||||
/**
|
||||
* @var int Does object support extrafields ? 0=No, 1=Yes
|
||||
*/
|
||||
public $isextrafieldmanaged = 1;
|
||||
public $isextrafieldmanaged = 0;
|
||||
|
||||
/**
|
||||
* @var string String with name of icon for target. Must be the part after the 'object_' into object_target.png
|
||||
@ -103,7 +103,7 @@ class Target extends CommonObject
|
||||
*/
|
||||
public $fields=array(
|
||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
|
||||
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'validate'=>'1', 'comment'=>"Reference of object"),
|
||||
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'index'=>1, 'searchall'=>1, 'validate'=>'1', 'comment'=>"Reference of object"),
|
||||
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1',),
|
||||
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',),
|
||||
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',),
|
||||
@ -112,9 +112,7 @@ class Target extends CommonObject
|
||||
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
|
||||
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
|
||||
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
|
||||
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
|
||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
|
||||
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
|
||||
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>3, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validé', '9'=>'Annulé'), 'validate'=>'1',),
|
||||
'url' => array('type'=>'varchar(255)', 'label'=>'Url', 'enabled'=>'1', 'position'=>50, 'notnull'=>1, 'visible'=>1,),
|
||||
'trigger_codes' => array('type'=>'text', 'label'=>'TriggerCodes', 'enabled'=>'1', 'position'=>50, 'notnull'=>1, 'visible'=>1, 'help'=>"TriggerCodeInfo",),
|
||||
@ -129,9 +127,7 @@ class Target extends CommonObject
|
||||
public $tms;
|
||||
public $fk_user_creat;
|
||||
public $fk_user_modif;
|
||||
public $last_main_doc;
|
||||
public $import_key;
|
||||
public $model_pdf;
|
||||
public $status;
|
||||
public $url;
|
||||
public $trigger_codes;
|
||||
@ -227,6 +223,7 @@ class Target extends CommonObject
|
||||
public function create(User $user, $notrigger = false)
|
||||
{
|
||||
$resultcreate = $this->createCommon($user, $notrigger);
|
||||
$this->ref = $this->id;
|
||||
|
||||
if ($resultcreate <= 0) {
|
||||
return $resultcreate;
|
||||
|
||||
1090
htdocs/webhook/class/target.class.php.back
Normal file
1090
htdocs/webhook/class/target.class.php.back
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,146 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* 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/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/webhook/mod_target_advanced.php
|
||||
* \ingroup webhook
|
||||
* \brief File containing class for advanced numbering model of Target
|
||||
*/
|
||||
|
||||
dol_include_once('/webhook/core/modules/webhook/modules_target.php');
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage customer Bom numbering rules advanced
|
||||
*/
|
||||
class mod_target_advanced extends ModeleNumRefTarget
|
||||
{
|
||||
/**
|
||||
* Dolibarr version of the loaded document
|
||||
* @var string
|
||||
*/
|
||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
|
||||
/**
|
||||
* @var string Error message
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string name
|
||||
*/
|
||||
public $name = 'advanced';
|
||||
|
||||
|
||||
/**
|
||||
* Returns the description of the numbering model
|
||||
*
|
||||
* @return string Texte descripif
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
global $conf, $langs, $db;
|
||||
|
||||
$langs->load("bills");
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
|
||||
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$texte .= '<input type="hidden" name="action" value="updateMask">';
|
||||
$texte .= '<input type="hidden" name="maskconst" value="WEBHOOK_TARGET_ADVANCED_MASK">';
|
||||
$texte .= '<table class="nobordernopadding centpercent">';
|
||||
|
||||
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Target"), $langs->transnoentities("Target"));
|
||||
$tooltip .= $langs->trans("GenericMaskCodes2");
|
||||
$tooltip .= $langs->trans("GenericMaskCodes3");
|
||||
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Target"), $langs->transnoentities("Target"));
|
||||
$tooltip .= $langs->trans("GenericMaskCodes5");
|
||||
|
||||
// Parametrage du prefix
|
||||
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
|
||||
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskvalue" value="'.$conf->global->WEBHOOK_TARGET_ADVANCED_MASK.'">', $tooltip, 1, 1).'</td>';
|
||||
$texte .= '<td class="left" rowspan="2"> <input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
||||
$texte .= '</tr>';
|
||||
|
||||
$texte .= '</table>';
|
||||
$texte .= '</form>';
|
||||
|
||||
return $texte;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an example of numbering
|
||||
*
|
||||
* @return string Example
|
||||
*/
|
||||
public function getExample()
|
||||
{
|
||||
global $conf, $db, $langs, $mysoc;
|
||||
|
||||
$object = new Target($db);
|
||||
$object->initAsSpecimen();
|
||||
|
||||
/*$old_code_client = $mysoc->code_client;
|
||||
$old_code_type = $mysoc->typent_code;
|
||||
$mysoc->code_client = 'CCCCCCCCCC';
|
||||
$mysoc->typent_code = 'TTTTTTTTTT';*/
|
||||
|
||||
$numExample = $this->getNextValue($object);
|
||||
|
||||
/*$mysoc->code_client = $old_code_client;
|
||||
$mysoc->typent_code = $old_code_type;*/
|
||||
|
||||
if (!$numExample) {
|
||||
$numExample = $langs->trans('NotConfigured');
|
||||
}
|
||||
return $numExample;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next free value
|
||||
*
|
||||
* @param Object $object Object we need next value for
|
||||
* @return string Value if KO, <0 if KO
|
||||
*/
|
||||
public function getNextValue($object)
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
// We get cursor rule
|
||||
$mask = $conf->global->WEBHOOK_TARGET_ADVANCED_MASK;
|
||||
|
||||
if (!$mask) {
|
||||
$this->error = 'NotConfigured';
|
||||
return 0;
|
||||
}
|
||||
|
||||
$date = $object->date;
|
||||
|
||||
$numFinal = get_next_value($db, $mask, 'webhook_target', 'ref', '', null, $date);
|
||||
|
||||
return $numFinal;
|
||||
}
|
||||
}
|
||||
@ -1,161 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||
*
|
||||
* 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/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/webhook/mod_target_standard.php
|
||||
* \ingroup webhook
|
||||
* \brief File of class to manage Target numbering rules standard
|
||||
*/
|
||||
dol_include_once('/webhook/core/modules/webhook/modules_target.php');
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage customer order numbering rules standard
|
||||
*/
|
||||
class mod_target_standard extends ModeleNumRefTarget
|
||||
{
|
||||
/**
|
||||
* Dolibarr version of the loaded document
|
||||
* @var string
|
||||
*/
|
||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
|
||||
public $prefix = 'TARGET';
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string name
|
||||
*/
|
||||
public $name = 'standard';
|
||||
|
||||
|
||||
/**
|
||||
* Return description of numbering module
|
||||
*
|
||||
* @return string Text with description
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
global $langs;
|
||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an example of numbering
|
||||
*
|
||||
* @return string Example
|
||||
*/
|
||||
public function getExample()
|
||||
{
|
||||
return $this->prefix."0501-0001";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the numbers already in the database do not
|
||||
* cause conflicts that would prevent this numbering working.
|
||||
*
|
||||
* @param Object $object Object we need next value for
|
||||
* @return boolean false if conflict, true if ok
|
||||
*/
|
||||
public function canBeActivated($object)
|
||||
{
|
||||
global $conf, $langs, $db;
|
||||
|
||||
$coyymm = ''; $max = '';
|
||||
|
||||
$posindice = strlen($this->prefix) + 6;
|
||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."webhook_target";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
if ($object->ismultientitymanaged == 1) {
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
} elseif ($object->ismultientitymanaged == 2) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$row = $db->fetch_row($resql);
|
||||
if ($row) {
|
||||
$coyymm = substr($row[0], 0, 6); $max = $row[0];
|
||||
}
|
||||
}
|
||||
if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans('ErrorNumRefModel', $max);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next free value
|
||||
*
|
||||
* @param Object $object Object we need next value for
|
||||
* @return string Value if KO, <0 if KO
|
||||
*/
|
||||
public function getNextValue($object)
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
// first we get the max value
|
||||
$posindice = strlen($this->prefix) + 6;
|
||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."webhook_target";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
if ($object->ismultientitymanaged == 1) {
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
} elseif ($object->ismultientitymanaged == 2) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$max = intval($obj->max);
|
||||
} else {
|
||||
$max = 0;
|
||||
}
|
||||
} else {
|
||||
dol_syslog("mod_target_standard::getNextValue", LOG_DEBUG);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//$date=time();
|
||||
$date = $object->date_creation;
|
||||
$yymm = strftime("%y%m", $date);
|
||||
|
||||
if ($max >= (pow(10, 4) - 1)) {
|
||||
$num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
|
||||
} else {
|
||||
$num = sprintf("%04s", $max + 1);
|
||||
}
|
||||
|
||||
dol_syslog("mod_target_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||
return $this->prefix.$yymm."-".$num;
|
||||
}
|
||||
}
|
||||
@ -1,158 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
* 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/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/webhook/modules_target.php
|
||||
* \ingroup webhook
|
||||
* \brief File that contains parent class for targets document models and parent class for targets numbering models
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
|
||||
|
||||
|
||||
/**
|
||||
* Parent class for documents models
|
||||
*/
|
||||
abstract class ModelePDFTarget extends CommonDocGenerator
|
||||
{
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return list of active generation modules
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param integer $maxfilenamelength Max length of value to show
|
||||
* @return array List of templates
|
||||
*/
|
||||
public static function liste_modeles($db, $maxfilenamelength = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf;
|
||||
|
||||
$type = 'target';
|
||||
$list = array();
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
$list = getListOfModels($db, $type, $maxfilenamelength);
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parent class to manage numbering of Target
|
||||
*/
|
||||
abstract class ModeleNumRefTarget
|
||||
{
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* Return if a module can be used or not
|
||||
*
|
||||
* @return boolean true if module can be used
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default description of the numbering template
|
||||
*
|
||||
* @return string Texte descripif
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("webhook@webhook");
|
||||
return $langs->trans("NoDescription");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an example of numbering
|
||||
*
|
||||
* @return string Example
|
||||
*/
|
||||
public function getExample()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("webhook@webhook");
|
||||
return $langs->trans("NoExample");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the numbers already in the database do not
|
||||
* cause conflicts that would prevent this numbering working.
|
||||
*
|
||||
* @param Object $object Object we need next value for
|
||||
* @return boolean false if conflict, true if ok
|
||||
*/
|
||||
public function canBeActivated($object)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns next assigned value
|
||||
*
|
||||
* @param Object $object Object we need next value for
|
||||
* @return string Valeur
|
||||
*/
|
||||
public function getNextValue($object)
|
||||
{
|
||||
global $langs;
|
||||
return $langs->trans("NotAvailable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns version of numbering module
|
||||
*
|
||||
* @return string Valeur
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
|
||||
if ($this->version == 'development') {
|
||||
return $langs->trans("VersionDevelopment");
|
||||
}
|
||||
if ($this->version == 'experimental') {
|
||||
return $langs->trans("VersionExperimental");
|
||||
}
|
||||
if ($this->version == 'dolibarr') {
|
||||
return DOL_VERSION;
|
||||
}
|
||||
if ($this->version) {
|
||||
return $this->version;
|
||||
}
|
||||
return $langs->trans("NotAvailable");
|
||||
}
|
||||
}
|
||||
@ -57,7 +57,7 @@ function targetPrepareHead($object)
|
||||
$h++;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
/*require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->webhook->dir_output."/target/".dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
@ -68,12 +68,12 @@ function targetPrepareHead($object)
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
|
||||
}
|
||||
$head[$h][2] = 'document';
|
||||
$h++;
|
||||
$h++;*/
|
||||
|
||||
$head[$h][0] = dol_buildpath("/webhook/target_agenda.php", 1).'?id='.$object->id;
|
||||
/*$head[$h][0] = dol_buildpath("/webhook/target_agenda.php", 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Events");
|
||||
$head[$h][2] = 'agenda';
|
||||
$h++;
|
||||
$h++;*/
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
|
||||
@ -1,261 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* 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 target_document.php
|
||||
* \ingroup webhook
|
||||
* \brief Tab for documents linked to Target
|
||||
*/
|
||||
|
||||
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
|
||||
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
|
||||
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
|
||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
|
||||
//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
|
||||
//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
|
||||
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
|
||||
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
|
||||
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
|
||||
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
|
||||
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
|
||||
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
|
||||
//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
|
||||
//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
|
||||
//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
|
||||
//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
|
||||
//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
|
||||
//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies
|
||||
//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
|
||||
//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
|
||||
|
||||
// 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 && file_exists("../../../main.inc.php")) {
|
||||
$res = @include "../../../main.inc.php";
|
||||
}
|
||||
if (!$res) {
|
||||
die("Include of main fails");
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
dol_include_once('/webhook/class/target.class.php');
|
||||
dol_include_once('/webhook/lib/webhook_target.lib.php');
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("webhook@webhook", "companies", "other", "mails"));
|
||||
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm');
|
||||
$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
|
||||
// Get parameters
|
||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "name";
|
||||
}
|
||||
//if (! $sortfield) $sortfield="position_name";
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Target($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->webhook->dir_output.'/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('targetdocument', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$upload_dir = $conf->webhook->multidir_output[$object->entity ? $object->entity : $conf->entity]."/target/".get_exdir(0, 0, 0, 1, $object);
|
||||
}
|
||||
|
||||
// There is several ways to check permission.
|
||||
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
|
||||
$enablepermissioncheck = 0;
|
||||
if ($enablepermissioncheck) {
|
||||
$permissiontoread = $user->rights->webhook->target->read;
|
||||
$permissiontoadd = $user->rights->webhook->target->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
|
||||
} else {
|
||||
$permissiontoread = 1;
|
||||
$permissiontoadd = 1;
|
||||
}
|
||||
|
||||
// Security check (enable the most restrictive one)
|
||||
//if ($user->socid > 0) accessforbidden();
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->webhook->enabled)) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans("Target").' - '.$langs->trans("Files");
|
||||
$help_url = '';
|
||||
//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if ($object->id) {
|
||||
/*
|
||||
* Show tabs
|
||||
*/
|
||||
$head = targetPrepareHead($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'document', $langs->trans("Target"), -1, $object->picto);
|
||||
|
||||
|
||||
// Build file list
|
||||
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
|
||||
$totalsize = 0;
|
||||
foreach ($filearray as $key => $file) {
|
||||
$totalsize += $file['size'];
|
||||
}
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="'.dol_buildpath('/webhook/target_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
/*
|
||||
// Ref customer
|
||||
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
|
||||
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||
if ($permissiontoadd)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
$morehtmlref.=' : ';
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
} else {
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref .= ': '.$proj->getNomUrl();
|
||||
} else {
|
||||
$morehtmlref .= '';
|
||||
}
|
||||
}
|
||||
}*/
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
// Number of files
|
||||
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
|
||||
|
||||
// Total size
|
||||
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
$modulepart = 'webhook';
|
||||
//$permissiontoadd = $user->rights->webhook->target->write;
|
||||
$permissiontoadd = 1;
|
||||
//$permtoedit = $user->rights->webhook->target->write;
|
||||
$permtoedit = 1;
|
||||
$param = '&id='.$object->id;
|
||||
|
||||
//$relativepathwithnofile='target/' . dol_sanitizeFileName($object->id).'/';
|
||||
$relativepathwithnofile = 'target/'.dol_sanitizeFileName($object->ref).'/';
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
|
||||
} else {
|
||||
accessforbidden('', 0, 1);
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -1,304 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2022 SuperAdmin <test@dolibarr.com>
|
||||
*
|
||||
* 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 test/phpunit/WebhookFunctionalTest.php
|
||||
* \ingroup webhook
|
||||
* \brief Example Selenium test.
|
||||
*
|
||||
* Put detailed description here.
|
||||
*/
|
||||
|
||||
namespace test\functional;
|
||||
|
||||
use PHPUnit_Extensions_Selenium2TestCase_WebDriverException;
|
||||
|
||||
/**
|
||||
* Class WebhookFunctionalTest
|
||||
*
|
||||
* Requires chromedriver for Google Chrome
|
||||
* Requires geckodriver for Mozilla Firefox
|
||||
*
|
||||
* @fixme Firefox (Geckodriver/Marionette) support
|
||||
* @todo Opera linux support
|
||||
* @todo Windows support (IE, Google Chrome, Mozilla Firefox, Safari)
|
||||
* @todo OSX support (Safari, Google Chrome, Mozilla Firefox)
|
||||
*
|
||||
* @package Testwebhook
|
||||
*/
|
||||
class WebhookFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
// TODO: move to a global configuration file?
|
||||
/** @var string Base URL of the webserver under test */
|
||||
protected static $base_url = 'http://dev.zenfusion.fr';
|
||||
/**
|
||||
* @var string Dolibarr admin username
|
||||
* @see authenticate
|
||||
*/
|
||||
protected static $dol_admin_user = 'admin';
|
||||
/**
|
||||
* @var string Dolibarr admin password
|
||||
* @see authenticate
|
||||
*/
|
||||
protected static $dol_admin_pass = 'admin';
|
||||
/** @var int Dolibarr module ID */
|
||||
private static $module_id = 500000; // TODO: autodetect?
|
||||
|
||||
/** @var array Browsers to test with */
|
||||
public static $browsers = array(
|
||||
array(
|
||||
'browser' => 'Google Chrome on Linux',
|
||||
'browserName' => 'chrome',
|
||||
'sessionStrategy' => 'shared',
|
||||
'desiredCapabilities' => array()
|
||||
),
|
||||
// Geckodriver does not keep the session at the moment?!
|
||||
// XPath selectors also don't seem to work
|
||||
//array(
|
||||
// 'browser' => 'Mozilla Firefox on Linux',
|
||||
// 'browserName' => 'firefox',
|
||||
// 'sessionStrategy' => 'shared',
|
||||
// 'desiredCapabilities' => array(
|
||||
// 'marionette' => true,
|
||||
// ),
|
||||
//)
|
||||
);
|
||||
|
||||
/**
|
||||
* Helper function to select links by href
|
||||
*
|
||||
* @param string $value Href
|
||||
* @return mixed Helper string
|
||||
*/
|
||||
protected function byHref($value)
|
||||
{
|
||||
$anchor = null;
|
||||
$anchors = $this->elements($this->using('tag name')->value('a'));
|
||||
foreach ($anchors as $anchor) {
|
||||
if (strstr($anchor->attribute('href'), $value)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Global test setup
|
||||
* @return void
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit test setup
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->setSeleniumServerRequestsTimeout(3600);
|
||||
$this->setBrowserUrl(self::$base_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify pre conditions
|
||||
* @return void
|
||||
*/
|
||||
protected function assertPreConditions()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Dolibarr authentication
|
||||
* @return void
|
||||
*/
|
||||
private function authenticate()
|
||||
{
|
||||
try {
|
||||
if ($this->byId('login')) {
|
||||
$login = $this->byId('username');
|
||||
$login->clear();
|
||||
$login->value('admin');
|
||||
$password = $this->byId('password');
|
||||
$password->clear();
|
||||
$password->value('admin');
|
||||
$this->byId('login')->submit();
|
||||
}
|
||||
} catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
|
||||
// Login does not exist. Assume we are already authenticated
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test enabling developer mode
|
||||
* @return bool
|
||||
*/
|
||||
public function testEnableDeveloperMode()
|
||||
{
|
||||
$this->url('/admin/const.php');
|
||||
$this->authenticate();
|
||||
$main_features_level_path = '//input[@value="MAIN_FEATURES_LEVEL"]/following::input[@type="text"]';
|
||||
$main_features_level = $this->byXPath($main_features_level_path);
|
||||
$main_features_level->clear();
|
||||
$main_features_level->value('2');
|
||||
$this->byName('update')->click();
|
||||
// Page reloaded, we need a new XPath
|
||||
$main_features_level = $this->byXPath($main_features_level_path);
|
||||
return $this->assertEquals('2', $main_features_level->value(), "MAIN_FEATURES_LEVEL value is 2");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test enabling the module
|
||||
*
|
||||
* @depends testEnableDeveloperMode
|
||||
* @return bool
|
||||
*/
|
||||
public function testModuleEnabled()
|
||||
{
|
||||
$this->url('/admin/modules.php');
|
||||
$this->authenticate();
|
||||
$module_status_image_path = '//a[contains(@href, "'.self::$module_id.'")]/img';
|
||||
$module_status_image = $this->byXPath($module_status_image_path);
|
||||
if (strstr($module_status_image->attribute('src'), 'switch_off.png')) {
|
||||
// Enable the module
|
||||
$this->byHref('modWebhook')->click();
|
||||
} else {
|
||||
// Disable the module
|
||||
$this->byHref('modWebhook')->click();
|
||||
// Reenable the module
|
||||
$this->byHref('modWebhook')->click();
|
||||
}
|
||||
// Page reloaded, we need a new Xpath
|
||||
$module_status_image = $this->byXPath($module_status_image_path);
|
||||
return $this->assertContains('switch_on.png', $module_status_image->attribute('src'), "Module enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test access to the configuration page
|
||||
*
|
||||
* @depends testModuleEnabled
|
||||
* @return bool
|
||||
*/
|
||||
public function testConfigurationPage()
|
||||
{
|
||||
$this->url('/custom/webhook/admin/setup.php');
|
||||
$this->authenticate();
|
||||
return $this->assertContains('webhook/admin/setup.php', $this->url(), 'Configuration page');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test access to the about page
|
||||
*
|
||||
* @depends testConfigurationPage
|
||||
* @return bool
|
||||
*/
|
||||
public function testAboutPage()
|
||||
{
|
||||
$this->url('/custom/webhook/admin/about.php');
|
||||
$this->authenticate();
|
||||
return $this->assertContains('webhook/admin/about.php', $this->url(), 'About page');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test about page is rendering Markdown
|
||||
*
|
||||
* @depends testAboutPage
|
||||
* @return bool
|
||||
*/
|
||||
public function testAboutPageRendersMarkdownReadme()
|
||||
{
|
||||
$this->url('/custom/webhook/admin/about.php');
|
||||
$this->authenticate();
|
||||
return $this->assertEquals(
|
||||
'Dolibarr Module Template (aka My Module)',
|
||||
$this->byTag('h1')->text(),
|
||||
"Readme title"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test box is properly declared
|
||||
*
|
||||
* @depends testModuleEnabled
|
||||
* @return bool
|
||||
*/
|
||||
public function testBoxDeclared()
|
||||
{
|
||||
$this->url('/admin/boxes.php');
|
||||
$this->authenticate();
|
||||
return $this->assertContains('webhookwidget1', $this->source(), "Box enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test trigger is properly enabled
|
||||
*
|
||||
* @depends testModuleEnabled
|
||||
* @return bool
|
||||
*/
|
||||
public function testTriggerDeclared()
|
||||
{
|
||||
$this->url('/admin/triggers.php');
|
||||
$this->authenticate();
|
||||
return $this->assertContains(
|
||||
'interface_99_modWebhook_WebhookTriggers.class.php',
|
||||
$this->byTag('body')->text(),
|
||||
"Trigger declared"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test trigger is properly declared
|
||||
*
|
||||
* @depends testTriggerDeclared
|
||||
* @return bool
|
||||
*/
|
||||
public function testTriggerEnabled()
|
||||
{
|
||||
$this->url('/admin/triggers.php');
|
||||
$this->authenticate();
|
||||
return $this->assertContains(
|
||||
'tick.png',
|
||||
$this->byXPath('//td[text()="interface_99_modWebhook_MyTrigger.class.php"]/following::img')->attribute('src'),
|
||||
"Trigger enabled"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify post conditions
|
||||
* @return void
|
||||
*/
|
||||
protected function assertPostConditions()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit test teardown
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Global test teardown
|
||||
* @return void
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user