Merge pull request #1344 from GPCsolutions/feature/multicompanybookmarks
Feature/multicompanybookmarks
This commit is contained in:
commit
db10740e2a
@ -67,6 +67,7 @@ function printBookmarksList($aDb, $aLangs)
|
|||||||
{
|
{
|
||||||
$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
|
$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
|
||||||
$sql.= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
|
$sql.= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
|
||||||
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
$sql.= " ORDER BY position";
|
$sql.= " ORDER BY position";
|
||||||
if ($resql = $db->query($sql) )
|
if ($resql = $db->query($sql) )
|
||||||
{
|
{
|
||||||
|
|||||||
@ -57,10 +57,13 @@ class Bookmark
|
|||||||
*/
|
*/
|
||||||
function fetch($id)
|
function fetch($id)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT rowid, fk_user, dateb as datec, url, target,";
|
$sql = "SELECT rowid, fk_user, dateb as datec, url, target,";
|
||||||
$sql.= " title, position, favicon";
|
$sql.= " title, position, favicon";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark";
|
||||||
$sql.= " WHERE rowid = ".$id;
|
$sql.= " WHERE rowid = ".$id;
|
||||||
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
dol_syslog("Bookmark::fetch sql=".$sql, LOG_DEBUG);
|
dol_syslog("Bookmark::fetch sql=".$sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -96,6 +99,8 @@ class Bookmark
|
|||||||
*/
|
*/
|
||||||
function create()
|
function create()
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->url=trim($this->url);
|
$this->url=trim($this->url);
|
||||||
$this->title=trim($this->title);
|
$this->title=trim($this->title);
|
||||||
@ -107,12 +112,14 @@ class Bookmark
|
|||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target";
|
||||||
$sql.= ",title,favicon,position";
|
$sql.= ",title,favicon,position";
|
||||||
|
$sql.= ",entity";
|
||||||
if ($this->fk_soc) $sql.=",fk_soc";
|
if ($this->fk_soc) $sql.=",fk_soc";
|
||||||
$sql.= ") VALUES (";
|
$sql.= ") VALUES (";
|
||||||
$sql.= ($this->fk_user > 0?"'".$this->fk_user."'":"0").",";
|
$sql.= ($this->fk_user > 0?"'".$this->fk_user."'":"0").",";
|
||||||
$sql.= " ".$this->db->idate($now).",";
|
$sql.= " ".$this->db->idate($now).",";
|
||||||
$sql.= " '".$this->url."', '".$this->target."',";
|
$sql.= " '".$this->url."', '".$this->target."',";
|
||||||
$sql.= " '".$this->db->escape($this->title)."', '".$this->favicon."', '".$this->position."'";
|
$sql.= " '".$this->db->escape($this->title)."', '".$this->favicon."', '".$this->position."'";
|
||||||
|
$sql.= ", '".$conf->entity."'";
|
||||||
if ($this->fk_soc) $sql.=",".$this->fk_soc;
|
if ($this->fk_soc) $sql.=",".$this->fk_soc;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
|
|||||||
@ -26,8 +26,14 @@
|
|||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php';
|
||||||
|
|
||||||
|
$langs->load("bookmarks");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
|
|
||||||
|
// Security check
|
||||||
|
if (! $user->rights->bookmark->lire) {
|
||||||
|
restrictedArea($user, 'bookmarks');
|
||||||
|
}
|
||||||
|
|
||||||
$id=GETPOST("id");
|
$id=GETPOST("id");
|
||||||
$action=GETPOST("action","alpha");
|
$action=GETPOST("action","alpha");
|
||||||
$title=GETPOST("title","alpha");
|
$title=GETPOST("title","alpha");
|
||||||
|
|||||||
@ -24,6 +24,12 @@
|
|||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php';
|
||||||
|
|
||||||
|
$langs->load("bookmarks");
|
||||||
|
|
||||||
|
// Security check
|
||||||
|
if (! $user->rights->bookmark->lire) {
|
||||||
|
restrictedArea($user, 'bookmarks');
|
||||||
|
}
|
||||||
|
|
||||||
$sortfield = GETPOST("sortfield",'alpha');
|
$sortfield = GETPOST("sortfield",'alpha');
|
||||||
$sortorder = GETPOST("sortorder",'alpha');
|
$sortorder = GETPOST("sortorder",'alpha');
|
||||||
@ -73,6 +79,7 @@ $sql = "SELECT b.fk_soc as rowid, b.dateb, b.rowid as bid, b.fk_user, b.url, b.t
|
|||||||
$sql.= " u.login, u.lastname, u.firstname";
|
$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.= " 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.= " 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)";
|
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->order($sortfield.", position",$sortorder);
|
||||||
$sql.= $db->plimit($limit, $offset);
|
$sql.= $db->plimit($limit, $offset);
|
||||||
|
|||||||
@ -1,149 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
*
|
|
||||||
* 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/comm/bookmark.php
|
|
||||||
* \brief Page affichage des bookmarks
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
require '../main.inc.php';
|
|
||||||
|
|
||||||
|
|
||||||
$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="DESC";
|
|
||||||
if (! $sortfield) $sortfield="bid";
|
|
||||||
$limit = $conf->liste_limit;
|
|
||||||
|
|
||||||
|
|
||||||
llxHeader();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Actions
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($_GET["action"] == 'add')
|
|
||||||
{
|
|
||||||
$bookmark=new Bookmark($db);
|
|
||||||
$bookmark->fk_user=$user->id;
|
|
||||||
$bookmark->url=$user->id;
|
|
||||||
$bookmark->target=$user->id;
|
|
||||||
$bookmark->title='xxx';
|
|
||||||
$bookmark->favicon='xxx';
|
|
||||||
|
|
||||||
$res=$bookmark->create();
|
|
||||||
if ($res > 0)
|
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mesg='<div class="error">'.$bookmark->error.'</div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_GET["action"] == 'delete')
|
|
||||||
{
|
|
||||||
$bookmark=new Bookmark($db);
|
|
||||||
$bookmark->id=$_GET["bid"];
|
|
||||||
$bookmark->url=$user->id;
|
|
||||||
$bookmark->target=$user->id;
|
|
||||||
$bookmark->title='xxx';
|
|
||||||
$bookmark->favicon='xxx';
|
|
||||||
|
|
||||||
$res=$bookmark->remove();
|
|
||||||
if ($res > 0)
|
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mesg='<div class="error">'.$bookmark->error.'</div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("Bookmarks"));
|
|
||||||
|
|
||||||
$sql = "SELECT s.rowid, s.nom as name, b.dateb as dateb, b.rowid as bid, b.fk_user, b.url, b.target, u.lastname, u.firstname";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."user as u";
|
|
||||||
$sql.= " WHERE b.fk_soc = s.rowid AND b.fk_user=u.rowid";
|
|
||||||
if (! $user->admin) $sql.= " AND b.fk_user = ".$user->id;
|
|
||||||
$sql.= $db->order($sortfield,$sortorder);
|
|
||||||
$sql.= $db->plimit($limit, $offset);
|
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
if ($sortorder == "DESC") $sortorder="ASC";
|
|
||||||
else $sortorder="DESC";
|
|
||||||
|
|
||||||
print "<table class=\"noborder\" width=\"100%\">";
|
|
||||||
|
|
||||||
print "<tr class=\"liste_titre\">";
|
|
||||||
//print "<td> </td>";
|
|
||||||
print_liste_field_titre($langs->trans("Id"),$_SERVER["PHP_SELF"],"bid","","",'align="center"',$sortfield,$sortorder);
|
|
||||||
print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"],"u.lastname","","","",$sortfield,$sortorder);
|
|
||||||
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"b.dateb","","",'align="center"',$sortfield,$sortorder);
|
|
||||||
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder);
|
|
||||||
print_liste_field_titre($langs->trans("Url"),$_SERVER["PHP_SELF"],"b.url","","",'',$sortfield,$sortorder);
|
|
||||||
print "<td>".$langs->trans("Target")."</td>";
|
|
||||||
print "<td> </td>";
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
$var=True;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($resql);
|
|
||||||
|
|
||||||
$var=!$var;
|
|
||||||
print "<tr ".$bc[$var].">";
|
|
||||||
//print "<td>" . ($i + 1 + ($limit * $page)) . "</td>";
|
|
||||||
print "<td align=\"center\"><b>".$obj->bid."</b></td>";
|
|
||||||
print "<td><a href='".DOL_URL_ROOT."/user/fiche.php?id=".$obj->fk_user."'>".img_object($langs->trans("ShowUser"),"user").' '.$obj->lastname." ".$obj->firstname."</a></td>\n";
|
|
||||||
print '<td align="center">'.dol_print_date($db->jdate($obj->dateb))."</td>";
|
|
||||||
print "<td><a href=\"index.php?socid=".$obj->rowid."\">".img_object($langs->trans("ShowCompany"),"company").' '.$obj->name."</a></td>\n";
|
|
||||||
print '<td align="center">'.$obj->url."</td>";
|
|
||||||
print '<td align="center">'.$obj->target."</td>";
|
|
||||||
print "<td><a href=\"bookmark.php?action=delete&bid=".$obj->bid."\">".img_delete()."</a></td>\n";
|
|
||||||
print "</tr>\n";
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
print "</table>";
|
|
||||||
$db->free($resql);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
llxFooter();
|
|
||||||
?>
|
|
||||||
@ -53,26 +53,6 @@ $now=dol_now();
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'add_bookmark' && ! empty($socid))
|
|
||||||
{
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$db->escape($socid)." AND fk_user=".$user->id;
|
|
||||||
if (! $db->query($sql) )
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$db->escape($socid).", ".$db->idate($now).",".$user->id.");";
|
|
||||||
if (! $db->query($sql) )
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'del_bookmark' && ! empty($bid))
|
|
||||||
{
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=".$db->escape($bid);
|
|
||||||
$result = $db->query($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
|
|||||||
@ -62,30 +62,6 @@ if ($user->societe_id > 0)
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'add_bookmark')
|
|
||||||
{
|
|
||||||
$now=dol_now();
|
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$socid." AND fk_user=".$user->id;
|
|
||||||
if (! $db->query($sql) )
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$socid.", ".$db->idate($now).",".$user->id.");";
|
|
||||||
if (! $db->query($sql) )
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'del_bookmark' && ! empty($bid))
|
|
||||||
{
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=".$db->escape($bid);
|
|
||||||
$result = $db->query($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class box_bookmarks extends ModeleBoxes
|
|||||||
*/
|
*/
|
||||||
function loadBox($max=5)
|
function loadBox($max=5)
|
||||||
{
|
{
|
||||||
global $user, $langs, $db;
|
global $user, $langs, $db, $conf;
|
||||||
$langs->load("boxes");
|
$langs->load("boxes");
|
||||||
|
|
||||||
$this->max=$max;
|
$this->max=$max;
|
||||||
@ -70,6 +70,7 @@ class box_bookmarks extends ModeleBoxes
|
|||||||
$sql = "SELECT b.title, b.url, b.target, b.favicon";
|
$sql = "SELECT b.title, b.url, b.target, b.favicon";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b";
|
||||||
$sql.= " WHERE fk_user = ".$user->id;
|
$sql.= " WHERE fk_user = ".$user->id;
|
||||||
|
$sql.= " AND b.entity = ".$conf->entity;
|
||||||
$sql.= $db->order("position","ASC");
|
$sql.= $db->order("position","ASC");
|
||||||
$sql.= $db->plimit($max, 0);
|
$sql.= $db->plimit($max, 0);
|
||||||
|
|
||||||
|
|||||||
@ -17,4 +17,4 @@
|
|||||||
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
|
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
|
||||||
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
|
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
|
||||||
|
|
||||||
|
ALTER TABLE llx_bookmark ADD COLUMN entity integer DEFAULT 1 NOT NULL;
|
||||||
|
|||||||
@ -26,5 +26,6 @@ create table llx_bookmark
|
|||||||
target varchar(16),
|
target varchar(16),
|
||||||
title varchar(64),
|
title varchar(64),
|
||||||
favicon varchar(24),
|
favicon varchar(24),
|
||||||
position integer DEFAULT 0
|
position integer DEFAULT 0,
|
||||||
|
entity integer DEFAULT 1 NOT NULL -- multicompany ID
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user