24if (!defined(
'NOTOKENRENEWAL')) {
25 define(
'NOTOKENRENEWAL',
'1');
27if (!defined(
'NOREQUIREHTML')) {
28 define(
'NOREQUIREHTML',
'1');
30if (!defined(
'NOREQUIREAJAX')) {
31 define(
'NOREQUIREAJAX',
'1');
33if (!defined(
'NOREQUIRESOC')) {
34 define(
'NOREQUIRESOC',
'1');
37if (!defined(
'NOREQUIREMENU')) {
38 define(
'NOREQUIREMENU',
'1');
41if (!empty($_GET[
'public'])) {
42 if (!defined(
"NOLOGIN")) {
43 define(
"NOLOGIN",
'1');
46if (!defined(
'NOIPCHECK')) {
47 define(
'NOIPCHECK',
'1');
49if (!defined(
'NOBROWSERNOTIF')) {
50 define(
'NOBROWSERNOTIF',
'1');
52include
'../../main.inc.php';
53require_once DOL_DOCUMENT_ROOT.
'/webhook/class/target.class.php';
55$action =
GETPOST(
'action',
'aZ09');
56$triggercode =
GETPOST(
'triggercode');
59if (empty($user->admin)) {
77if ($action ==
"getjsonformtrigger") {
83 if (!empty($triggercode)) {
85 $objecttriggername = array();
86 preg_match(
'#\((.*?)\)#', $triggercode, $objecttriggername);
88 $json->triggercode = empty($objecttriggername[1]) ? $triggercode : $objecttriggername[1];
90 if (!empty($json->triggercode)) {
91 $objtype = explode(
"_", $json->triggercode)[0];
93 if (is_object($obj)) {
94 dol_syslog(
"Ajax webhook: We clean object fetched");
96 foreach ($properties as $key => $property) {
97 if (empty($property)) {
103 unset($obj->table_element);
105 unset($obj->isextrafieldmanaged);
106 unset($obj->ismultientitymanaged);
108 $json->object = $obj;
117 dol_syslog(
"Ajax webhook: Class not found for trigger code ".$json->triggercode);
119 $json->object->field1 =
'field1';
120 $json->object->field2 =
'field2';
121 $json->object->field3 =
'field3';
125 $response = json_encode($json);
137 dol_syslog(
"Ajax webhook: We fetch object of type = ".$objecttype.
" and we init it as specimen");
139 if (is_object($obj)) {
140 '@phan-var-force CommonObject $obj';
141 $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.