(most) API calls do not trigger plugins
Summary
Hi,
this has also been reported in https://forum.howtoforge.com/threads/working-with-plugin-control-panel-vs-api.86218/ but I think it's better to have it properly in the bug tracker, as it doesn't seem to be here yet.
Proposed fix
At my company, we had to do this:
--- a/interface/lib/classes/remote.d/sites.inc.php
+++ b/interface/lib/classes/remote.d/sites.inc.php
@@ -221,8 +221,7 @@ class remoting_sites extends remoting {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
-
- return $this->insertQuery('../sites/form/database_user.tform.php', $client_id, $params);
+ return $this->insertQuery('../sites/form/database_user.tform.php', $client_id, $params, 'sites:database_user:on_after_insert');
}
//* Update a record
@@ -238,7 +237,7 @@ class remoting_sites extends remoting {
$app->remoting_lib->loadFormDef('../sites/form/database_user.tform.php');
$old_rec = $app->remoting_lib->getDataRecord($primary_id);
- $result = $this->updateQuery('../sites/form/database_user.tform.php', $client_id, $primary_id, $params);
+ $result = $this->updateQuery('../sites/form/database_user.tform.php', $client_id, $primary_id, $params, 'sites:database_user:on_after_update');
$new_rec = $app->remoting_lib->getDataRecord($primary_id);
@@ -266,7 +265,7 @@ class remoting_sites extends remoting {
}
//$app->db->datalogDelete('web_database_user', 'database_user_id', $primary_id);
- $affected_rows = $this->deleteQuery('../sites/form/database_user.tform.php', $primary_id);
+ $affected_rows = $this->deleteQuery('../sites/form/database_user.tform.php', $primary_id, 'sites:database_user:on_after_delete');
$records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_user_id = ?", $primary_id);
foreach($records as $rec) {
@@ -304,7 +303,7 @@ class remoting_sites extends remoting {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
- return $this->insertQuery('../sites/form/ftp_user.tform.php', $client_id, $params);
+ return $this->insertQuery('../sites/form/ftp_user.tform.php', $client_id, $params, 'sites:ftp_user:on_after_insert');
}
//* Update a record
@@ -314,7 +313,7 @@ class remoting_sites extends remoting {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
- $affected_rows = $this->updateQuery('../sites/form/ftp_user.tform.php', $client_id, $primary_id, $params);
+ $affected_rows = $this->updateQuery('../sites/form/ftp_user.tform.php', $client_id, $primary_id, $params, 'sites:ftp_user:on_after_update');
return $affected_rows;
}
@@ -325,7 +324,7 @@ class remoting_sites extends remoting {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
- $affected_rows = $this->deleteQuery('../sites/form/ftp_user.tform.php', $primary_id);
+ $affected_rows = $this->deleteQuery('../sites/form/ftp_user.tform.php', $primary_id, 'sites:ftp_user:on_after_delete');
return $affected_rows;
}
Now, I'm not proposing a MR because it wouldn't make sense to do this partially, but do think this is something that should be done at all, or else how to think this bug should be handled?