12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /* <one line to give the program's name and a brief idea of what it does.>
- * Copyright (C) <year> <name of author>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * \file htdocs/modulebuilder/template/class/actions_mymodule.class.php
- * \ingroup mymodule
- * \brief Example hook overload.
- *
- * Put detailed description here.
- */
- /**
- * Class ActionsMyModule
- */
- class ActionsMyModule
- {
- /**
- * @var array Hook results. Propagated to $hookmanager->resArray for later reuse
- */
- public $results = array();
- /**
- * @var string String displayed by executeHook() immediately after return
- */
- public $resprints;
- /**
- * @var array Errors
- */
- public $errors = array();
- /**
- * Constructor
- */
- public function __construct()
- {
- }
- /**
- * Overloading the doActions function : replacing the parent's function with the one below
- *
- * @param array() $parameters Hook metadatas (context, etc...)
- * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
- * @param string $action Current action (if set). Generally create or edit or null
- * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
- * @return int < 0 on error, 0 on success, 1 to replace standard code
- */
- public function doActions($parameters, &$object, &$action, $hookmanager)
- {
- $error = 0; // Error counter
- $myvalue = 'test'; // A result value
- print_r($parameters);
- echo "action: " . $action;
- print_r($object);
- if (in_array('somecontext', explode(':', $parameters['context']))) {
- // do something only for the context 'somecontext'
- }
- if (! $error) {
- $this->results = array('myreturn' => $myvalue);
- $this->resprints = 'A text to show';
- return 0; // or return 1 to replace standard code
- } else {
- $this->errors[] = 'Error message';
- return -1;
- }
- }
- }
|