diff --git a/actions.php b/actions.php index cc5af7de8..5dadf67e6 100644 --- a/actions.php +++ b/actions.php @@ -2,6 +2,8 @@ include_once __DIR__.'/core.php'; +use Models\Note; + if (empty($structure) || empty($structure['enabled'])) { die(tr('Accesso negato')); } @@ -93,6 +95,26 @@ elseif (filter('op') == 'validate') { return; } +// Aggiunta nota interna +elseif (filter('op') == 'add_nota') { + $contenuto = post('contenuto'); + $data_notifica = post('data_notifica') ?: null; + + $nota = Note::build($user, $structure, $id_record, $contenuto, $data_notifica); + + flash()->info(tr('Nota interna aggiunta correttamente!')); +} + +// Aggiunta nota interna +elseif (filter('op') == 'remove_nota') { + $id_nota = post('id_nota'); + $nota = Note::find($id_nota); + + $nota->delete(); + + flash()->info(tr('Nota interna aggiunta correttamente!')); +} + // Invio email elseif (post('op') == 'send-email') { $id_template = post('template'); diff --git a/core.php b/core.php index 19d36896b..c45c938a1 100644 --- a/core.php +++ b/core.php @@ -233,6 +233,7 @@ if (!API\Response::isAPIRequest()) { $id_record = filter('id_record'); $id_parent = filter('id_parent'); + $id_record = $id_record == $id_parent ? '' : $id_record; Modules::setCurrent(filter('id_module')); Plugins::setCurrent(filter('id_plugin')); diff --git a/editor.php b/editor.php index 1cb5c1e91..2450d85e1 100755 --- a/editor.php +++ b/editor.php @@ -4,19 +4,21 @@ include_once __DIR__.'/core.php'; use Carbon\Carbon; -if (empty($id_record) && !empty($id_module)) { +if (empty($id_record) && !empty($id_module) && empty($id_plugin)) { redirect(ROOTDIR.'/controller.php?id_module='.$id_module); -} elseif (empty($id_record) && empty($id_module)) { +} elseif (empty($id_record) && empty($id_module) && empty($id_plugin)) { redirect(ROOTDIR.'/index.php'); } include_once App::filepath('include|custom|', 'top.php'); -Util\Query::setSegments(false); -$query = Util\Query::getQuery($structure, [ - 'id' => $id_record, -]); -Util\Query::setSegments(true); +if (!empty($id_record)) { + Util\Query::setSegments(false); + $query = Util\Query::getQuery($structure, [ + 'id' => $id_record, + ]); + Util\Query::setSegments(true); +} $query = str_replace(['AND `deleted_at` IS NULL', '`deleted_at` IS NULL AND', '`deleted_at` IS NULL', 'AND deleted_at IS NULL', 'deleted_at IS NULL AND', 'deleted_at IS NULL'], '', $query); @@ -90,6 +92,14 @@ if (empty($record) || !$has_access) { '; } + // Tab per le note interne + if ($structure->permission != '-') { + echo ' +
'.tr('Non sono presenti note interne').'
'; + } + + if ($structure->permission == 'rw') { + echo ' + '; + } + + echo ' +