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')) {
129 $objectclass =
'Bookmark';
130 $objectlabel =
'Bookmark';
131 $uploaddir =
$conf->bookmark->dir_output;
132 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
134 if ($action ==
'delete' && $permissiontodelete) {
139 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
153$form =
new Form($db);
159$title = $langs->trans(
"Bookmarks");
166$sql =
"SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,";
167$sql .=
" u.login, u.lastname, u.firstname";
169if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
170 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
171 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
175$parameters = array();
176$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
177$sql .= $hookmanager->resPrint;
178$sql = preg_replace(
'/,\s*$/',
'', $sql);
182$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as b LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON b.fk_user=u.rowid";
187$sql .=
" AND b.entity IN (".getEntity(
'bookmark').
")";
189 $sql .=
" AND (b.fk_user = ".((int) $user->id).
" OR b.fk_user is NULL OR b.fk_user = 0)";
193$nbtotalofrecords =
'';
196 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
197 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
198 $resql = $db->query($sqlforcount);
200 $objforcount = $db->fetch_object($resql);
201 $nbtotalofrecords = $objforcount->nbtotalofrecords;
203 dol_print_error($db);
206 if (($page * $limit) > (
int) $nbtotalofrecords) {
214$sql .= $db->order($sortfield.
", position", $sortorder);
216 $sql .= $db->plimit($limit + 1, $offset);
219$resql = $db->query($sql);
221 dol_print_error($db);
225$num = $db->num_rows($resql);
231llxHeader(
'', $title,
'',
'', 0, 0,
'',
'',
'',
'bodyforlist mod-bookmarks page-list');
233$arrayofselected = is_array($toselect) ? $toselect : array();
237 $param .=
'&mode='.urlencode($mode);
239if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
240 $param .=
'&contextpage='.urlencode($contextpage);
242if ($limit > 0 && $limit !=
$conf->liste_limit) {
243 $param .=
'&limit='.((int) $limit);
245if ($optioncss !=
'') {
246 $param .=
'&optioncss='.urlencode($optioncss);
249include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
251$parameters = array(
'param' => &$param);
252$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
253$param .= $hookmanager->resPrint;
256$arrayofmassactions = array(
262if (!empty($permissiontodelete)) {
263 $arrayofmassactions[
'predelete'] = img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
265if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
266 $arrayofmassactions = array();
268$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
270print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
271if ($optioncss !=
'') {
272 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
274print
'<input type="hidden" name="token" value="'.newToken().
'">';
275print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
276print
'<input type="hidden" name="action" value="list">';
277print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
278print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
279print
'<input type="hidden" name="page" value="'.$page.
'">';
280print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
281print
'<input type="hidden" name="page_y" value="">';
282print
'<input type="hidden" name="mode" value="'.$mode.
'">';
286$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);
288print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bookmark', 0, $newcardbutton,
'', $limit, 0, 0, 1);
291$topicmail =
"SendBookmarkRef";
292$modelmail =
"bookmark";
294$trackid =
'bookmark'.$object->id;
295include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
299$parameters = array();
300$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
301if (empty($reshook)) {
302 $moreforfilter .= $hookmanager->resPrint;
304 $moreforfilter = $hookmanager->resPrint;
307if (!empty($moreforfilter)) {
308 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
309 print $moreforfilter;
313$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
314$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
315$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
317print
'<div class="div-table-responsive">';
318print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
324$totalarray = array();
325$totalarray[
'nbfield'] = 0;
329print
'<tr class="liste_titre">';
330if (
$conf->main_checkbox_left_column) {
331 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
332 $totalarray[
'nbfield']++;
335$totalarray[
'nbfield']++;
337$totalarray[
'nbfield']++;
339$totalarray[
'nbfield']++;
340print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"b.target",
"", $param,
'', $sortfield, $sortorder,
'center ');
341$totalarray[
'nbfield']++;
342print_liste_field_titre(
"Visibility", $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
'', $sortfield, $sortorder,
'center ');
343$totalarray[
'nbfield']++;
344print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"b.dateb",
"", $param,
'', $sortfield, $sortorder,
'center ');
345$totalarray[
'nbfield']++;
346print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
"b.position",
"", $param,
'', $sortfield, $sortorder,
'right ');
347$totalarray[
'nbfield']++;
348if (!
$conf->main_checkbox_left_column) {
349 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
350 $totalarray[
'nbfield']++;
357$savnbfield = $totalarray[
'nbfield'];
358$totalarray = array();
359$totalarray[
'nbfield'] = 0;
360$imaxinloop = ($limit ? min($num, $limit) : $num);
361while ($i < $imaxinloop) {
362 $obj = $db->fetch_object($resql);
370 if ($mode ==
'kanban') {
372 print
'<tr><td colspan="'.$savnbfield.
'">';
373 print
'<div class="box-flex-container">';
377 if ($massactionbutton || $massaction) {
379 if (in_array(
$object->id, $arrayofselected)) {
383 print
$object->getKanbanView(
'', array(
'selected' => $selected));
384 if ($i == ($imaxinloop - 1)) {
391 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
393 if (
$conf->main_checkbox_left_column) {
394 print
'<td class="nowrap center">';
395 if ($massactionbutton || $massaction) {
397 if (in_array(
$object->id, $arrayofselected)) {
400 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
404 $totalarray[
'nbfield']++;
409 print
'<td class="nowraponall">';
414 if (preg_match(
'/^http/i', $obj->url)) {
417 $title = $obj->title;
419 $canedit = $permissiontoadd;
420 $candelete = $permissiontodelete;
423 print
'<td class="tdoverflowmax250" alt="'.dol_escape_htmltag($title).
'">';
428 print
'<td class="tdoverflowmax250">';
429 if (empty($linkintern)) {
430 print img_picto(
'',
'url',
'class="pictofixedwidth"');
431 print
'<a class="" href="'.$obj->url.
'"'.($obj->target ?
' target="newlink" rel="noopener"' :
'').
'>';
433 print
'<a class="" href="'.$obj->url.
'">';
440 print
'<td class="tdoverflowmax125 center">';
441 if ($obj->target == 0) {
442 print $langs->trans(
"BookmarkTargetReplaceWindowShort");
444 if ($obj->target == 1) {
445 print $langs->trans(
"BookmarkTargetNewWindowShort");
450 print
'<td class="tdoverflowmax125 center">';
451 if ($obj->fk_user > 0) {
452 if (empty(
$conf->cache[
'users'][$obj->fk_user])) {
453 $tmpuser =
new User($db);
454 $tmpuser->fetch($obj->fk_user);
455 $conf->cache[
'users'][$obj->fk_user] = $tmpuser;
457 $tmpuser =
$conf->cache[
'users'][$obj->fk_user];
458 print $tmpuser->getNomUrl(-1);
460 print
'<span class="opacitymedium">'.$langs->trans(
"Everybody").
'</span>';
469 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>";
472 print
'<td class="right">'.$obj->position.
"</td>";
475 if (!
$conf->main_checkbox_left_column) {
476 print
'<td class="nowrap center">';
477 if ($massactionbutton || $massaction) {
479 if (in_array(
$object->id, $arrayofselected)) {
482 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
486 $totalarray[
'nbfield']++;
497include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
502 foreach ($arrayfields as $key => $val) {
503 if (!empty($val[
'checked'])) {
507 print
'<tr><td colspan="'.$savnbfield.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
512$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
513$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
514print $hookmanager->resPrint;
516print
'</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.
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.