27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/bookmarks/class/bookmark.class.php';
39$langs->loadLangs(array(
'bookmarks',
'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');
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')) {
125 $objectclass =
'Bookmark';
126 $objectlabel =
'Bookmark';
127 $uploaddir =
$conf->bookmark->dir_output;
128 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
130 if ($action ==
'delete' && $permissiontodelete) {
134 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
148$form =
new Form($db);
154$title = $langs->trans(
"Bookmarks");
161$sql =
"SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,";
162$sql .=
" u.login, u.lastname, u.firstname";
164if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
165 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
166 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
170$parameters = array();
171$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
172$sql .= $hookmanager->resPrint;
173$sql = preg_replace(
'/,\s*$/',
'', $sql);
177$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as b LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON b.fk_user=u.rowid";
182$sql .=
" AND b.entity IN (".getEntity(
'bookmark').
")";
184 $sql .=
" AND (b.fk_user = ".((int) $user->id).
" OR b.fk_user is NULL OR b.fk_user = 0)";
188$nbtotalofrecords =
'';
191 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
192 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
193 $resql = $db->query($sqlforcount);
195 $objforcount = $db->fetch_object($resql);
196 $nbtotalofrecords = $objforcount->nbtotalofrecords;
201 if (($page * $limit) > $nbtotalofrecords) {
209$sql .= $db->order($sortfield.
", position", $sortorder);
211 $sql .= $db->plimit($limit + 1, $offset);
214$resql = $db->query($sql);
220$num = $db->num_rows($resql);
226llxHeader(
'', $title,
'',
'', 0, 0,
'',
'',
'',
'bodyforlist mod-bookmarks page-list');
228$arrayofselected = is_array($toselect) ? $toselect : array();
232 $param .=
'&mode='.urlencode($mode);
234if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
235 $param .=
'&contextpage='.urlencode($contextpage);
237if ($limit > 0 && $limit !=
$conf->liste_limit) {
238 $param .=
'&limit='.((int) $limit);
240if ($optioncss !=
'') {
241 $param .=
'&optioncss='.urlencode($optioncss);
244include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
246$parameters = array(
'param' => &$param);
247$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
248$param .= $hookmanager->resPrint;
251$arrayofmassactions = array(
257if (!empty($permissiontodelete)) {
258 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
260if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
261 $arrayofmassactions = array();
263$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
265print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
266if ($optioncss !=
'') {
267 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
269print
'<input type="hidden" name="token" value="'.newToken().
'">';
270print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
271print
'<input type="hidden" name="action" value="list">';
272print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
273print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
274print
'<input type="hidden" name="page" value="'.$page.
'">';
275print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
276print
'<input type="hidden" name="page_y" value="">';
277print
'<input type="hidden" name="mode" value="'.$mode.
'">';
281$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);
283print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bookmark', 0, $newcardbutton,
'', $limit, 0, 0, 1);
286$topicmail =
"SendBookmarkRef";
287$modelmail =
"bookmark";
289$trackid =
'bookmark'.$object->id;
290include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
294$parameters = array();
295$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
296if (empty($reshook)) {
297 $moreforfilter .= $hookmanager->resPrint;
299 $moreforfilter = $hookmanager->resPrint;
302if (!empty($moreforfilter)) {
303 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
304 print $moreforfilter;
308$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
309$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
310$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
312print
'<div class="div-table-responsive">';
313print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
319$totalarray = array();
320$totalarray[
'nbfield'] = 0;
324print
'<tr class="liste_titre">';
326 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
327 $totalarray[
'nbfield']++;
330$totalarray[
'nbfield']++;
332$totalarray[
'nbfield']++;
334$totalarray[
'nbfield']++;
335print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"b.target",
"", $param,
'', $sortfield, $sortorder,
'center ');
336$totalarray[
'nbfield']++;
337print_liste_field_titre(
"Visibility", $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
'', $sortfield, $sortorder,
'center ');
338$totalarray[
'nbfield']++;
339print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"b.dateb",
"", $param,
'', $sortfield, $sortorder,
'center ');
340$totalarray[
'nbfield']++;
341print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
"b.position",
"", $param,
'', $sortfield, $sortorder,
'right ');
342$totalarray[
'nbfield']++;
344 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
345 $totalarray[
'nbfield']++;
352$savnbfield = $totalarray[
'nbfield'];
353$totalarray = array();
354$totalarray[
'nbfield'] = 0;
355$imaxinloop = ($limit ? min($num, $limit) : $num);
356while ($i < $imaxinloop) {
357 $obj = $db->fetch_object($resql);
365 if ($mode ==
'kanban') {
367 print
'<tr><td colspan="'.$savnbfield.
'">';
368 print
'<div class="box-flex-container">';
372 if ($massactionbutton || $massaction) {
374 if (in_array(
$object->id, $arrayofselected)) {
378 print
$object->getKanbanView(
'', array(
'selected' => $selected));
379 if ($i == ($imaxinloop - 1)) {
386 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
389 print
'<td class="nowrap center">';
390 if ($massactionbutton || $massaction) {
392 if (in_array(
$object->id, $arrayofselected)) {
395 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
399 $totalarray[
'nbfield']++;
404 print
'<td class="nowraponall">';
409 if (preg_match(
'/^http/i', $obj->url)) {
412 $title = $obj->title;
414 $canedit = $permissiontoadd;
415 $candelete = $permissiontodelete;
418 print
'<td class="tdoverflowmax250" alt="'.dol_escape_htmltag($title).
'">';
423 print
'<td class="tdoverflowmax250">';
424 if (empty($linkintern)) {
425 print
img_picto(
'',
'url',
'class="pictofixedwidth"');
426 print
'<a class="" href="'.$obj->url.
'"'.($obj->target ?
' target="newlink" rel="noopener"' :
'').
'>';
429 print
'<a class="" href="'.$obj->url.
'">';
436 print
'<td class="tdoverflowmax125 center">';
437 if ($obj->target == 0) {
438 print $langs->trans(
"BookmarkTargetReplaceWindowShort");
440 if ($obj->target == 1) {
441 print $langs->trans(
"BookmarkTargetNewWindowShort");
446 print
'<td class="tdoverflowmax125 center">';
447 if ($obj->fk_user > 0) {
448 if (empty(
$conf->cache[
'users'][$obj->fk_user])) {
449 $tmpuser =
new User($db);
450 $tmpuser->fetch($obj->fk_user);
451 $conf->cache[
'users'][$obj->fk_user] = $tmpuser;
453 $tmpuser =
$conf->cache[
'users'][$obj->fk_user];
454 print $tmpuser->getNomUrl(-1);
456 print
'<span class="opacitymedium">'.$langs->trans(
"Everybody").
'</span>';
465 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>";
468 print
'<td class="right">'.$obj->position.
"</td>";
472 print
'<td class="nowrap center">';
473 if ($massactionbutton || $massaction) {
475 if (in_array(
$object->id, $arrayofselected)) {
478 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
482 $totalarray[
'nbfield']++;
493include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
498 foreach ($arrayfields as $key => $val) {
499 if (!empty($val[
'checked'])) {
503 print
'<tr><td colspan="'.$savnbfield.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
508$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
509$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
510print $hookmanager->resPrint;
512print
'</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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.