25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/bookmarks/class/bookmark.class.php';
29 $langs->loadLangs(array(
'bookmarks',
'admin'));
32 $action =
GETPOST(
'action',
'aZ09');
33 $massaction =
GETPOST(
'massaction',
'alpha');
34 $show_files =
GETPOST(
'show_files',
'int');
35 $confirm =
GETPOST(
'confirm',
'alpha');
36 $cancel =
GETPOST(
'cancel',
'alpha');
37 $toselect =
GETPOST(
'toselect',
'array');
38 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'bookmarklist';
39 $backtopage =
GETPOST(
'backtopage',
'alpha');
40 $optioncss =
GETPOST(
'optioncss',
'alpha');
46 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
47 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
48 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
50 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
54 $offset = $limit * $page;
55 $pageprev = $page - 1;
56 $pagenext = $page + 1;
58 $sortfield =
'b.position';
67 $arrayfields = array();
68 $hookmanager->initHooks(array(
'bookmarklist'));
81 $permissiontoread = $user->hasRight(
'bookmark',
'lire');
82 $permissiontoadd = $user->hasRight(
'bookmark',
'creer');
83 $permissiontodelete = ($user->hasRight(
'bookmark',
'supprimer') || ($permissiontoadd && $object->fk_user == $user->id));
90 if (
GETPOST(
'cancel',
'alpha')) {
94 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
98 $parameters = array();
99 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104 if (empty($reshook)) {
106 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
108 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
109 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
114 $objectclass =
'Bookmark';
115 $objectlabel =
'Bookmark';
116 $uploaddir = $conf->bookmark->dir_output;
117 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
119 if ($action ==
'delete' && $permissiontodelete) {
121 $res = $object->delete($user);
123 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
143 $title = $langs->trans(
"Bookmarks");
150 $sql =
"SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,";
151 $sql .=
" u.login, u.lastname, u.firstname";
153 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
154 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
155 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
159 $parameters = array();
160 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
161 $sql .= preg_replace(
'/^,/',
'', $hookmanager->resPrint);
162 $sql = preg_replace(
'/,\s*$/',
'', $sql);
166 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as b LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON b.fk_user=u.rowid";
167 $sql .=
" WHERE 1=1";
168 $sql .=
" AND b.entity IN (".getEntity(
'bookmark').
")";
170 $sql .=
" AND (b.fk_user = ".((int) $user->id).
" OR b.fk_user is NULL OR b.fk_user = 0)";
175 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
177 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
178 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
179 $resql = $db->query($sqlforcount);
181 $objforcount = $db->fetch_object(
$resql);
195 $sql .= $db->order($sortfield.
", position", $sortorder);
197 $sql .= $db->plimit($limit + 1, $offset);
200 $resql = $db->query($sql);
206 $num = $db->num_rows(
$resql);
214 $arrayofselected = is_array($toselect) ? $toselect : array();
218 $param .=
'&mode='.urlencode($mode);
220 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
221 $param .=
'&contextpage='.urlencode($contextpage);
223 if ($limit > 0 && $limit != $conf->liste_limit) {
224 $param .=
'&limit='.urlencode($limit);
226 if ($optioncss !=
'') {
227 $param .=
'&optioncss='.urlencode($optioncss);
230 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
232 $parameters = array();
233 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
234 $param .= $hookmanager->resPrint;
237 $arrayofmassactions = array(
243 if (!empty($permissiontodelete)) {
244 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
246 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
247 $arrayofmassactions = array();
249 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
251 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
252 if ($optioncss !=
'') {
253 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
255 print
'<input type="hidden" name="token" value="'.newToken().
'">';
256 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
257 print
'<input type="hidden" name="action" value="list">';
258 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
259 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
260 print
'<input type="hidden" name="page" value="'.$page.
'">';
261 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
262 print
'<input type="hidden" name="page_y" value="">';
263 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
267 $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);
269 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'bookmark', 0, $newcardbutton,
'', $limit, 0, 0, 1);
272 $topicmail =
"SendBookmarkRef";
273 $modelmail =
"bookmark";
275 $trackid =
'bookmark'.$object->id;
276 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
280 $parameters = array();
281 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object);
282 if (empty($reshook)) {
283 $moreforfilter .= $hookmanager->resPrint;
285 $moreforfilter = $hookmanager->resPrint;
288 if (!empty($moreforfilter)) {
289 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
290 print $moreforfilter;
294 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
295 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
296 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
298 print
'<div class="div-table-responsive">';
299 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
305 $totalarray = array();
306 $totalarray[
'nbfield'] = 0;
310 print
'<tr class="liste_titre">';
312 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
313 $totalarray[
'nbfield']++;
318 print_liste_field_titre(
"Target", $_SERVER[
"PHP_SELF"],
"b.target",
"", $param,
'', $sortfield, $sortorder,
'center ');
319 print_liste_field_titre(
"Visibility", $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
'', $sortfield, $sortorder,
'center ');
320 print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"b.dateb",
"", $param,
'', $sortfield, $sortorder,
'center ');
321 print_liste_field_titre(
"Position", $_SERVER[
"PHP_SELF"],
"b.position",
"", $param,
'', $sortfield, $sortorder,
'right ');
323 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
324 $totalarray[
'nbfield']++;
328 $totalarray = array();
329 $totalarray[
'nbfield'] = 0;
334 $savnbfield = $totalarray[
'nbfield'];
335 $totalarray = array();
336 $totalarray[
'nbfield'] = 0;
337 $imaxinloop = ($limit ? min($num, $limit) : $num);
338 while ($i < $imaxinloop) {
339 $obj = $db->fetch_object(
$resql);
344 $object->id = $obj->rowid;
345 $object->ref = $obj->rowid;
347 if ($mode ==
'kanban') {
349 print
'<tr><td colspan="'.$savnbfield.
'">';
350 print
'<div class="box-flex-container">';
353 print $object->getKanbanView(
'');
354 if ($i == ($imaxinloop - 1)) {
361 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
364 print
'<td class="nowrap center">';
365 if ($massactionbutton || $massaction) {
367 if (in_array($object->id, $arrayofselected)) {
370 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
374 $totalarray[
'nbfield']++;
379 print
'<td class="nowraponall">';
380 print $object->getNomUrl(1);
384 if (preg_match(
'/^http/i', $obj->url)) {
387 $title = $obj->title;
389 $canedit = $permissiontoadd;
390 $candelete = $permissiontodelete;
393 print
'<td class="tdoverflowmax200" alt="'.dol_escape_htmltag($title).
'">';
398 print
'<td class="tdoverflowmax200">';
399 if (empty($linkintern)) {
400 print
img_picto(
'',
'url',
'class="pictofixedwidth"');
401 print
'<a class="" href="'.$obj->url.
'"'.($obj->target ?
' target="newlink" rel="noopener"' :
'').
'>';
404 print
'<a class="" href="'.$obj->url.
'">';
411 print
'<td class="center">';
412 if ($obj->target == 0) {
413 print $langs->trans(
"BookmarkTargetReplaceWindowShort");
415 if ($obj->target == 1) {
416 print $langs->trans(
"BookmarkTargetNewWindowShort");
421 print
'<td class="center">';
422 if ($obj->fk_user > 0) {
423 if (empty($conf->cache[
'users'][$obj->fk_user])) {
424 $tmpuser =
new User($db);
425 $tmpuser->fetch($obj->fk_user);
426 $conf->cache[
'users'][$obj->fk_user] = $tmpuser;
428 $tmpuser = $conf->cache[
'users'][$obj->fk_user];
429 print $tmpuser->getNomUrl(-1);
431 print
'<span class="opacitymedium">'.$langs->trans(
"Everybody").
'</span>';
440 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>";
443 print
'<td class="right">'.$obj->position.
"</td>";
447 print
'<td class="nowrap center">';
448 if ($massactionbutton || $massaction) {
450 if (in_array($object->id, $arrayofselected)) {
453 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
457 $totalarray[
'nbfield']++;
468 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
473 foreach ($arrayfields as $key => $val) {
474 if (!empty($val[
'checked'])) {
478 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
483 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
484 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
485 print $hookmanager->resPrint;
487 print
'</table>'.
"\n";
490 print
'</form>'.
"\n";
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bookmarks.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
$nbtotalofrecords
Count total nb of records.
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.