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';
62$action =
GETPOST(
'action',
'aZ09');
63$triggercode =
GETPOST(
'triggercode');
66if (empty($user->admin)) {
84if ($action ==
"getjsonformtrigger") {
90 if (!empty($triggercode)) {
92 $objecttriggername = array();
93 preg_match(
'#\((.*?)\)#', $triggercode, $objecttriggername);
95 $json->triggercode = empty($objecttriggername[1]) ? $triggercode : $objecttriggername[1];
97 if (!empty($json->triggercode)) {
98 $objtype = explode(
"_", $json->triggercode)[0];
100 if (is_object($obj)) {
101 dol_syslog(
"Ajax webhook: We clean object fetched");
103 foreach ($properties as $key => $property) {
104 if (empty($property)) {
110 unset($obj->table_element);
112 unset($obj->isextrafieldmanaged);
113 unset($obj->ismultientitymanaged);
115 $json->object = $obj;
124 dol_syslog(
"Ajax webhook: Class not found for trigger code ".$json->triggercode);
126 $json->object->field1 =
'field1';
127 $json->object->field2 =
'field2';
128 $json->object->field3 =
'field3';
132 $response = json_encode($json);
144 dol_syslog(
"Ajax webhook: We fetch object of type = ".$objecttype.
" and we init it as specimen");
146 if (is_object($obj)) {
147 '@phan-var-force CommonObject $obj';
148 $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.