25require
'../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.
'/bookmarks/class/bookmark.class.php';
29$langs->loadLangs(array(
'bookmarks',
'admin'));
32$action =
GETPOST(
'action',
'aZ09');
33$massaction =
GETPOST(
'massaction',
'alpha');
34$show_files =
GETPOST(
'show_files',
'int');
35$confirm =
GETPOST(
'confirm',
'alpha');
36$cancel =
GETPOST(
'cancel',
'alpha');
37$toselect =
GETPOST(
'toselect',
'array');
38$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'bookmarklist';
39$backtopage =
GETPOST(
'backtopage',
'alpha');
40$optioncss =
GETPOST(
'optioncss',
'alpha');
44$search_title =
GETPOST(
'search_title',
'alpha');
47$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
48$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
49$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
50$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
51if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
55$offset = $limit * $page;
59 $sortfield =
'b.position';
68$arrayfields = array();
69$hookmanager->initHooks(array(
'bookmarklist'));
82$permissiontoread = $user->hasRight(
'bookmark',
'lire');
83$permissiontoadd = $user->hasRight(
'bookmark',
'creer');
84$permissiontodelete = ($user->hasRight(
'bookmark',
'supprimer') || ($permissiontoadd && $object->fk_user == $user->id));
91if (
GETPOST(
'cancel',
'alpha')) {
95if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
100$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
105if (empty($reshook)) {
107 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
109 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
110 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
115 $objectclass =
'Bookmark';
116 $objectlabel =
'Bookmark';
117 $uploaddir = $conf->bookmark->dir_output;
118 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
120 if ($action ==
'delete' && $permissiontodelete) {
122 $res = $object->delete($user);
124 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
138$form =
new Form($db);
144$title = $langs->trans(
"Bookmarks");
151$sql =
"SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,";
152$sql .=
" u.login, u.lastname, u.firstname";
154if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
155 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
156 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
160$parameters = array();
161$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
162$sql .= $hookmanager->resPrint;
163$sql = preg_replace(
'/,\s*$/',
'', $sql);
167$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as b LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON b.fk_user=u.rowid";
172$sql .=
" AND b.entity IN (".getEntity(
'bookmark').
")";
174 $sql .=
" AND (b.fk_user = ".((int) $user->id).
" OR b.fk_user is NULL OR b.fk_user = 0)";
178$nbtotalofrecords =
'';
181 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
182 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
183 $resql = $db->query($sqlforcount);
185 $objforcount = $db->fetch_object($resql);
186 $nbtotalofrecords = $objforcount->nbtotalofrecords;
191 if (($page * $limit) > $nbtotalofrecords) {
199$sql .= $db->order($sortfield.
", position", $sortorder);
201 $sql .= $db->plimit($limit + 1, $offset);
204$resql = $db->query($sql);
210$num = $db->num_rows($resql);
218$arrayofselected = is_array($toselect) ? $toselect : array();
222 $param .=
'&mode='.urlencode($mode);
224if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
225 $param .=
'&contextpage='.urlencode($contextpage);
227if ($limit > 0 && $limit != $conf->liste_limit) {
228 $param .=
'&limit='.((int) $limit);
230if ($optioncss !=
'') {
231 $param .=
'&optioncss='.urlencode($optioncss);
234include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
236$parameters = array();
237$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
238$param .= $hookmanager->resPrint;
241$arrayofmassactions = array(
247if (!empty($permissiontodelete)) {
248 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
250if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
251 $arrayofmassactions = array();
253$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
255print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
256if ($optioncss !=
'') {
257 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
259print
'<input type="hidden" name="token" value="'.newToken().
'">';
260print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
261print
'<input type="hidden" name="action" value="list">';
262print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
263print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
264print
'<input type="hidden" name="page" value="'.$page.
'">';
265print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
266print
'<input type="hidden" name="page_y" value="">';
267print
'<input type="hidden" name="mode" value="'.$mode.
'">';
271$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);
273print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bookmark', 0, $newcardbutton,
'', $limit, 0, 0, 1);
276$topicmail =
"SendBookmarkRef";
277$modelmail =
"bookmark";
279$trackid =
'bookmark'.$object->id;
280include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
284$parameters = array();
285$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object);
286if (empty($reshook)) {
287 $moreforfilter .= $hookmanager->resPrint;
289 $moreforfilter = $hookmanager->resPrint;
292if (!empty($moreforfilter)) {
293 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
294 print $moreforfilter;
298$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
299$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
300$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
302print
'<div class="div-table-responsive">';
303print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
309$totalarray = array();
310$totalarray[
'nbfield'] = 0;
314print
'<tr class="liste_titre">';
316 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
317 $totalarray[
'nbfield']++;
320$totalarray[
'nbfield']++;
322$totalarray[
'nbfield']++;
324$totalarray[
'nbfield']++;
325print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"b.target",
"", $param,
'', $sortfield, $sortorder,
'center ');
326$totalarray[
'nbfield']++;
327print_liste_field_titre(
"Visibility", $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
'', $sortfield, $sortorder,
'center ');
328$totalarray[
'nbfield']++;
329print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"b.dateb",
"", $param,
'', $sortfield, $sortorder,
'center ');
330$totalarray[
'nbfield']++;
331print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
"b.position",
"", $param,
'', $sortfield, $sortorder,
'right ');
332$totalarray[
'nbfield']++;
334 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
335 $totalarray[
'nbfield']++;
342$savnbfield = $totalarray[
'nbfield'];
343$totalarray = array();
344$totalarray[
'nbfield'] = 0;
345$imaxinloop = ($limit ? min($num, $limit) : $num);
346while ($i < $imaxinloop) {
347 $obj = $db->fetch_object($resql);
352 $object->id = $obj->rowid;
353 $object->ref = $obj->rowid;
355 if ($mode ==
'kanban') {
357 print
'<tr><td colspan="'.$savnbfield.
'">';
358 print
'<div class="box-flex-container">';
361 print $object->getKanbanView(
'', array(
'selected' => in_array($object->id, $arrayofselected)));
362 if ($i == ($imaxinloop - 1)) {
369 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
372 print
'<td class="nowrap center">';
373 if ($massactionbutton || $massaction) {
375 if (in_array($object->id, $arrayofselected)) {
378 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
382 $totalarray[
'nbfield']++;
387 print
'<td class="nowraponall">';
388 print $object->getNomUrl(1);
392 if (preg_match(
'/^http/i', $obj->url)) {
395 $title = $obj->title;
397 $canedit = $permissiontoadd;
398 $candelete = $permissiontodelete;
401 print
'<td class="tdoverflowmax200" alt="'.dol_escape_htmltag($title).
'">';
406 print
'<td class="tdoverflowmax200">';
407 if (empty($linkintern)) {
408 print
img_picto(
'',
'url',
'class="pictofixedwidth"');
409 print
'<a class="" href="'.$obj->url.
'"'.($obj->target ?
' target="newlink" rel="noopener"' :
'').
'>';
412 print
'<a class="" href="'.$obj->url.
'">';
419 print
'<td class="tdoverflowmax100 center">';
420 if ($obj->target == 0) {
421 print $langs->trans(
"BookmarkTargetReplaceWindowShort");
423 if ($obj->target == 1) {
424 print $langs->trans(
"BookmarkTargetNewWindowShort");
429 print
'<td class="tdoverflowmax100 center">';
430 if ($obj->fk_user > 0) {
431 if (empty($conf->cache[
'users'][$obj->fk_user])) {
432 $tmpuser =
new User($db);
433 $tmpuser->fetch($obj->fk_user);
434 $conf->cache[
'users'][$obj->fk_user] = $tmpuser;
436 $tmpuser = $conf->cache[
'users'][$obj->fk_user];
437 print $tmpuser->getNomUrl(-1);
439 print
'<span class="opacitymedium">'.$langs->trans(
"Everybody").
'</span>';
448 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>";
451 print
'<td class="right">'.$obj->position.
"</td>";
455 print
'<td class="nowrap center">';
456 if ($massactionbutton || $massaction) {
458 if (in_array($object->id, $arrayofselected)) {
461 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
465 $totalarray[
'nbfield']++;
476include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
481 foreach ($arrayfields as $key => $val) {
482 if (!empty($val[
'checked'])) {
486 print
'<tr><td colspan="'.$savnbfield.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
491$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
492$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
493print $hookmanager->resPrint;
495print
'</table>'.
"\n";
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return 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.