* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/bookmarks/list.php * \ingroup bookmark * \brief Page to display list of bookmarks */ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; // Load translation files required by the page $langs->loadLangs(array('bookmarks', 'admin')); // Get Parameters $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bookmarklist'; // To manage different context of search $id = GETPOST("id", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortfield) { $sortfield = 'b.position'; } if (!$sortorder) { $sortorder = 'ASC'; } // Initialize Objects $object = new Bookmark($db); // Security check restrictedArea($user, 'bookmark'); // Permissions $permissiontoread = !empty($user->rights->bookmark->lire); $permissiontoadd = !empty($user->rights->bookmark->creer); $permissiontodelete = !empty($user->rights->bookmark->supprimer); /* * Actions */ if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } if ($action == 'delete') { $res = $object->remove($id); if ($res > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } /* * View */ $form = new Form($db); $title = $langs->trans("ListOfBookmarks"); llxHeader('', $title); $sql = "SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,"; $sql .= " u.login, u.lastname, u.firstname"; $sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b LEFT JOIN ".MAIN_DB_PREFIX."user as u ON b.fk_user=u.rowid"; $sql .= " WHERE 1=1"; $sql .= " AND b.entity IN (".getEntity('bookmark').")"; if (!$user->admin) { $sql .= " AND (b.fk_user = ".((int) $user->id)." OR b.fk_user is NULL OR b.fk_user = 0)"; } // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { /* The fast and low memory method to get and count full list converts the sql into a sql count */ $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); if ($resql) { $objforcount = $db->fetch_object($resql); $nbtotalofrecords = $objforcount->nbtotalofrecords; } else { dol_print_error($db); } if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } $db->free($resql); } // Complete request and execute it with limit $sql .= $db->order($sortfield.", position", $sortorder); if ($limit) { $sql .= $db->plimit($limit + 1, $offset); } $resql = $db->query($sql); if (!$resql) { dol_print_error($db); exit; } $num = $db->num_rows($resql); $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } $moreforfilter = ''; // List of mass actions available $arrayofmassactions = array( //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
'."\n"; if ($optioncss != '') { print ''; } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $newcardbutton = ''; $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'), '', !empty($user->rights->bookmark->creer)); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bookmark', 0, $newcardbutton, '', $limit, 0, 0, 1); print '
'; print ''."\n"; print ''; //print ""; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "b.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "b.title", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Link", $_SERVER["PHP_SELF"], "b.url", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "b.target", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Visibility", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "b.dateb", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Position", $_SERVER["PHP_SELF"], "b.position", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre(''); print "\n"; $cacheOfUsers = array(); $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $object->id = $obj->rowid; $object->ref = $obj->rowid; print ''; // Id print ''; $linkintern = 1; if (preg_match('/^http/i', $obj->url)) { $linkintern = 0; } $title = $obj->title; $link = $obj->url; $canedit = $user->rights->bookmark->supprimer; $candelete = $user->rights->bookmark->creer; // Title print '\n"; // Url print '\n"; // Target print '\n"; // Author print '\n"; // Date creation print '"; // Position print '"; // Actions print '"; print "\n"; $i++; } print "
 
'; print $object->getNomUrl(1); print ''; print dol_escape_htmltag($title); print "'; if (empty($linkintern)) { print img_picto('', 'url', 'class="pictofixedwidth"'); print 'target ? ' target="newlink" rel="noopener"' : '').'>'; } else { //print img_picto('', 'rightarrow', 'class="pictofixedwidth"'); print ''; } print $link; print ''; print "'; if ($obj->target == 0) { print $langs->trans("BookmarkTargetReplaceWindowShort"); } if ($obj->target == 1) { print $langs->trans("BookmarkTargetNewWindowShort"); } print "'; if ($obj->fk_user) { if (empty($cacheOfUsers[$obj->fk_user])) { $tmpuser = new User($db); $tmpuser->fetch($obj->fk_user); $cacheOfUsers[$obj->fk_user] = $tmpuser; } $tmpuser = $cacheOfUsers[$obj->fk_user]; print $tmpuser->getNomUrl(1); } else { print ''.$langs->trans("Everybody").''; if (!$user->admin) { $candelete = false; $canedit = false; } } print "'.dol_print_date($db->jdate($obj->dateb), 'day')."'.$obj->position."'; if ($canedit) { print ''.img_edit().""; } if ($candelete) { print 'rowid.'">'.img_delete().''; } print "
"; print '
'; $db->free($resql); // End of page llxFooter(); $db->close();