-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
list.php
218 lines (182 loc) · 6.34 KB
/
list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
/* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/bookmarks/list.php
* \brief Page to display list of bookmarks
* \ingroup bookmark
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php';
$langs->load("bookmarks");
$langs->load("admin");
// Security check
if (! $user->rights->bookmark->lire) {
restrictedArea($user, 'bookmarks');
}
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="position";
$limit=$conf->liste_limit;
/*
* Actions
*/
if ($_GET["action"] == 'delete')
{
$bookmark=new Bookmark($db);
$res=$bookmark->remove($_GET["bid"]);
if ($res > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
setEventMessage($bookmark->error, 'errors');
}
}
/*
* View
*/
$userstatic=new User($db);
llxHeader();
print_fiche_titre($langs->trans("Bookmarks"));
$sql = "SELECT b.fk_soc as rowid, b.dateb, b.rowid as bid, 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 = ".$conf->entity;
if (! $user->admin) $sql.= " AND (b.fk_user = ".$user->id." OR b.fk_user is NULL OR b.fk_user = 0)";
$sql.= $db->order($sortfield.", position",$sortorder);
$sql.= $db->plimit($limit, $offset);
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
//print "<td> </td>";
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"bid","","",'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Title"),'','')."</td>";
print_liste_field_titre($langs->trans("Link"),'','')."</td>";
print_liste_field_titre($langs->trans("Target"),'','','','','align="center"')."</td>";
print_liste_field_titre($langs->trans("Owner"),$_SERVER["PHP_SELF"],"u.lastname","","",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"b.dateb","","",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Position"),$_SERVER["PHP_SELF"],"b.position","","",'align="right"',$sortfield,$sortorder);
print_liste_field_titre('','','');
print "</tr>\n";
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr ".$bc[$var].">";
// Id
print '<td align="left">';
print "<a href=\"card.php?id=".$obj->bid."\">".img_object($langs->trans("ShowBookmark"),"bookmark").' '.$obj->bid."</a>";
print '</td>';
$lieninterne=0;
$title=dol_trunc($obj->title,24);
$lien=dol_trunc($obj->url,24);
// Title
print "<td>";
if ($obj->rowid)
{
// Lien interne societe
$lieninterne=1;
$lien="Dolibarr";
if (! $obj->title)
{
// For compatibility with old Dolibarr bookmarks
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$societe=new Societe($db);
$societe->fetch($obj->rowid);
$obj->title=$societe->name;
}
$title=img_object($langs->trans("ShowCompany"),"company").' '.$obj->title;
}
if ($lieninterne) print "<a href=\"".$obj->url."\">";
print $title;
if ($lieninterne) print "</a>";
print "</td>\n";
// Url
print "<td>";
if (! $lieninterne) print '<a href="'.$obj->url.'"'.($obj->target?' target="newlink"':'').'>';
print $lien;
if (! $lieninterne) print '</a>';
print "</td>\n";
// Target
print '<td align="center">';
if ($obj->target == 0) print $langs->trans("BookmarkTargetReplaceWindowShort");
if ($obj->target == 1) print $langs->trans("BookmarkTargetNewWindowShort");
print "</td>\n";
// Author
print '<td align="center">';
if ($obj->fk_user)
{
$userstatic->id=$obj->fk_user;
$userstatic->lastname=$obj->login;
print $userstatic->getNomUrl(1);
}
else
{
print $langs->trans("Public");
}
print "</td>\n";
// Date creation
print '<td align="center">'.dol_print_date($db->jdate($obj->dateb),'day')."</td>";
// Position
print '<td align="right">'.$obj->position."</td>";
// Actions
print '<td align="right" class="nowrap">';
if ($user->rights->bookmark->creer)
{
print "<a href=\"".DOL_URL_ROOT."/bookmarks/card.php?action=edit&id=".$obj->bid."&backtopage=".urlencode($_SERVER["PHP_SELF"])."\">".img_edit()."</a> ";
}
if ($user->rights->bookmark->supprimer)
{
print "<a href=\"".$_SERVER["PHP_SELF"]."?action=delete&bid=$obj->bid\">".img_delete()."</a>";
}
else
{
print " ";
}
print "</td>";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free($resql);
}
else
{
dol_print_error($db);
}
print "<div class=\"tabsAction\">\n";
if ($user->rights->bookmark->creer)
{
print '<a class="butAction" href="card.php?action=create">'.$langs->trans("NewBookmark").'</a>';
}
print '</div>';
$db->close();
llxFooter();