dolibarr  7.0.0-beta
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
24 require '../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php';
26 
27 $langs->load("bookmarks");
28 $langs->load("admin");
29 
30 $action=GETPOST('action','alpha');
31 $massaction=GETPOST('massaction','alpha');
32 $show_files=GETPOST('show_files','int');
33 $confirm=GETPOST('confirm','alpha');
34 $toselect = GETPOST('toselect', 'array');
35 
36 // Security check
37 if (! $user->rights->bookmark->lire) {
38  restrictedArea($user, 'bookmarks');
39 }
40 $optioncss = GETPOST('optioncss','alpha');
41 
42 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
43 $sortfield = GETPOST("sortfield",'alpha');
44 $sortorder = GETPOST("sortorder",'alpha');
45 $page = GETPOST("page",'int');
46 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
47 $offset = $limit * $page;
48 $pageprev = $page - 1;
49 $pagenext = $page + 1;
50 if (! $sortfield) $sortfield='position';
51 if (! $sortorder) $sortorder='ASC';
52 
53 $id = GETPOST("id",'int');
54 
55 
56 /*
57  * Actions
58  */
59 
60 if ($action == 'delete')
61 {
62  $bookmark=new Bookmark($db);
63  $res=$bookmark->remove($id);
64  if ($res > 0)
65  {
66  header("Location: ".$_SERVER["PHP_SELF"]);
67  exit;
68  }
69  else
70  {
71  setEventMessages($bookmark->error, $bookmark->errors, 'errors');
72  }
73 }
74 
75 
76 /*
77  * View
78  */
79 
80 $userstatic=new User($db);
81 
82 llxHeader('', $langs->trans("ListOfBookmarks"));
83 
84 print load_fiche_titre($langs->trans("ListOfBookmarks"));
85 
86 $sql = "SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,";
87 $sql.= " u.login, u.lastname, u.firstname";
88 $sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b LEFT JOIN ".MAIN_DB_PREFIX."user as u ON b.fk_user=u.rowid";
89 $sql.= " WHERE 1=1";
90 $sql.= " AND b.entity = ".$conf->entity;
91 if (! $user->admin) $sql.= " AND (b.fk_user = ".$user->id." OR b.fk_user is NULL OR b.fk_user = 0)";
92 $sql.= $db->order($sortfield.", position",$sortorder);
93 $sql.= $db->plimit($limit, $offset);
94 
95 $resql=$db->query($sql);
96 if ($resql)
97 {
98  $num = $db->num_rows($resql);
99  $i = 0;
100  $param = "";
101  if ($optioncss != '') $param ='&optioncss='.$optioncss;
102 
103  $moreforfilter='';
104 
105  print '<div class="div-table-responsive">';
106  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
107 
108  print "<tr class=\"liste_titre\">";
109  //print "<td>&nbsp;</td>";
110  print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"b.rowid","", $param,'align="left"',$sortfield,$sortorder);
111  print_liste_field_titre("Title",$_SERVER["PHP_SELF"],"b.title","", $param,'align="left"',$sortfield,$sortorder);
112  print_liste_field_titre("Link",$_SERVER["PHP_SELF"],"b.url","", $param,'align="left"',$sortfield,$sortorder);
113  print_liste_field_titre("Target",'','','','','align="center"');
114  print_liste_field_titre("Owner",$_SERVER["PHP_SELF"],"u.lastname","", $param,'align="center"',$sortfield,$sortorder);
115  print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"b.dateb","", $param,'align="center"',$sortfield,$sortorder);
116  print_liste_field_titre("Position",$_SERVER["PHP_SELF"],"b.position","", $param,'align="right"',$sortfield,$sortorder);
118  print "</tr>\n";
119 
120  $var=True;
121  while ($i < $num)
122  {
123  $obj = $db->fetch_object($resql);
124 
125 
126  print '<tr class="oddeven">';
127 
128  // Id
129  print '<td align="left">';
130  print "<a href=\"card.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowBookmark"),"bookmark").' '.$obj->rowid."</a>";
131  print '</td>';
132 
133  $linkintern=0;
134  $title=$obj->title;
135  $link=$obj->url;
136 
137  // Title
138  print "<td>";
139  $linkintern=1;
140  if ($linkintern) print "<a href=\"".$obj->url."\">";
141  print $title;
142  if ($linkintern) print "</a>";
143  print "</td>\n";
144 
145  // Url
146  print '<td class="tdoverflowmax200">';
147  if (! $linkintern) print '<a href="'.$obj->url.'"'.($obj->target?' target="newlink"':'').'>';
148  print $link;
149  if (! $linkintern) print '</a>';
150  print "</td>\n";
151 
152  // Target
153  print '<td align="center">';
154  if ($obj->target == 0) print $langs->trans("BookmarkTargetReplaceWindowShort");
155  if ($obj->target == 1) print $langs->trans("BookmarkTargetNewWindowShort");
156  print "</td>\n";
157 
158  // Author
159  print '<td align="center">';
160  if ($obj->fk_user)
161  {
162  $userstatic->id=$obj->fk_user;
163  $userstatic->lastname=$obj->login;
164  print $userstatic->getNomUrl(1);
165  }
166  else
167  {
168  print $langs->trans("Public");
169  }
170  print "</td>\n";
171 
172  // Date creation
173  print '<td align="center">'.dol_print_date($db->jdate($obj->dateb),'day')."</td>";
174 
175  // Position
176  print '<td align="right">'.$obj->position."</td>";
177 
178  // Actions
179  print '<td align="right" class="nowrap">';
180  if ($user->rights->bookmark->creer)
181  {
182  print "<a href=\"".DOL_URL_ROOT."/bookmarks/card.php?action=edit&id=".$obj->rowid."&backtopage=".urlencode($_SERVER["PHP_SELF"])."\">".img_edit()."</a> ";
183  }
184  if ($user->rights->bookmark->supprimer)
185  {
186  print "<a href=\"".$_SERVER["PHP_SELF"]."?action=delete&id=$obj->rowid\">".img_delete()."</a>";
187  }
188  else
189  {
190  print "&nbsp;";
191  }
192  print "</td>";
193  print "</tr>\n";
194  $i++;
195  }
196  print "</table>";
197  print '</div>';
198 
199  $db->free($resql);
200 }
201 else
202 {
203  dol_print_error($db);
204 }
205 
206 
207 
208 print "<div class=\"tabsAction\">\n";
209 
210 if ($user->rights->bookmark->creer)
211 {
212  print '<a class="butAction" href="'.DOL_URL_ROOT.'/bookmarks/card.php?action=create">'.$langs->trans("NewBookmark").'</a>';
213 }
214 
215 print '</div>';
216 
217 llxFooter();
218 $db->close();
219 
220 
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
Class to manage Dolibarr users.
Definition: user.class.php:39
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_delete($titlealt= 'default', $other= 'class="pictodelete"')
Show delete logo.
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
img_edit($titlealt= 'default', $float=0, $other= 'class="pictoedit"')
Show logo editer/modifier fiche.
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.
Class to manage bookmarks.