Update note.php
This commit is contained in:
parent
55f8d72219
commit
98362881a6
@ -27,6 +27,7 @@ require '../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||||
|
|
||||||
|
// Get parameters
|
||||||
$id = GETPOST('id', 'int');
|
$id = GETPOST('id', 'int');
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'usernote'; // To manage different context of search
|
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'usernote'; // To manage different context of search
|
||||||
@ -39,16 +40,19 @@ $object->fetch($id, '', '', 1);
|
|||||||
$object->getrights();
|
$object->getrights();
|
||||||
|
|
||||||
// If user is not user read and no permission to read other users, we stop
|
// If user is not user read and no permission to read other users, we stop
|
||||||
if (($object->id != $user->id) && (!$user->hasRight("user", "user", "read"))) {
|
if (($object->id != $user->id) && (!$user->rights->user->user->lire)) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Permissions
|
||||||
|
$permissionnote = $user->hasRight("user", "self", "write"); // Used by the include of actions_setnotes.inc.php
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = 0;
|
$socid = 0;
|
||||||
if ($user->socid > 0) {
|
if ($user->socid > 0) {
|
||||||
$socid = $user->socid;
|
$socid = $user->socid;
|
||||||
}
|
}
|
||||||
$feature2 = (($socid && $user->hasRight("user", "self", "write")) ? '' : 'user');
|
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
|
||||||
|
|
||||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||||
|
|
||||||
@ -59,37 +63,23 @@ $hookmanager->initHooks(array('usercard', 'usernote', 'globalcard'));
|
|||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$parameters = array('id'=>$socid);
|
$parameters = array('id'=>$socid);
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) {
|
if ($reshook < 0) {
|
||||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($reshook)) {
|
if (empty($reshook)) {
|
||||||
if ($action == 'update' && $user->hasRight("user", "user", "write") && !GETPOST("cancel")) {
|
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
$res = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES | ENT_HTML5));
|
|
||||||
if ($res < 0) {
|
|
||||||
$mesg = '<div class="error">'.$adh->error.'</div>';
|
|
||||||
$db->rollback();
|
|
||||||
} else {
|
|
||||||
$db->commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
$form = new Form($db);
|
|
||||||
|
|
||||||
$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
|
llxHeader();
|
||||||
$title = $person_name." - ".$langs->trans('Notes');
|
|
||||||
$help_url = '';
|
$form = new Form($db);
|
||||||
llxHeader('', $title, $help_url);
|
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$head = user_prepare_head($object);
|
$head = user_prepare_head($object);
|
||||||
@ -99,7 +89,7 @@ if ($id) {
|
|||||||
|
|
||||||
$linkback = '';
|
$linkback = '';
|
||||||
|
|
||||||
if ($user->hasRight("user", "user", "read") || $user->admin) {
|
if ($user->rights->user->user->lire || $user->admin) {
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
$linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +97,7 @@ if ($id) {
|
|||||||
$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
|
$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
|
||||||
$morehtmlref .= '</a>';
|
$morehtmlref .= '</a>';
|
||||||
|
|
||||||
dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref);
|
dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref);
|
||||||
|
|
||||||
print '<div class="underbanner clearboth"></div>';
|
print '<div class="underbanner clearboth"></div>';
|
||||||
|
|
||||||
@ -127,7 +117,7 @@ if ($id) {
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
$addadmin = '';
|
$addadmin = '';
|
||||||
if (property_exists($object, 'admin')) {
|
if (property_exists($object, 'admin')) {
|
||||||
if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
|
if (!empty($conf->multicompany->enabled) && !empty($object->admin) && empty($object->entity)) {
|
||||||
$addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
|
$addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
|
||||||
} elseif (!empty($object->admin)) {
|
} elseif (!empty($object->admin)) {
|
||||||
$addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
|
$addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
|
||||||
@ -138,46 +128,20 @@ if ($id) {
|
|||||||
}
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
$editenabled = (($action == 'edit') && $user->hasRight("user", "user", "write"));
|
|
||||||
|
|
||||||
// Note
|
|
||||||
print '<tr><td class="tdtop">'.$langs->trans("Note").'</td>';
|
|
||||||
print '<td class="'.($editenabled ? '' : 'sensiblehtmlcontent').'">';
|
|
||||||
if ($editenabled) {
|
|
||||||
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
|
|
||||||
print "<input type=\"hidden\" name=\"id\" value=\"".$object->id."\">";
|
|
||||||
// Editeur wysiwyg
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
|
||||||
$doleditor = new DolEditor('note_private', $object->note_private, '', 280, 'dolibarr_notes', 'In', true, false, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_8, '90%');
|
|
||||||
$doleditor->Create();
|
|
||||||
} else {
|
|
||||||
print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
|
|
||||||
}
|
|
||||||
print "</td></tr>";
|
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|
||||||
|
//print '<br>';
|
||||||
|
|
||||||
|
//print '<div class="underbanner clearboth"></div>';
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
|
||||||
|
|
||||||
print dol_get_fiche_end();
|
print dol_get_fiche_end();
|
||||||
|
} else {
|
||||||
if ($action == 'edit') {
|
$langs->load("errors");
|
||||||
print $form->buttonsSaveCancel();
|
print $langs->trans("ErrorRecordNotFound");
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Actions
|
|
||||||
*/
|
|
||||||
|
|
||||||
print '<div class="tabsAction">';
|
|
||||||
|
|
||||||
if ($user->hasRight("user", "user", "write") && $action != 'edit') {
|
|
||||||
print '<a class="butAction" href="note.php?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans('Modify')."</a>";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</div>";
|
|
||||||
|
|
||||||
print "</form>\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user