diff --git a/admin/objecthistory_setup.php b/admin/objecthistory_setup.php
index 02fa5ca..a0936d4 100644
--- a/admin/objecthistory_setup.php
+++ b/admin/objecthistory_setup.php
@@ -23,9 +23,9 @@
* Put some comments here
*/
// Dolibarr environment
-$res = @include("../../main.inc.php"); // From htdocs directory
+$res = @include "../../main.inc.php"; // From htdocs directory
if (! $res) {
- $res = @include("../../../main.inc.php"); // From "custom" directory
+ $res = @include "../../../main.inc.php"; // From "custom" directory
}
// Libraries
@@ -39,7 +39,7 @@
// Access control
if (! $user->admin) {
- accessforbidden();
+ accessforbidden();
}
// Parameters
@@ -48,33 +48,25 @@
/*
* Actions
*/
-if (preg_match('/set_(.*)/',$action,$reg))
-{
+if (preg_match('/set_(.*)/', $action, $reg)) {
$code=$reg[1];
$val = GETPOST($code);
if ($code == 'OBJECTHISTORY_HOOKS_ALLOWED' && !empty($val)) $val = implode(',', $val);
- if (dolibarr_set_const($db, $code, $val, 'chaine', 0, '', $conf->entity) > 0)
- {
+ if (dolibarr_set_const($db, $code, $val, 'chaine', 0, '', $conf->entity) > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
- }
- else
- {
+ } else {
dol_print_error($db);
}
}
-
-if (preg_match('/del_(.*)/',$action,$reg))
-{
+
+if (preg_match('/del_(.*)/', $action, $reg)) {
$code=$reg[1];
- if (dolibarr_del_const($db, $code, 0) > 0)
- {
+ if (dolibarr_del_const($db, $code, 0) > 0) {
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
- }
- else
- {
+ } else {
dol_print_error($db);
}
}
@@ -87,18 +79,18 @@
// Subheader
$linkback = ''
- . $langs->trans("BackToModuleList") . '';
+ . $langs->trans("BackToModuleList") . '';
print load_fiche_titre($langs->trans($page_name), $linkback);
$notab = -1;
// Configuration header
$head = objecthistoryAdminPrepareHead();
dol_fiche_head(
- $head,
- 'settings',
- $langs->trans("Module104089Name"),
+ $head,
+ 'settings',
+ $langs->trans("Module104089Name"),
$notab,
- "objecthistory@objecthistory"
+ "objecthistory@objecthistory"
);
// Setup page goes here
@@ -107,9 +99,9 @@
print '
';
-if(!function_exists('setup_print_title')){
- print ''.$langs->trans('AbricotNeedUpdate').' :
Wiki ';
- exit;
+if (!function_exists('setup_print_title')) {
+ print ''.$langs->trans('AbricotNeedUpdate').' :
Wiki ';
+ exit;
}
setup_print_title("Parameters");
diff --git a/class/actions_objecthistory.class.php b/class/actions_objecthistory.class.php
index 34e8e02..4a11a0f 100644
--- a/class/actions_objecthistory.class.php
+++ b/class/actions_objecthistory.class.php
@@ -65,6 +65,8 @@ class ActionsObjectHistory
/**
* Constructor
+ *
+ * @param DoliDB $db Database handler
*/
public function __construct($db)
{
@@ -83,38 +85,33 @@ public function __construct($db)
/**
* 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 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
*/
- function doActions($parameters, &$object, &$action, $hookmanager)
+ public function doActions($parameters, &$object, &$action, $hookmanager)
{
global $conf,$langs,$user;
- $TContext = explode(':',$parameters['context']);
+ $TContext = explode(':', $parameters['context']);
$interSect = array_intersect($TContext, ObjectHistory::getTHookAllowed());
- if (!empty($interSect))
- {
- if (getDolGlobalString('OBJECTHISTORY_ARCHIVE_ON_MODIFY'))
- {
+ if (!empty($interSect)) {
+ if (getDolGlobalString('OBJECTHISTORY_ARCHIVE_ON_MODIFY')) {
// CommandeFournisseur = reopen
- if ($action == 'modif' || $object->element == 'order_supplier' && $object->statut == 2 && $action == 'reopen')
- {
+ if ($action == 'modif' || $object->element == 'order_supplier' && $object->statut == 2 && $action == 'reopen') {
$action = 'objecthistory_modif';
return 1; // on saute l'action par défaut en retournant 1, puis on affiche la pop-in dans formConfirm()
}
// Ask if proposal archive wanted
- if ($action == 'objecthistory_confirm_modify')
- {
+ if ($action == 'objecthistory_confirm_modify') {
// New version if wanted
$archive_object = GETPOST('archive_object', 'alpha');
- if ($archive_object == 'on')
- {
-// TPropaleHist::archiverPropale($ATMdb, $object);
+ if ($archive_object == 'on') {
+ // TPropaleHist::archiverPropale($ATMdb, $object);
$res = ObjectHistory::archiveObject($object);
if ($res > 0) setEventMessage($langs->trans('ObjectHistoryVersionSuccessfullArchived'));
@@ -132,16 +129,14 @@ function doActions($parameters, &$object, &$action, $hookmanager)
}
// l'action "delete_archive" affiche une popin de confirmation, donc il faut garder l'arrière plan dans la version précédemment sélectionnée
- if($action == 'confirm_view_archive' || $action == 'delete_archive')
- {
+ if ($action == 'confirm_view_archive' || $action == 'delete_archive') {
$id = $object->id;
if ($object->element == 'propal') $object = new PropalHistory($this->db);
elseif ($object->element == 'commande') $object = new CommandeHistory($this->db);
elseif ($object->element == 'supplier_proposal') $object = new SupplierProposalHistory($this->db);
elseif ($object->element == 'order_supplier') $object = new CommandeFournisseurHistory($this->db);
- else
- {
+ else {
// Object not handled
return 0;
}
@@ -152,34 +147,29 @@ function doActions($parameters, &$object, &$action, $hookmanager)
$version->fetch(GETPOST('idVersion'));
$version->unserializeObject();
-// if (!empty($object->fields))
-// {
-// foreach ($object->fields as $key => &$val)
-// {
-// $val = $version->serialized_object_source->{$key};
-// }
-// }
-// else
-// {
- foreach($version->serialized_object_source as $k => $v)
- {
- if ($k == 'db') continue;
- $object->{$k} = $v;
- }
+ // if (!empty($object->fields))
+ // {
+ // foreach ($object->fields as $key => &$val)
+ // {
+ // $val = $version->serialized_object_source->{$key};
+ // }
+ // }
+ // else
+ // {
+ foreach ($version->serialized_object_source as $k => $v) {
+ if ($k == 'db') continue;
+ $object->{$k} = $v;
+ }
- foreach($object->lines as &$line)
- {
- $line->description = $line->desc;
- $line->db = $this->db;
- //$line->fetch_optionals();
- }
-// }
+ foreach ($object->lines as &$line) {
+ $line->description = $line->desc;
+ $line->db = $this->db;
+ //$line->fetch_optionals();
+ }
+ // }
return 1;
-
- }
- elseif($action == 'create_archive')
- {
+ } elseif ($action == 'create_archive') {
$res = ObjectHistory::archiveObject($object);
if ($res > 0) setEventMessage($langs->trans('ObjectHistoryVersionSuccessfullArchived'));
@@ -187,9 +177,7 @@ function doActions($parameters, &$object, &$action, $hookmanager)
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id);
exit;
- }
- elseif($action == 'restore_archive')
- {
+ } elseif ($action == 'restore_archive') {
$res = ObjectHistory::restoreObject($object, GETPOST('idVersion'));
if ($res > 0) setEventMessage($langs->trans('ObjectHistoryVersionSuccessfullRestored'));
@@ -197,9 +185,7 @@ function doActions($parameters, &$object, &$action, $hookmanager)
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id);
exit;
- }
- elseif($action == 'confirm_delete_archive')
- {
+ } elseif ($action == 'confirm_delete_archive') {
$version = new ObjectHistory($this->db);
$version->fetch(GETPOST('idVersion'));
@@ -209,17 +195,22 @@ function doActions($parameters, &$object, &$action, $hookmanager)
header('Location: '.$_SERVER['PHP_SELF'].'?id='.GETPOST('id'));
exit;
}
-
-
}
return 0;
}
-
- function formConfirm($parameters, &$object, &$action, $hookmanager)
+ /**
+ * Add confirmation content
+ *
+ * @param array $parameters Hook metadatas (context, etc...)
+ * @param CommonObject $object The object to process
+ * @param string $action Current action
+ * @param HookManager $hookmanager Hook manager
+ * @return int 0
+ */
+ public function formConfirm($parameters, &$object, &$action, $hookmanager)
{
- if ($action == 'objecthistory_modif' || $action == 'view_archive' || $action == 'delete_archive')
- {
+ if ($action == 'objecthistory_modif' || $action == 'view_archive' || $action == 'delete_archive') {
$form = new Form($this->db);
$formConfirm = getFormConfirmObjectHistory($form, $object, $action);
$this->results = array();
@@ -230,32 +221,36 @@ function formConfirm($parameters, &$object, &$action, $hookmanager)
return 0;
}
-
- function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager)
+ /**
+ * Add more actions buttons
+ *
+ * @param array $parameters Hook metadatas (context, etc...)
+ * @param CommonObject $object The object to process
+ * @param string $action Current action
+ * @param HookManager $hookmanager Hook manager
+ * @return int 0
+ */
+ public function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager)
{
global $conf;
- $TContext = explode(':',$parameters['context']);
+ $TContext = explode(':', $parameters['context']);
$interSect = array_intersect($TContext, ObjectHistory::getTHookAllowed());
- if (!empty($interSect) && !empty($object->id))
- {
+ if (!empty($interSect) && !empty($object->id)) {
$TVersion = ObjectHistory::getAllVersionBySourceId($object->id, $object->element);
print getHtmlListObjectHistory($object, $TVersion, $action);
- if(!getDolGlobalString('OBJECTHISTORY_HIDE_VERSION_ON_TABS'))
- {
+ if (!getDolGlobalString('OBJECTHISTORY_HIDE_VERSION_ON_TABS')) {
$idVersion = GETPOST('idVersion', 'int');
- if (!empty($idVersion) && isset($TVersion[$idVersion]))
- {
+ if (!empty($idVersion) && isset($TVersion[$idVersion])) {
$num = array_search($idVersion, array_keys($TVersion)) + 1;
print '';
- }
- else if(! empty($TVersion)) {
+ } elseif (! empty($TVersion)) {
$num = count($TVersion) + 1; // TODO voir pour afficher le bon numéro de version si on est en mode visu
print '