The API discovery loop in htdocs/api/index.php (around line 308) accepts
both Foo and FooApi class names when scanning module directories. The
dispatch loop on the request-handling side (line 422) only checked
class_exists($classname), so a module exposing class MyModuleApi from
api_mymodule.class.php would appear in the API Explorer yet 501 with
'API not found' when the endpoint was actually called.
Probe class_exists($classname.'Api') first to mirror the discovery
behavior. Falls back to the plain class name so existing modules keep
working.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
API endpoints return JSON or XML. When PHP display_errors is on (the
default outside production), any warning or notice raised before the
response is written ends up in the response body and breaks the parser
on the caller side. The reporter noted that "HTML should never appear
before a JSON answer", which is exactly what happens to a development
or staging install whose conf.php does not set dolibarr_main_prod.
Set display_errors=0 and log_errors=1 at the top of api/index.php so
that the messages stay visible in the server log while the response
body stays clean. This applies to every API call independently of the
production flag handled by filefunc.inc.php.
Reported by @gagarine.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
* check if MAIN_AGENDA_XCAL_EXPORTKEY is set before using it
* suggestion from frederic34
* adding 5 new statuses and their functions
* adding 5 new statuses and their functions
* copy and modified from email template api
* remove some unset because they are present in the database
* all objects are ConferenceOrBoothAttendee's
* load eventattendee API file from eventorganization/ folder
* ref is not required and should perhaps be banned because it is ignored during create + nonexisting apifetch function replaced with call to just fetch + making usre to use the correct class
* variable named paid is unused?
* get all event attendees
* fixing the sql statement
* adjusting function checking access rights
* UNTESTED! multicompany support by leftjoining with the projet table which does have an entity column + adjusting checkAccessRights function to prepare for testing project visibility
* adding more statuses and explaining boarding pass better
* expanding access rights checks with a project id and starting to use that after fetch so we know the project_id
* checking if the user has access to the project specified in fk_project
* phan fix getting right
* checking if isModEnabled('multicompany')
* will only show rows of projects which is either public or the user is a contact of
* 2 new status changing functions and some protection for the existing status changing functions
* fix pre-commit check
* typo fix = that should be ==
* adding extrafields and linkedobjectids to event attendee
* should be back to develop branch contents so PR can be smaller
* reducing PR size, just GET and POST
* smallest commit, just the post and functions needed by post
---------
Co-authored-by: Jon Bendtsen <xcodeauthor@jonb.dk>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* adding function to set it to draft mode
* New API endpoint for controlling mass mailings
* report which id we could not find + unset some fields not on this object + write that source was com/propal/class/api_propal.class.php
* extending the fetch function for the mailing object so the API can show all columns in the database
* filling more data into the object and don't unset it later
* adding notrigger to clone creation
* still some cleaning up from when cloning api_proposals.class.php
* do not unset the ID, because we want the ID so we can use it
* adding endpoint to clone a mass mailing
* extending count function with 'all' that just returns all rows, no matter the status
* API endpoints to delete all targets of a mass mailing
* setting which http method to use
* pretty print clone endpoint in API explorer
* endpoint resetTargetsStatus of mass mailing
* Typo receipients fixed
* Update api_mailings.class.php
* Update api_mailings.class.php
* Update api_mailings.class.php
---------
Co-authored-by: Jon Bendtsen <xcodeauthor@jonb.dk>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* When api/temp folder does not exist or isn't writeable dol_syslog what the folder is and print where to find that information
* flipping line order
* putting suslog line first
* back to original print
---------
Co-authored-by: Jon Bendtsen <xcodeauthor@jonb.dk>
# Fix: Use of deprecated fichinter in dynamic modulename
The modulename is computed dynamically and could use deprecated fichinter
module name.
Also optimised the test.
As discussed in the pull request conversation :
- remove unnecessary flush calls ;
- remove termination callback method from Restler code and set it back into api/index.php
This commit allows Rester to immediately send response data back to the client before completing some time consuming post-processing tasks (such as sending emails) in a termination callback if defined.
Termination callback should be created into the same class as the API method it terminates. Callback name must match the following format : "_terminate_" + <API_METHOD_NAME> + "_" + <API_METHOD_RESPONSE_FORMAT_EXTENSION>.
For instance, termination callback for orders "post" method defined in htdocs/commande/class/api_orders.class.php must be named "_terminate_post_json".
Mostly comments, one variable changed from misspelling to .
Also changed CNAT to C.N.A.T in comment to avoid fix from CNAT to CAN'T.
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>