23if (!defined(
'NOTOKENRENEWAL')) {
24 define(
'NOTOKENRENEWAL',
'1');
26if (!defined(
'NOREQUIREHTML')) {
27 define(
'NOREQUIREHTML',
'1');
29if (!defined(
'NOREQUIREAJAX')) {
30 define(
'NOREQUIREAJAX',
'1');
32if (!defined(
'NOREQUIRESOC')) {
33 define(
'NOREQUIRESOC',
'1');
36if (!defined(
'NOREQUIREMENU')) {
37 define(
'NOREQUIREMENU',
'1');
40if (!empty($_GET[
'public'])) {
41 if (!defined(
"NOLOGIN")) {
42 define(
"NOLOGIN",
'1');
45if (!defined(
'NOIPCHECK')) {
46 define(
'NOIPCHECK',
'1');
48if (!defined(
'NOBROWSERNOTIF')) {
49 define(
'NOBROWSERNOTIF',
'1');
51include
'../../main.inc.php';
52require_once DOL_DOCUMENT_ROOT.
'/webhook/class/target.class.php';
54$action =
GETPOST(
'action',
'aZ09');
55$triggercode =
GETPOST(
'triggercode');
58if (empty($user->admin)) {
76if ($action ==
"getjsonformtrigger") {
82 if (!empty($triggercode)) {
84 $objecttriggername = array();
85 preg_match(
'#\((.*?)\)#', $triggercode, $objecttriggername);
87 $json->triggercode = empty($objecttriggername[1]) ? $triggercode : $objecttriggername[1];
89 if (!empty($json->triggercode)) {
90 $objtype = explode(
"_", $json->triggercode)[0];
92 if (is_object($obj)) {
93 dol_syslog(
"Ajax webhook: We clean object fetched");
95 foreach ($properties as $key => $property) {
96 if (empty($property)) {
102 unset($obj->table_element);
104 unset($obj->isextrafieldmanaged);
105 unset($obj->ismultientitymanaged);
107 $json->object = $obj;
116 dol_syslog(
"Ajax webhook: Class not found for trigger code ".$json->triggercode);
118 $json->object->field1 =
'field1';
119 $json->object->field2 =
'field2';
120 $json->object->field3 =
'field3';
124 $response = json_encode($json);
136 dol_syslog(
"Ajax webhook: We fetch object of type = ".$objecttype.
" and we init it as specimen");
138 if (is_object($obj)) {
139 $obj->initAsSpecimen();
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
dol_get_object_properties($obj, $properties=[])
Get properties for an object - including magic properties when requested.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
fetchObjectByElement($element_id, $element_type, $element_ref='', $useCache=0, $maxCacheByType=10)
Fetch an object from its id and element_type Inclusion of classes is automatic.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
if( $action=="getjsonformtrigger") findobjecttosend($objecttype)
Find and init a specimen for the given object type.