Skip to content

Commit

Permalink
Evarisk#579 [Session] add: make content not visible + editable in cur…
Browse files Browse the repository at this point in the history
…rent view
  • Loading branch information
evarisk-francois committed Jul 30, 2024
1 parent dd5740a commit 19e6641
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 21 deletions.
2 changes: 1 addition & 1 deletion class/session.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Session extends SaturneObject
'label' => ['type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'position' => 70, 'notnull' => 1, 'visible' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'showoncombobox' => 2, 'validate' => 1, 'autofocusoncreate' => 1],
'date_start' => ['type' => 'datetime', 'label' => 'DateStart', 'enabled' => 1, 'position' => 110, 'notnull' => 1, 'visible' => 1],
'date_end' => ['type' => 'datetime', 'label' => 'DateEnd', 'enabled' => 1, 'position' => 120, 'notnull' => 1, 'visible' => 1],
'content' => ['type' => 'html', 'label' => 'Content', 'enabled' => 1, 'position' => 140, 'notnull' => 1, 'visible' => 3, 'validate' => 1],
'content' => ['type' => 'html', 'label' => 'Content', 'enabled' => 1, 'position' => 140, 'notnull' => 1, 'visible' => 0, 'validate' => 1],
'type' => ['type' => 'varchar(128)', 'label' => 'Type', 'enabled' => 1, 'position' => 120, 'notnull' => 1, 'visible' => 0],
'duration' => ['type' => 'duration', 'label' => 'Duration', 'enabled' => 1, 'position' => 130, 'notnull' => 0, 'visible' => 1],
'note_public' => ['type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 150, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => 1],
Expand Down
72 changes: 52 additions & 20 deletions view/session/session_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,17 @@
print '</form>';
}

if ($action == 'set_content' && $user->hasRight("dolimeet", "trainingsession", "write")) {
if (!GETPOST('cancel')) {
$object->content = GETPOST('content', 'restricthtml');
$result = $object->setValueFrom('content', $object->content);

if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
}

// Part to show record.
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
$res = $object->fetch_optionals();
Expand Down Expand Up @@ -458,14 +469,50 @@
unset($object->fields['fk_project']); // Hide field already shown in banner.
unset($object->fields['fk_soc']); // Hide field already shown in banner.
unset($object->fields['fk_contrat']); // Hide field already shown in banner.

$content = $object->fields['content'];
unset($object->fields['content']);


// Common attributes.
require_once DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';

$object->fields['content'] = $content;
if ($user->hasRight("dolimeet", "trainingsession", "write") && $action == 'edit_content') {
print '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<input type="hidden" name="object_type" value="' . $objectType . '">';
print '<input type="hidden" name="action" value="set_content">';
}

print '<tr class="liste_titre trforfield"><td class="nowrap titlefield">';
print $langs->trans("Content");
print '</td><td>';
if ($user->hasRight("dolimeet", "trainingsession", "write")) {
print '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=edit_content&token=' . newToken() . '&id=' . $object->id . '&object_type=' . $objectType . '">' . img_edit($langs->trans('Modify')) . '</a>';
}
print '</td></tr>';

print '<tr>';
print '<td colspan="2">';
if ($user->hasRight("dolimeet", "trainingsession", "write") && $action == 'edit_content') {
$content = GETPOSTISSET('content') ? GETPOST('content', 'restricthtml') : $object->content;
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('content', $content, '', 250, 'dolibarr_notes', 'In', false, true, isModEnabled('fckeditor'), ROWS_5, '90%');
$doleditor->Create();
} else {
print '<div class="longmessagecut">';
print dolPrintHTML($object->content);
print '</div>';
}
if ($user->hasRight("dolimeet", "trainingsession", "write") && $action == 'edit_content') {
print '<div class="center">';
print '<input type="submit" class="button button-edit" value="' . $langs->trans('Modify') . '">';
print '<input type="submit" class="button button-cancel" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>';
}
print '</td>';
print '</tr>';

if ($user->hasRight("dolimeet", "trainingsession", "write") && $action == 'edit_content') {
print '</form>';
}

// Categories
if ($conf->categorie->enabled) {
Expand All @@ -483,21 +530,6 @@

print '<div class="clearboth"></div>';

print '<table class="centpercent notopnoleftnoright table-fiche-title">';
print '<tbody>';
print '<tr class="titre">';
print '<td class="nobordernopadding valignmiddle col-title">';
print '<div class="titre inline-block">' . $langs->trans($content['label']) . '</div>';
print '</td>';
print '</tr>';
print '<tr>';
print '<td>';
print '<div class="longmessagecut">' . $object->content . '</div>';
print '</td>';
print '</tr>';
print '</tbody>';
print '</table>';

print dol_get_fiche_end();

$documentTypeArray = ['trainingsession', 'attendancesheet', 'completioncertificate'];
Expand Down

0 comments on commit 19e6641

Please sign in to comment.