27require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/bookmarks/class/bookmark.class.php';
40$langs->loadLangs(array(
'other',
'admin'));
43$action =
GETPOST(
'action',
'aZ09');
44$massaction =
GETPOST(
'massaction',
'alpha');
46$confirm =
GETPOST(
'confirm',
'alpha');
47$cancel =
GETPOST(
'cancel',
'alpha');
48$toselect =
GETPOST(
'toselect',
'array:int');
49$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'bookmarklist';
50$backtopage =
GETPOST(
'backtopage',
'alpha');
51$optioncss =
GETPOST(
'optioncss',
'alpha');
55$search_title =
GETPOST(
'search_title',
'alpha');
59$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
62if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
66$offset = $limit * $page;
70 $sortfield =
'b.position';
79$arrayfields = array();
81$parameters = array(
'arrayfields' => &$arrayfields);
82$reshook = $hookmanager->executeHooks(
'completeArrayFields', $parameters, $object, $action);
83$hookmanager->initHooks(array(
'bookmarklist'));
96$permissiontoread = $user->hasRight(
'bookmark',
'lire');
97$permissiontoadd = $user->hasRight(
'bookmark',
'creer');
98$permissiontodelete = ($user->hasRight(
'bookmark',
'supprimer') || ($permissiontoadd &&
$object->fk_user == $user->id));
105if (
GETPOST(
'cancel',
'alpha')) {
109if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
113$parameters = array();
114$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
116 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
119if (empty($reshook)) {
121 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
123 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
124 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
130 if (!$user->hasRight(
'bookmark',
'supprimer') && is_array($toselect) && count($toselect) > 0) {
131 $ownbookmarks = array();
132 $sqlown =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"bookmark";
133 $sqlown .=
" WHERE rowid IN (".$db->sanitize(implode(
',', array_map(
'intval', $toselect))).
")";
134 $sqlown .=
" AND fk_user = ".((int) $user->id);
135 $sqlown .=
" AND entity IN (".getEntity(
'bookmark').
")";
136 $resqlown = $db->query($sqlown);
138 while ($objown = $db->fetch_object($resqlown)) {
139 $ownbookmarks[] = (int) $objown->rowid;
142 $toselect = $ownbookmarks;
146 $objectclass =
'Bookmark';
147 $objectlabel =
'Bookmark';
148 $uploaddir =
$conf->bookmark->dir_output;
149 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
151 if ($action ==
'delete' && $permissiontodelete) {
156 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
170$form =
new Form($db);
176$title = $langs->trans(
"Bookmarks");
183$sql =
"SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,";
184$sql .=
" u.login, u.lastname, u.firstname";
186if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
187 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
188 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
192$parameters = array();
193$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
194$sql .= $hookmanager->resPrint;
195$sql = preg_replace(
'/,\s*$/',
'', $sql);
199$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as b LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON b.fk_user=u.rowid";
204$sql .=
" AND b.entity IN (".getEntity(
'bookmark').
")";
206 $sql .=
" AND (b.fk_user = ".((int) $user->id).
" OR b.fk_user is NULL OR b.fk_user = 0)";
210$nbtotalofrecords =
'';
213 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
214 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
215 $resql = $db->query($sqlforcount);
217 $objforcount = $db->fetch_object($resql);
218 $nbtotalofrecords = $objforcount->nbtotalofrecords;
220 dol_print_error($db);
223 if (($page * $limit) > (
int) $nbtotalofrecords) {
231$sql .= $db->order($sortfield.
", position", $sortorder);
233 $sql .= $db->plimit($limit + 1, $offset);
236$resql = $db->query($sql);
238 dol_print_error($db);
242$num = $db->num_rows($resql);
248llxHeader(
'', $title,
'',
'', 0, 0,
'',
'',
'',
'bodyforlist mod-bookmarks page-list');
250$arrayofselected = is_array($toselect) ? $toselect : array();
254 $param .=
'&mode='.urlencode($mode);
256if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
257 $param .=
'&contextpage='.urlencode($contextpage);
259if ($limit > 0 && $limit !=
$conf->liste_limit) {
260 $param .=
'&limit='.((int) $limit);
262if ($optioncss !=
'') {
263 $param .=
'&optioncss='.urlencode($optioncss);
266include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
268$parameters = array(
'param' => &$param);
269$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
270$param .= $hookmanager->resPrint;
273$arrayofmassactions = array(
279if (!empty($permissiontodelete)) {
280 $arrayofmassactions[
'predelete'] = img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
282if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
283 $arrayofmassactions = array();
285$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
287print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
288if ($optioncss !=
'') {
289 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
291print
'<input type="hidden" name="token" value="'.newToken().
'">';
292print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
293print
'<input type="hidden" name="action" value="list">';
294print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
295print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
296print
'<input type="hidden" name="page" value="'.$page.
'">';
297print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
298print
'<input type="hidden" name="page_y" value="">';
299print
'<input type="hidden" name="mode" value="'.$mode.
'">';
303$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);
305print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bookmark', 0, $newcardbutton,
'', $limit, 0, 0, 1);
308$topicmail =
"SendBookmarkRef";
309$modelmail =
"bookmark";
311$trackid =
'bookmark'.$object->id;
312include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
316$parameters = array();
317$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
318if (empty($reshook)) {
319 $moreforfilter .= $hookmanager->resPrint;
321 $moreforfilter = $hookmanager->resPrint;
324if (!empty($moreforfilter)) {
325 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
326 print $moreforfilter;
330$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
331$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
332$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
334print
'<div class="div-table-responsive">';
335print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
341$totalarray = array();
342$totalarray[
'nbfield'] = 0;
346print
'<tr class="liste_titre">';
347if (
$conf->main_checkbox_left_column) {
348 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
349 $totalarray[
'nbfield']++;
352$totalarray[
'nbfield']++;
354$totalarray[
'nbfield']++;
356$totalarray[
'nbfield']++;
357print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"b.target",
"", $param,
'', $sortfield, $sortorder,
'center ');
358$totalarray[
'nbfield']++;
359print_liste_field_titre(
"Visibility", $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
'', $sortfield, $sortorder,
'center ');
360$totalarray[
'nbfield']++;
361print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"b.dateb",
"", $param,
'', $sortfield, $sortorder,
'center ');
362$totalarray[
'nbfield']++;
363print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
"b.position",
"", $param,
'', $sortfield, $sortorder,
'right ');
364$totalarray[
'nbfield']++;
365if (!
$conf->main_checkbox_left_column) {
366 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
367 $totalarray[
'nbfield']++;
374$savnbfield = $totalarray[
'nbfield'];
375$totalarray = array();
376$totalarray[
'nbfield'] = 0;
377$imaxinloop = ($limit ? min($num, $limit) : $num);
378while ($i < $imaxinloop) {
379 $obj = $db->fetch_object($resql);
387 if ($mode ==
'kanban') {
389 print
'<tr><td colspan="'.$savnbfield.
'">';
390 print
'<div class="box-flex-container">';
394 if ($massactionbutton || $massaction) {
396 if (in_array(
$object->id, $arrayofselected)) {
400 print
$object->getKanbanView(
'', array(
'selected' => $selected));
401 if ($i == ($imaxinloop - 1)) {
408 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
410 if (
$conf->main_checkbox_left_column) {
411 print
'<td class="nowrap center">';
412 if ($massactionbutton || $massaction) {
414 if (in_array(
$object->id, $arrayofselected)) {
417 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
421 $totalarray[
'nbfield']++;
426 print
'<td class="nowraponall">';
431 if (preg_match(
'/^http/i', $obj->url)) {
434 $title = $obj->title;
436 $canedit = $permissiontoadd;
437 $candelete = $permissiontodelete;
440 print
'<td class="tdoverflowmax250" alt="'.dol_escape_htmltag($title).
'">';
445 print
'<td class="tdoverflowmax250">';
446 if (empty($linkintern)) {
447 print img_picto(
'',
'url',
'class="pictofixedwidth"');
448 print
'<a class="" href="'.$obj->url.
'"'.($obj->target ?
' target="newlink" rel="noopener"' :
'').
'>';
450 print
'<a class="" href="'.$obj->url.
'">';
457 print
'<td class="tdoverflowmax125 center">';
458 if ($obj->target == 0) {
459 print $langs->trans(
"BookmarkTargetReplaceWindowShort");
461 if ($obj->target == 1) {
462 print $langs->trans(
"BookmarkTargetNewWindowShort");
467 print
'<td class="tdoverflowmax125 center">';
468 if ($obj->fk_user > 0) {
469 if (empty(
$conf->cache[
'users'][$obj->fk_user])) {
470 $tmpuser =
new User($db);
471 $tmpuser->fetch($obj->fk_user);
472 $conf->cache[
'users'][$obj->fk_user] = $tmpuser;
474 $tmpuser =
$conf->cache[
'users'][$obj->fk_user];
475 print $tmpuser->getNomUrl(-1);
477 print
'<span class="opacitymedium">'.$langs->trans(
"Everybody").
'</span>';
486 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>";
489 print
'<td class="right">'.$obj->position.
"</td>";
492 if (!
$conf->main_checkbox_left_column) {
493 print
'<td class="nowrap center">';
494 if ($massactionbutton || $massaction) {
496 if (in_array(
$object->id, $arrayofselected)) {
499 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
503 $totalarray[
'nbfield']++;
514include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
519 foreach ($arrayfields as $key => $val) {
520 if (!empty($val[
'checked'])) {
524 print
'<tr><td colspan="'.$savnbfield.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
529$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
530$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
531print $hookmanager->resPrint;
533print
'</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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage bookmarks.
Class to manage Dolibarr users.
dol_now($mode='gmt')
Return date for now.
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.