27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/bookmarks/class/bookmark.class.php';
39$langs->loadLangs(array(
'other',
'admin'));
42$action =
GETPOST(
'action',
'aZ09');
43$massaction =
GETPOST(
'massaction',
'alpha');
45$confirm =
GETPOST(
'confirm',
'alpha');
46$cancel =
GETPOST(
'cancel',
'alpha');
47$toselect =
GETPOST(
'toselect',
'array:int');
48$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'bookmarklist';
49$backtopage =
GETPOST(
'backtopage',
'alpha');
50$optioncss =
GETPOST(
'optioncss',
'alpha');
54$search_title =
GETPOST(
'search_title',
'alpha');
58$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
65$offset = $limit * $page;
69 $sortfield =
'b.position';
78$arrayfields = array();
79$hookmanager->initHooks(array(
'bookmarklist'));
92$permissiontoread = $user->hasRight(
'bookmark',
'lire');
93$permissiontoadd = $user->hasRight(
'bookmark',
'creer');
94$permissiontodelete = ($user->hasRight(
'bookmark',
'supprimer') || ($permissiontoadd &&
$object->fk_user == $user->id));
101if (
GETPOST(
'cancel',
'alpha')) {
105if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
109$parameters = array();
110$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
115if (empty($reshook)) {
117 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
119 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
120 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
126 if (!$user->hasRight(
'bookmark',
'supprimer') && is_array($toselect) && count($toselect) > 0) {
127 $ownbookmarks = array();
128 $sqlown =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"bookmark";
129 $sqlown .=
" WHERE rowid IN (".$db->sanitize(implode(
',', array_map(
'intval', $toselect))).
")";
130 $sqlown .=
" AND fk_user = ".((int) $user->id);
131 $sqlown .=
" AND entity IN (".getEntity(
'bookmark').
")";
132 $resqlown = $db->query($sqlown);
134 while ($objown = $db->fetch_object($resqlown)) {
135 $ownbookmarks[] = (int) $objown->rowid;
138 $toselect = $ownbookmarks;
142 $objectclass =
'Bookmark';
143 $objectlabel =
'Bookmark';
144 $uploaddir = $conf->bookmark->dir_output;
145 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
147 if ($action ==
'delete' && $permissiontodelete) {
151 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
165$form =
new Form($db);
171$title = $langs->trans(
"Bookmarks");
178$sql =
"SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,";
179$sql .=
" u.login, u.lastname, u.firstname";
181if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
182 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
183 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
187$parameters = array();
188$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
189$sql .= $hookmanager->resPrint;
190$sql = preg_replace(
'/,\s*$/',
'', $sql);
194$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as b LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON b.fk_user=u.rowid";
199$sql .=
" AND b.entity IN (".getEntity(
'bookmark').
")";
201 $sql .=
" AND (b.fk_user = ".((int) $user->id).
" OR b.fk_user is NULL OR b.fk_user = 0)";
205$nbtotalofrecords =
'';
208 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
209 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
210 $resql = $db->query($sqlforcount);
212 $objforcount = $db->fetch_object($resql);
213 $nbtotalofrecords = $objforcount->nbtotalofrecords;
218 if (($page * $limit) > (
int) $nbtotalofrecords) {
226$sql .= $db->order($sortfield.
", position", $sortorder);
228 $sql .= $db->plimit($limit + 1, $offset);
231$resql = $db->query($sql);
237$num = $db->num_rows($resql);
243llxHeader(
'', $title,
'',
'', 0, 0,
'',
'',
'',
'bodyforlist mod-bookmarks page-list');
245$arrayofselected = is_array($toselect) ? $toselect : array();
249 $param .=
'&mode='.urlencode($mode);
251if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
252 $param .=
'&contextpage='.urlencode($contextpage);
254if ($limit > 0 && $limit != $conf->liste_limit) {
255 $param .=
'&limit='.((int) $limit);
257if ($optioncss !=
'') {
258 $param .=
'&optioncss='.urlencode($optioncss);
261include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
263$parameters = array(
'param' => &$param);
264$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
265$param .= $hookmanager->resPrint;
268$arrayofmassactions = array(
274if (!empty($permissiontodelete)) {
275 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
277if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
278 $arrayofmassactions = array();
280$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
282print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
283if ($optioncss !=
'') {
284 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
286print
'<input type="hidden" name="token" value="'.newToken().
'">';
287print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
288print
'<input type="hidden" name="action" value="list">';
289print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
290print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
291print
'<input type="hidden" name="page" value="'.$page.
'">';
292print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
293print
'<input type="hidden" name="page_y" value="">';
294print
'<input type="hidden" name="mode" value="'.$mode.
'">';
298$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);
300print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bookmark', 0, $newcardbutton,
'', $limit, 0, 0, 1);
303$topicmail =
"SendBookmarkRef";
304$modelmail =
"bookmark";
306$trackid =
'bookmark'.$object->id;
307include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
311$parameters = array();
312$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
313if (empty($reshook)) {
314 $moreforfilter .= $hookmanager->resPrint;
316 $moreforfilter = $hookmanager->resPrint;
319if (!empty($moreforfilter)) {
320 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
321 print $moreforfilter;
325$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
326$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
327$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
329print
'<div class="div-table-responsive">';
330print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
341print
'<tr class="liste_titre">';
343 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
352print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"b.target",
"", $param,
'', $sortfield, $sortorder,
'center ');
354print_liste_field_titre(
"Visibility", $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
'', $sortfield, $sortorder,
'center ');
356print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"b.dateb",
"", $param,
'', $sortfield, $sortorder,
'center ');
358print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
"b.position",
"", $param,
'', $sortfield, $sortorder,
'right ');
361 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
372$imaxinloop = ($limit ? min($num, $limit) : $num);
373while ($i < $imaxinloop) {
374 $obj = $db->fetch_object($resql);
382 if ($mode ==
'kanban') {
384 print
'<tr><td colspan="'.$savnbfield.
'">';
385 print
'<div class="box-flex-container">';
389 if ($massactionbutton || $massaction) {
391 if (in_array(
$object->id, $arrayofselected)) {
395 print
$object->getKanbanView(
'', array(
'selected' => $selected));
396 if ($i == ($imaxinloop - 1)) {
403 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
406 print
'<td class="nowrap center">';
407 if ($massactionbutton || $massaction) {
409 if (in_array(
$object->id, $arrayofselected)) {
412 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
421 print
'<td class="nowraponall">';
426 if (preg_match(
'/^http/i', $obj->url)) {
429 $title = $obj->title;
431 $canedit = $permissiontoadd;
432 $candelete = $permissiontodelete;
435 print
'<td class="tdoverflowmax250" alt="'.dol_escape_htmltag($title).
'">';
440 print
'<td class="tdoverflowmax250">';
441 if (empty($linkintern)) {
442 print
img_picto(
'',
'url',
'class="pictofixedwidth"');
443 print
'<a class="" href="'.$obj->url.
'"'.($obj->target ?
' target="newlink" rel="noopener"' :
'').
'>';
445 print
'<a class="" href="'.$obj->url.
'">';
452 print
'<td class="tdoverflowmax125 center">';
453 if ($obj->target == 0) {
454 print $langs->trans(
"BookmarkTargetReplaceWindowShort");
456 if ($obj->target == 1) {
457 print $langs->trans(
"BookmarkTargetNewWindowShort");
462 print
'<td class="tdoverflowmax125 center">';
463 if ($obj->fk_user > 0) {
464 if (empty($conf->cache[
'users'][$obj->fk_user])) {
465 $tmpuser =
new User($db);
466 $tmpuser->fetch($obj->fk_user);
467 $conf->cache[
'users'][$obj->fk_user] = $tmpuser;
469 $tmpuser = $conf->cache[
'users'][$obj->fk_user];
470 print $tmpuser->getNomUrl(-1);
472 print
'<span class="opacitymedium">'.$langs->trans(
"Everybody").
'</span>';
481 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>";
484 print
'<td class="right">'.$obj->position.
"</td>";
488 print
'<td class="nowrap center">';
489 if ($massactionbutton || $massaction) {
491 if (in_array(
$object->id, $arrayofselected)) {
494 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
509include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
514 foreach ($arrayfields as $key => $val) {
515 if (!empty($val[
'checked'])) {
519 print
'<tr><td colspan="'.$savnbfield.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
524$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
525$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
526print $hookmanager->resPrint;
528print
'</table>'.
"\n";
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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, $allowothertags=array())
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, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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...
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_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.