From f242cf4cc1357ddf4bd6b99edb5a747f18df017a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Nov 2019 19:15:32 +0100 Subject: [PATCH] Debug modulebuilder --- .../template/myobject_agenda.php | 4 ++- .../modulebuilder/template/myobject_card.php | 30 +++++++++---------- .../template/myobject_document.php | 6 ++-- .../modulebuilder/template/myobject_note.php | 6 ++-- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index c452d908538..f75e7d352f1 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -93,6 +93,8 @@ if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$ob //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $object->id); +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php + /* * Actions @@ -156,7 +158,7 @@ if ($object->id > 0) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->mymodule->creer) + if ($permissiontoadd) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index ec70df73583..111e190bcf3 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -105,11 +105,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -$permissionnote = $user->rights->mymodule->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->mymodule->write; // Used by the include of actions_dellink.inc.php -$permissionedit = $user->rights->mymodule->write; // Used by the include of actions_lineupdown.inc.php -$permissiontoadd = $user->rights->mymodule->write; // Used by the include of actions_addupdatedelete.inc.php -$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); +$permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->mymodule->myobject->write; // Used by the include of actions_dellink.inc.php +$permissionedit = $user->rights->mymodule->myobject->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontodelete = $user->rights->mymodule->myobject->delete || ($permissiontoadd && $object->status == 0); @@ -319,8 +319,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref='
'; /* // Ref bis - $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->myobject->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->myobject->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project @@ -328,7 +328,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->mymodule->write) + if ($permissiontoadd) { if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; @@ -451,13 +451,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '' . $langs->trans('SendMail') . ''."\n"; // Back to draft - if (! empty($user->rights->mymodule->write) && $object->status == BOM::STATUS_VALIDATED) + if (! empty($user->rights->mymodule->myobject->write) && $object->status == BOM::STATUS_VALIDATED) { print '' . $langs->trans("SetToDraft") . ''; } // Modify - if (! empty($user->rights->mymodule->write)) + if (! empty($user->rights->mymodule->myobject->write)) { print ''.$langs->trans("Modify").''."\n"; } @@ -467,13 +467,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Clone - if (! empty($user->rights->mymodule->write)) + if (! empty($user->rights->mymodule->myobject->write)) { print '' . $langs->trans("ToClone") . ''."\n"; } /* - if ($user->rights->mymodule->write) + if ($user->rights->mymodule->myobject->write) { if ($object->status == 1) { @@ -487,7 +487,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea */ // Delete (need delete permission, or if draft, just need create/modify permission) - if (! empty($user->rights->mymodule->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mymodule->write))) + if (! empty($user->rights->mymodule->myobject->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mymodule->myobject->write))) { print ''.$langs->trans('Delete').''."\n"; } @@ -515,8 +515,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref . '/' . $objref . '.pdf'; $filedir = $conf->mymodule->dir_output . '/' . $objref; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->mymodule->create; // If you can create/edit, you can remove a file on card + $genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->mymodule->myobject->create; // If you can create/edit, you can remove a file on card print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); */ diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index f4b918692ca..9d0954d277e 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -84,6 +84,8 @@ if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$ob //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $object->id); +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php + /* @@ -146,9 +148,9 @@ if ($object->id) dol_fiche_end(); $modulepart = 'mymodule'; - //$permission = $user->rights->mymodule->create; + //$permission = $user->rights->mymodule->myobject->write; $permission = 1; - //$permtoedit = $user->rights->mymodule->create; + //$permtoedit = $user->rights->mymodule->myobject->write; $permtoedit = 1; $param = '&id=' . $object->id; diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index 7cf5f418ff1..89a8ed5513b 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -67,8 +67,8 @@ $extrafields->fetch_name_optionals_label($object->table_element); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id; -$permissionnote=1; -//$permissionnote=$user->rights->mymodule->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote=$user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php @@ -113,7 +113,7 @@ if ($id > 0 || ! empty($ref)) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->mymodule->creer) + if ($permissiontoadd) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';