26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/bookmarks/class/bookmark.class.php';
30$langs->loadLangs(array(
'bookmarks',
'admin'));
33$action =
GETPOST(
'action',
'aZ09');
34$massaction =
GETPOST(
'massaction',
'alpha');
36$confirm =
GETPOST(
'confirm',
'alpha');
37$cancel =
GETPOST(
'cancel',
'alpha');
38$toselect =
GETPOST(
'toselect',
'array');
39$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'bookmarklist';
40$backtopage =
GETPOST(
'backtopage',
'alpha');
41$optioncss =
GETPOST(
'optioncss',
'alpha');
45$search_title =
GETPOST(
'search_title',
'alpha');
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
56$offset = $limit * $page;
60 $sortfield =
'b.position';
69$arrayfields = array();
70$hookmanager->initHooks(array(
'bookmarklist'));
83$permissiontoread = $user->hasRight(
'bookmark',
'lire');
84$permissiontoadd = $user->hasRight(
'bookmark',
'creer');
85$permissiontodelete = ($user->hasRight(
'bookmark',
'supprimer') || ($permissiontoadd &&
$object->fk_user == $user->id));
92if (
GETPOST(
'cancel',
'alpha')) {
96if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
100$parameters = array();
101$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
106if (empty($reshook)) {
108 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
110 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
111 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
116 $objectclass =
'Bookmark';
117 $objectlabel =
'Bookmark';
118 $uploaddir = $conf->bookmark->dir_output;
119 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
121 if ($action ==
'delete' && $permissiontodelete) {
125 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
139$form =
new Form($db);
145$title = $langs->trans(
"Bookmarks");
152$sql =
"SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,";
153$sql .=
" u.login, u.lastname, u.firstname";
155if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
156 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
157 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
161$parameters = array();
162$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
163$sql .= $hookmanager->resPrint;
164$sql = preg_replace(
'/,\s*$/',
'', $sql);
168$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as b LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON b.fk_user=u.rowid";
173$sql .=
" AND b.entity IN (".getEntity(
'bookmark').
")";
175 $sql .=
" AND (b.fk_user = ".((int) $user->id).
" OR b.fk_user is NULL OR b.fk_user = 0)";
179$nbtotalofrecords =
'';
182 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
183 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
184 $resql = $db->query($sqlforcount);
186 $objforcount = $db->fetch_object($resql);
187 $nbtotalofrecords = $objforcount->nbtotalofrecords;
192 if (($page * $limit) > $nbtotalofrecords) {
200$sql .= $db->order($sortfield.
", position", $sortorder);
202 $sql .= $db->plimit($limit + 1, $offset);
205$resql = $db->query($sql);
211$num = $db->num_rows($resql);
217llxHeader(
'', $title,
'',
'', 0, 0,
'',
'',
'',
'bodyforlist mod-bookmarks page-list');
219$arrayofselected = is_array($toselect) ? $toselect : array();
223 $param .=
'&mode='.urlencode($mode);
225if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
226 $param .=
'&contextpage='.urlencode($contextpage);
228if ($limit > 0 && $limit != $conf->liste_limit) {
229 $param .=
'&limit='.((int) $limit);
231if ($optioncss !=
'') {
232 $param .=
'&optioncss='.urlencode($optioncss);
235include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
237$parameters = array(
'param' => &$param);
238$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
239$param .= $hookmanager->resPrint;
242$arrayofmassactions = array(
248if (!empty($permissiontodelete)) {
249 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
251if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
252 $arrayofmassactions = array();
254$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
256print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
257if ($optioncss !=
'') {
258 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
260print
'<input type="hidden" name="token" value="'.newToken().
'">';
261print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
262print
'<input type="hidden" name="action" value="list">';
263print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
264print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
265print
'<input type="hidden" name="page" value="'.$page.
'">';
266print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
267print
'<input type="hidden" name="page_y" value="">';
268print
'<input type="hidden" name="mode" value="'.$mode.
'">';
272$newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/bookmarks/card.php?action=create&backtopage='.urlencode(DOL_URL_ROOT.
'/bookmarks/list.php'),
'', $permissiontoadd);
274print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bookmark', 0, $newcardbutton,
'', $limit, 0, 0, 1);
277$topicmail =
"SendBookmarkRef";
278$modelmail =
"bookmark";
280$trackid =
'bookmark'.$object->id;
281include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
285$parameters = array();
286$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
287if (empty($reshook)) {
288 $moreforfilter .= $hookmanager->resPrint;
290 $moreforfilter = $hookmanager->resPrint;
293if (!empty($moreforfilter)) {
294 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
295 print $moreforfilter;
299$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
300$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
301$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
303print
'<div class="div-table-responsive">';
304print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
310$totalarray = array();
311$totalarray[
'nbfield'] = 0;
315print
'<tr class="liste_titre">';
317 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
318 $totalarray[
'nbfield']++;
321$totalarray[
'nbfield']++;
323$totalarray[
'nbfield']++;
325$totalarray[
'nbfield']++;
326print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"b.target",
"", $param,
'', $sortfield, $sortorder,
'center ');
327$totalarray[
'nbfield']++;
328print_liste_field_titre(
"Visibility", $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
'', $sortfield, $sortorder,
'center ');
329$totalarray[
'nbfield']++;
330print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"b.dateb",
"", $param,
'', $sortfield, $sortorder,
'center ');
331$totalarray[
'nbfield']++;
332print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
"b.position",
"", $param,
'', $sortfield, $sortorder,
'right ');
333$totalarray[
'nbfield']++;
335 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
336 $totalarray[
'nbfield']++;
343$savnbfield = $totalarray[
'nbfield'];
344$totalarray = array();
345$totalarray[
'nbfield'] = 0;
346$imaxinloop = ($limit ? min($num, $limit) : $num);
347while ($i < $imaxinloop) {
348 $obj = $db->fetch_object($resql);
356 if ($mode ==
'kanban') {
358 print
'<tr><td colspan="'.$savnbfield.
'">';
359 print
'<div class="box-flex-container">';
363 if ($massactionbutton || $massaction) {
365 if (in_array(
$object->id, $arrayofselected)) {
369 print
$object->getKanbanView(
'', array(
'selected' => $selected));
370 if ($i == ($imaxinloop - 1)) {
377 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
380 print
'<td class="nowrap center">';
381 if ($massactionbutton || $massaction) {
383 if (in_array(
$object->id, $arrayofselected)) {
386 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
390 $totalarray[
'nbfield']++;
395 print
'<td class="nowraponall">';
400 if (preg_match(
'/^http/i', $obj->url)) {
403 $title = $obj->title;
405 $canedit = $permissiontoadd;
406 $candelete = $permissiontodelete;
409 print
'<td class="tdoverflowmax200" alt="'.dol_escape_htmltag($title).
'">';
414 print
'<td class="tdoverflowmax200">';
415 if (empty($linkintern)) {
416 print
img_picto(
'',
'url',
'class="pictofixedwidth"');
417 print
'<a class="" href="'.$obj->url.
'"'.($obj->target ?
' target="newlink" rel="noopener"' :
'').
'>';
420 print
'<a class="" href="'.$obj->url.
'">';
427 print
'<td class="tdoverflowmax100 center">';
428 if ($obj->target == 0) {
429 print $langs->trans(
"BookmarkTargetReplaceWindowShort");
431 if ($obj->target == 1) {
432 print $langs->trans(
"BookmarkTargetNewWindowShort");
437 print
'<td class="tdoverflowmax100 center">';
438 if ($obj->fk_user > 0) {
439 if (empty($conf->cache[
'users'][$obj->fk_user])) {
440 $tmpuser =
new User($db);
441 $tmpuser->fetch($obj->fk_user);
442 $conf->cache[
'users'][$obj->fk_user] = $tmpuser;
444 $tmpuser = $conf->cache[
'users'][$obj->fk_user];
445 print $tmpuser->getNomUrl(-1);
447 print
'<span class="opacitymedium">'.$langs->trans(
"Everybody").
'</span>';
456 print
'<td class="center" title="'.dol_escape_htmltag(
dol_print_date($db->jdate($obj->dateb),
'dayhour')).
'">'.
dol_print_date($db->jdate($obj->dateb),
'day').
"</td>";
459 print
'<td class="right">'.$obj->position.
"</td>";
463 print
'<td class="nowrap center">';
464 if ($massactionbutton || $massaction) {
466 if (in_array(
$object->id, $arrayofselected)) {
469 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
473 $totalarray[
'nbfield']++;
484include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
489 foreach ($arrayfields as $key => $val) {
490 if (!empty($val[
'checked'])) {
494 print
'<tr><td colspan="'.$savnbfield.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
499$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
500$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
501print $hookmanager->resPrint;
503print
'</table>'.
"\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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bookmarks.
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.