Go to the documentation of this file.
27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/bookmarks/class/bookmark.class.php';
31 $langs->loadLangs(array(
'bookmarks',
'other'));
34 if (empty($user->rights->bookmark->lire)) {
39 $action =
GETPOST(
"action",
"alpha");
40 $title = (string)
GETPOST(
"title",
"alpha");
41 $url = (string)
GETPOST(
"url",
"alpha");
42 $urlsource =
GETPOST(
"urlsource",
"alpha");
43 $target =
GETPOST(
"target",
"int");
44 $userid =
GETPOST(
"userid",
"int");
45 $position =
GETPOST(
"position",
"int");
46 $backtopage =
GETPOST(
'backtopage',
'alpha');
58 if ($action ==
'add' || $action ==
'addproduct' || $action ==
'update') {
59 if ($action ==
'update') {
60 $invertedaction =
'edit';
62 $invertedaction =
'create';
67 if (
GETPOST(
'cancel',
'alpha')) {
68 if (empty($backtopage)) {
69 $backtopage = ($urlsource ? $urlsource : ((!empty($url) && !preg_match(
'/^http/i', $url)) ? $url : DOL_URL_ROOT.
'/bookmarks/list.php'));
71 header(
"Location: ".$backtopage);
75 if ($action ==
'update') {
76 $object->fetch(
GETPOST(
"id",
'int'));
79 if (!empty($userid)) {
80 $object->fk_user = $userid;
82 $object->title = $title;
84 $object->target = $target;
85 $object->position = $position;
89 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"BookmarkTitle")),
null,
'errors');
94 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"UrlOrLink")),
null,
'errors');
98 $object->favicon =
'none';
100 if ($action ==
'update') {
101 $res = $object->update();
103 $res = $object->create();
107 if (empty($backtopage)) {
108 $backtopage = ($urlsource ? $urlsource : ((!empty($url) && !preg_match(
'/^http/i', $url)) ? $url : DOL_URL_ROOT.
'/bookmarks/list.php'));
110 header(
"Location: ".$backtopage);
113 if ($object->errno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
114 $langs->load(
"errors");
115 setEventMessages($langs->transnoentities(
"WarningBookmarkAlreadyExists"),
null,
'warnings');
119 $action = $invertedaction;
122 $action = $invertedaction;
139 $head[$h][0] = $_SERVER[
"PHP_SELF"].($object->id ?
'?id='.$object->id :
'');
140 $head[$h][1] = $langs->trans(
"Bookmark");
141 $head[$h][2] =
'card';
147 if ($action ==
'create') {
152 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" enctype="multipart/form-data">'.
"\n";
153 print
'<input type="hidden" name="token" value="'.newToken().
'">';
154 print
'<input type="hidden" name="action" value="add">';
155 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
161 print
'<table class="border centpercent tableforfieldcreate">';
163 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>';
167 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>';
170 print
'<tr><td>'.$langs->trans(
"BehaviourOnClick").
'</td><td>';
171 $liste = array(0=>$langs->trans(
"ReplaceWindow"), 1=>$langs->trans(
"OpenANewWindow"));
173 if ($url && !preg_match(
'/^http/i', $url)) {
176 print
$form->selectarray(
'target', $liste,
GETPOSTISSET(
'target') ?
GETPOST(
'target',
'int') : $defaulttarget, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth300');
177 print
'</td><td class="hideonsmartphone"><span class="opacitymedium">'.$langs->trans(
"ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").
'</span></td></tr>';
180 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td>';
181 print
img_picto(
'',
'user').
' '.
$form->select_dolusers(
GETPOSTISSET(
'userid') ?
GETPOST(
'userid',
'int') : $user->id,
'userid', 0,
'', 0, ($user->admin ?
'' : array($user->id)),
'', 0, 0, 0,
'', ($user->admin) ? 1 : 0,
'',
'maxwidth300 widthcentpercentminusx');
182 print
'</td><td class="hideonsmartphone"></td></tr>';
185 print
'<tr><td>'.$langs->trans(
"Position").
'</td><td>';
186 print
'<input class="flat width50" name="position" value="'.(GETPOSTISSET(
"position") ?
GETPOST(
"position",
'int') : $object->position).
'">';
187 print
'</td><td class="hideonsmartphone"></td></tr>';
193 print
$form->buttonsSaveCancel(
"CreateBookmark");
199 if ($id > 0 && !preg_match(
'/^add/i', $action)) {
200 if ($action ==
'edit') {
201 print
'<form name="edit" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'" enctype="multipart/form-data">';
202 print
'<input type="hidden" name="token" value="'.newToken().
'">';
203 print
'<input type="hidden" name="action" value="update">';
204 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
205 print
'<input type="hidden" name="urlsource" value="'.DOL_URL_ROOT.
'/bookmarks/card.php?id='.$object->id.
'">';
206 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
209 print
dol_get_fiche_head($head, $hselected, $langs->trans(
"Bookmark"), -1,
'bookmark');
211 $linkback =
'<a href="'.DOL_URL_ROOT.
'/bookmarks/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
213 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref',
'',
'', 0,
'',
'', 0);
215 print
'<div class="fichecenter">';
217 print
'<div class="underbanner clearboth"></div>';
218 print
'<table class="border centpercent tableforfield">';
220 print
'<tr><td class="titlefield">';
221 if ($action ==
'edit') {
222 print
'<span class="fieldrequired">';
225 print $langs->trans(
"BookmarkTitle");
227 if ($action ==
'edit') {
232 if ($action ==
'edit') {
233 print
'<input class="flat minwidth250" name="title" value="'.(GETPOSTISSET(
"title") ?
GETPOST(
"title",
'', 2) : $object->title).
'">';
240 if ($action ==
'edit') {
241 print
'<span class="fieldrequired">';
243 print $langs->trans(
"UrlOrLink");
244 if ($action ==
'edit') {
248 if ($action ==
'edit') {
249 print
'<input class="flat minwidth500 quatrevingtpercent" name="url" value="'.(GETPOSTISSET(
"url") ?
GETPOST(
"url") : $object->url).
'">';
251 print
'<a href="'.(preg_match(
'/^http/i', $object->url) ? $object->url : DOL_URL_ROOT.$object->url).
'"'.($object->target ?
' target="_blank" rel="noopener noreferrer"' :
'').
'>';
252 print
img_picto(
'',
'globe',
'class="paddingright"');
258 print
'<tr><td>'.$langs->trans(
"BehaviourOnClick").
'</td><td>';
259 if ($action ==
'edit') {
260 $liste = array(1=>$langs->trans(
"OpenANewWindow"), 0=>$langs->trans(
"ReplaceWindow"));
263 if ($object->target == 0) {
264 print $langs->trans(
"ReplaceWindow");
266 if ($object->target == 1) {
267 print $langs->trans(
"OpenANewWindow");
272 print
'<tr><td>'.$langs->trans(
"Visibility").
'</td><td>';
273 if ($action ==
'edit' && $user->admin) {
274 print
img_picto(
'',
'user').
' '.
$form->select_dolusers(
GETPOSTISSET(
'userid') ?
GETPOST(
'userid',
'int') : ($object->fk_user ? $object->fk_user :
''),
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
276 if ($object->fk_user > 0) {
277 $fuser =
new User($db);
278 $fuser->fetch($object->fk_user);
279 print $fuser->getNomUrl(1);
281 print
'<span class="opacitymedium">'.$langs->trans(
"Everybody").
'</span>';
287 print
'<tr><td>'.$langs->trans(
"Position").
'</td><td>';
288 if ($action ==
'edit') {
289 print
'<input class="flat" name="position" size="5" value="'.(GETPOSTISSET(
"position") ?
GETPOST(
"position",
'int') : $object->position).
'">';
291 print $object->position;
296 print
'<tr><td>'.$langs->trans(
"DateCreation").
'</td><td>'.
dol_print_date($object->datec,
'dayhour').
'</td></tr>';
304 if ($action ==
'edit') {
305 print
$form->buttonsSaveCancel();
313 print
"<div class=\"tabsAction\">\n";
316 if ($user->rights->bookmark->creer && $action !=
'edit') {
317 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Edit").
'</a>'.
"\n";
321 if ($user->rights->bookmark->supprimer && $action !=
'edit') {
322 print
'<a class="butActionDelete" href="list.php?bid='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
"Delete").
'</a>'.
"\n";
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
restrictedArea($user, $features, $objectid=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.
Class to manage bookmarks.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage Dolibarr users.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.