28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/bookmarks/class/bookmark.class.php';
33$langs->loadLangs(array(
'bookmarks',
'other'));
38$action =
GETPOST(
"action",
"alpha");
39$title = (string)
GETPOST(
"title",
"alpha");
40$url = (string)
GETPOST(
"url",
"alpha");
41$urlsource =
GETPOST(
"urlsource",
"alpha");
45$backtopage =
GETPOST(
'backtopage',
'alpha');
57$permissiontoread = $user->hasRight(
'bookmark',
'lire');
58$permissiontoadd = $user->hasRight(
'bookmark',
'creer');
59$permissiontodelete = $user->hasRight(
'bookmark',
'supprimer');
67if (($action ==
'add' || $action ==
'addproduct' || $action ==
'update') && $permissiontoadd) {
68 if ($action ==
'update') {
69 $invertedaction =
'edit';
71 $invertedaction =
'create';
76 if (
GETPOST(
'cancel',
'alpha')) {
77 if (empty($backtopage)) {
78 $backtopage = ($urlsource ? $urlsource : ((!empty($url) && !preg_match(
'/^http/i', $url)) ? $url : DOL_URL_ROOT.
'/bookmarks/list.php'));
80 header(
"Location: ".$backtopage);
84 if ($action ==
'update') {
88 if (!empty($userid)) {
98 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"BookmarkTitle")),
null,
'errors');
103 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"UrlOrLink")),
null,
'errors');
109 if ($action ==
'update') {
116 if (empty($backtopage)) {
117 $backtopage = ($urlsource ? $urlsource : ((!empty($url) && !preg_match(
'/^http/i', $url)) ? $url : DOL_URL_ROOT.
'/bookmarks/list.php'));
119 header(
"Location: ".$backtopage);
122 if (
$object->errno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
123 $langs->load(
"errors");
124 setEventMessages($langs->transnoentities(
"WarningBookmarkAlreadyExists"),
null,
'warnings');
128 $action = $invertedaction;
131 $action = $invertedaction;
141llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-bookmarks page-card');
143$form =
new Form($db);
149$head[$h][0] = $_SERVER[
"PHP_SELF"].($object->id ?
'?id='.$object->id :
'');
150$head[$h][1] = $langs->trans(
"Bookmark");
151$head[$h][2] =
'card';
157if ($action ==
'create') {
162 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" enctype="multipart/form-data">'.
"\n";
163 print
'<input type="hidden" name="token" value="'.newToken().
'">';
164 print
'<input type="hidden" name="action" value="add">';
165 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
171 print
'<table class="border centpercent tableforfieldcreate">';
173 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"BookmarkTitle").
'</td><td><input id="titlebookmark" class="flat minwidth250" name="title" value="'.
dol_escape_htmltag($title).
'"></td><td class="hideonsmartphone"><span class="opacitymedium">'.$langs->trans(
"SetHereATitleForLink").
'</span></td></tr>';
177 print
'<tr><td class="fieldrequired">'.$langs->trans(
"UrlOrLink").
'</td><td><input class="flat quatrevingtpercent minwidth500" name="url" value="'.
dol_escape_htmltag($url).
'"></td><td class="hideonsmartphone"><span class="opacitymedium">'.$langs->trans(
"UseAnExternalHttpLinkOrRelativeDolibarrLink").
'</span></td></tr>';
180 print
'<tr><td>'.$langs->trans(
"BehaviourOnClick").
'</td><td>';
181 $liste = array(0=>$langs->trans(
"ReplaceWindow"), 1=>$langs->trans(
"OpenANewWindow"));
183 if ($url && !preg_match(
'/^http/i', $url)) {
186 print $form->selectarray(
'target', $liste, GETPOSTISSET(
'target') ?
GETPOSTINT(
'target') : $defaulttarget, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth300');
187 print
'</td><td class="hideonsmartphone"><span class="opacitymedium">'.$langs->trans(
"ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").
'</span></td></tr>';
190 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td>';
191 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
192 print $form->select_dolusers(GETPOSTISSET(
'userid') ?
GETPOSTINT(
'userid') : $user->id,
'userid', 0,
'', 0, ($user->admin ?
'' : array($user->id)),
'', 0, 0, 0,
'', ($user->admin) ? 1 : 0,
'',
'maxwidth300 widthcentpercentminusx');
193 print
'</td><td class="hideonsmartphone"></td></tr>';
196 print
'<tr><td>'.$langs->trans(
"Position").
'</td><td>';
197 print
'<input class="flat width50" name="position" value="'.(GETPOSTISSET(
"position") ?
GETPOSTINT(
"position") :
$object->
position).
'">';
198 print
'</td><td class="hideonsmartphone"></td></tr>';
204 print $form->buttonsSaveCancel(
"CreateBookmark");
210if ($id > 0 && !preg_match(
'/^add/i', $action)) {
211 if ($action ==
'edit') {
212 print
'<form name="edit" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'" enctype="multipart/form-data">';
213 print
'<input type="hidden" name="token" value="'.newToken().
'">';
214 print
'<input type="hidden" name="action" value="update">';
215 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
216 print
'<input type="hidden" name="urlsource" value="'.DOL_URL_ROOT.
'/bookmarks/card.php?id='.
$object->id.
'">';
217 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
220 print
dol_get_fiche_head($head, $hselected, $langs->trans(
"Bookmark"), -1,
'bookmark');
222 $linkback =
'<a href="'.DOL_URL_ROOT.
'/bookmarks/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
224 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'ref',
'',
'', 0,
'',
'', 0);
226 print
'<div class="fichecenter">';
228 print
'<div class="underbanner clearboth"></div>';
229 print
'<table class="border centpercent tableforfield">';
232 print
'<tr><td class="titlefield">';
233 if ($action ==
'edit') {
234 print
'<span class="fieldrequired">';
237 print $langs->trans(
"BookmarkTitle");
239 if ($action ==
'edit') {
244 if ($action ==
'edit') {
245 print
'<input class="flat minwidth250" name="title" value="'.(GETPOSTISSET(
"title") ?
GETPOST(
"title",
'', 2) :
$object->title).
'">';
253 if ($action ==
'edit') {
254 print
'<span class="fieldrequired">';
256 print $langs->trans(
"UrlOrLink");
257 if ($action ==
'edit') {
260 print
'</td><td class="wordbreak">';
261 if ($action ==
'edit') {
262 print
'<input class="flat minwidth500 quatrevingtpercent" name="url" value="'.(GETPOSTISSET(
"url") ?
GETPOST(
"url") :
$object->url).
'">';
264 print
'<a href="'.(preg_match(
'/^http/i',
$object->url) ?
$object->url : DOL_URL_ROOT.$object->url).
'"'.(
$object->target ?
' target="_blank" rel="noopener noreferrer"' :
'').
'>';
265 print
img_picto(
'',
'globe',
'class="paddingright"');
271 print
'<tr><td>'.$langs->trans(
"BehaviourOnClick").
'</td><td>';
272 if ($action ==
'edit') {
273 $liste = array(1=>$langs->trans(
"OpenANewWindow"), 0=>$langs->trans(
"ReplaceWindow"));
274 print $form->selectarray(
'target', $liste, GETPOSTISSET(
"target") ?
GETPOST(
"target") :
$object->target);
277 print $langs->trans(
"ReplaceWindow");
280 print $langs->trans(
"OpenANewWindow");
286 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td>';
287 if ($action ==
'edit' && $user->admin) {
288 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
289 print $form->select_dolusers(GETPOSTISSET(
'userid') ?
GETPOSTINT(
'userid') : (
$object->fk_user ?
$object->fk_user :
''),
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300 widthcentpercentminusx');
292 $fuser =
new User($db);
293 $fuser->fetch(
$object->fk_user);
294 print $fuser->getNomUrl(-1);
296 print
'<span class="opacitymedium">'.$langs->trans(
"Everybody").
'</span>';
302 print
'<tr><td>'.$langs->trans(
"Position").
'</td><td>';
303 if ($action ==
'edit') {
304 print
'<input class="flat" name="position" size="5" value="'.(GETPOSTISSET(
"position") ?
GETPOSTINT(
"position") :
$object->
position).
'">';
311 print
'<tr><td>'.$langs->trans(
"DateCreation").
'</td><td>'.
dol_print_date(
$object->datec,
'dayhour').
'</td></tr>';
319 if ($action ==
'edit') {
320 print $form->buttonsSaveCancel();
328 print
"<div class=\"tabsAction\">\n";
331 if ($permissiontoadd && $action !=
'edit') {
332 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Edit").
'</a>'.
"\n";
336 if ($permissiontodelete && $action !=
'edit') {
337 print
'<a class="butActionDelete" href="list.php?id='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
"Delete").
'</a>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bookmarks.
Class to manage Dolibarr users.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.